|Konstantin Belousov||Apr 7, 2012 5:50 am|
|Ian Lepore||Apr 7, 2012 7:46 am|
|Konstantin Belousov||Apr 7, 2012 7:57 am|
|Nathan Whitehorn||Apr 7, 2012 8:04 am|
|Konstantin Belousov||Apr 7, 2012 8:14 am|
|Nathan Whitehorn||Apr 7, 2012 8:48 am|
|Julian Elischer||Apr 7, 2012 2:31 pm|
|Julian Elischer||Apr 7, 2012 2:34 pm|
|Warner Losh||Apr 7, 2012 8:08 pm|
|Warner Losh||Apr 7, 2012 8:10 pm|
|Warner Losh||Apr 7, 2012 8:12 pm|
|Warner Losh||Apr 7, 2012 8:14 pm|
|Konstantin Belousov||Apr 7, 2012 8:58 pm|
|Ian Lepore||Apr 9, 2012 7:07 am|
|Ian Lepore||Apr 9, 2012 7:40 am|
|Konstantin Belousov||Apr 9, 2012 7:58 am|
|John Baldwin||Apr 9, 2012 8:00 am|
|Ian Lepore||Apr 9, 2012 8:41 am|
|Warner Losh||Apr 9, 2012 8:57 am|
|Konstantin Belousov||Apr 9, 2012 12:09 pm|
|John Baldwin||Apr 9, 2012 12:35 pm|
|Konstantin Belousov||Apr 9, 2012 1:05 pm|
|John Baldwin||Apr 10, 2012 6:55 am|
|Konstantin Belousov||Apr 10, 2012 7:38 am|
|John Baldwin||Apr 10, 2012 11:47 am|
|Konstantin Belousov||Apr 10, 2012 11:31 pm|
|Subject:||Re: device_attach(9) and driver initialization|
|From:||Warner Losh (im...@bsdimp.com)|
|Date:||Apr 7, 2012 8:12:43 pm|
On Apr 7, 2012, at 9:04 AM, Nathan Whitehorn wrote:
On 04/07/12 07:50, Konstantin Belousov wrote:
Hello, there seems to be a problem with device attach sequence offered by newbus. Basically, when device attach method is executing, device is not fully initialized yet. Also the device state in the newbus part of the world is DS_ALIVE. There is definitely no shattering news in the statements, but drivers that e.g. create devfs node to communicate with consumers are prone to a race.
If /dev node is created inside device attach method, then usermode can start calling cdevsw methods before device fully initialized itself. Even more, if device tries to use newbus helpers in cdevsw methods, like device_busy(9), then panic occurs "called for unatteched device". I get reports from users about this issues, to it is not something that only could happen.
I propose to add DEVICE_AFTER_ATTACH() driver method, to be called from newbus right after device attach finished and newbus considers the device fully initialized. Driver then could create devfs node in the after_attach method instead of attach. Please see the patch below.
Something like this would also be very useful for drivers that need to interact
across the device tree, if newbus called it only after all drivers have been
attached. Drivers that need to see other potentially attached drivers now need
to do some hacks with SYSINIT. Would it be possible to do this? I don't think it
changes the functionality you need.
Well, there's a problem here. You never know that you've attached everything,
so you could never really call it. Many busses enumerate asynchronously, so it
may be hard to get the semantics that you desire unless the two devices you want
to coordinate are in the static part of the tree.
_______________________________________________ free...@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "free...@freebsd.org"