Go to file
dyoung 0d1ba3e899 During shutdown, detach devices in an orderly fashion.
Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks.  For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown.  Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags.  Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag.  The default for kern.detachall is 0.  SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress.  In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs.  Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
2009-04-02 00:09:32 +00:00
bin Bump date for previous. 2009-03-29 08:54:10 +00:00
common Fix crash where user was able to crash proplib with trying to internalize 2009-03-30 07:42:51 +00:00
compat Prefer MACHINE_ARCH to MACHINE in some tests 2009-03-12 17:16:58 +00:00
crypto apply patches from upstream CVS to fix 3 security problems: 2009-03-27 10:41:29 +00:00
dist add missing commas to .Dd fix, pointed out by wiz 2009-03-22 14:29:34 +00:00
distrib Add byteorder(9) man page which describes htole32() etc. From FreeBSD 2009-03-31 16:11:59 +00:00
doc uvm_kmguard chgs 2009-03-29 10:56:43 +00:00
etc Use the new ?= operator to set the on_panic value for the optional ddb 2009-04-01 16:20:55 +00:00
external add -n to gzip invocation 2009-03-31 21:12:51 +00:00
games Avoid hardcoded "too large" constant that caused FPE on the vax. 2009-03-31 18:48:16 +00:00
gnu regenerated after i386 gcc configuration change (assume i486) 2009-03-27 19:38:43 +00:00
include Revert previous since it was just wrong. 2009-03-19 08:04:38 +00:00
lib Make keypad return an int instead of nothing, as the SUS and even 2009-04-01 20:59:15 +00:00
libexec Fix redirection core dump as reported in PR#41042. 2009-03-23 12:49:28 +00:00
regress remove obsolete comment. 2009-03-08 19:17:11 +00:00
rescue - rework this a bunch to make it work inside /rescue/ldd. 2009-01-07 00:39:23 +00:00
sbin Don't print an error with sysctl -w name?=value if name does not exist. 2009-04-01 15:55:27 +00:00
share Add a _ARRANFL for the flags for invoking ar as ranlib. 2009-04-01 17:47:39 +00:00
sys During shutdown, detach devices in an orderly fashion. 2009-04-02 00:09:32 +00:00
tests ipf does not live here; it is in the parent directory. Spotted by njoly@. 2009-02-27 07:32:33 +00:00
tools -introduce a "COMMON_CONFIGURE_ARGS" variable which is included by 2009-03-27 19:19:49 +00:00
usr.bin note that -n also stops the timestamp from being output. 2009-04-01 08:15:37 +00:00
usr.sbin Make the ddb.onpanic line acceptable even if commented out 2009-04-01 16:38:46 +00:00
x11 add -n to gzip invocation 2009-03-31 21:12:51 +00:00
build.sh Add a MKARZERO flag, which invokes ar(1) with the new D flag when it 2009-03-13 16:23:31 +00:00
BUILDING be explicit about MAKEOBJDIR and MAKEOBJDIRPREFIX not being for 2008-12-02 22:28:21 +00:00
Makefile Disable grep host tool and unbreak NetBSD build until I can come up with a 2009-02-25 22:28:36 +00:00
Makefile.inc don't set KERNSRCDIR here; pull in <bsd.kernobj.mk> if you need it 2002-04-10 14:53:43 +00:00
UPDATING add a note about needing to rebuild i386 toolchain 2009-03-29 18:33:56 +00:00