Is there some implicit locking of device methods?

Warner Losh imp at bsdimp.com
Tue Apr 26 14:31:06 UTC 2011


On Apr 26, 2011, at 7:42 AM, John Baldwin wrote:
> - The Giant protection for new-bus should prevent attach/detach from running
>   concurrently I believe (either that or the USB bus itself should ensure
>   that the two instances of your device have seperate device_t instances with
>   separate softc's, so current attach/detach should not matter except that
>   they may both try to talk to the same hardware perhaps?  In that case that
>   is something the USB bus driver should fix by prevent a device from
>   attaching at an existing address until any existing device at that address
>   is fully detached).

I thought that if we held Giant when we're about to go to sleep that we drop it as a special case.  So if any newbus-releated function sleeps, we can have a situation where attach is running and detach gets called.  There is (or was) some code to cope with this in CardBus, iirc.  I'm surprised there isn't any in USB, since Hans was the one that alerted me to this issue.

Warner



More information about the freebsd-hackers mailing list