--- - branch: MAIN date: Mon Mar 28 12:33:41 UTC 2022 files: - new: '1.298' old: '1.297' path: src/sys/kern/subr_autoconf.c pathrev: src/sys/kern/subr_autoconf.c@1.298 type: modified - new: '1.180' old: '1.179' path: src/sys/sys/device.h pathrev: src/sys/sys/device.h@1.180 type: modified id: 20220328T123341Z.db925eba0d5d8fbd23df802b8d1e2f25951e601a log: | autoconf(9): New localcount-based device instance references. device_lookup_acquire looks up an autoconf device instance, if found, and acquires a reference the caller must release with device_release. If attach or detach is still in progress, device_lookup_acquire waits until it completes. While references are held, the device's softc will not be freed or reused until the last reference is released. The reference is meant to be held while opening a device in the short term, and then to be passed off to a longer-term reference that can be broken explicitly by detach -- usually a device special vnode, which is broken by vdevgone in the driver's *_detach function. Sleeping while holding a reference is allowed, e.g. waiting to open a tty. A driver must arrange that its *_detach function will interrupt any threads sleeping while holding references and cause them to back out so that detach can complete promptly. Subsequent changes to subr_devsw.c will make bdev_open and cdev_open automatically take a reference to an autoconf instance for drivers that opt into this, so there will be no logic changes needed in most drivers other than to connect the autoconf cfdriver to the bdevsw/cdevsw I/O operation tables. The effect will be that *_detach may run while d_open is in progress, but no new d_open can begin until *_detach has backed out from or committed to detaching. XXX kernel ABI change to struct device requires bump -- later change will make struct device opaque to ABI, but we're not there yet module: src subject: 'CVS commit: src/sys' unixtime: '1648470821' user: riastradh