svn commit: r296909 - head/sys/ofed/drivers/infiniband/ulp/ipoib

John Baldwin jhb at freebsd.org
Fri Mar 18 18:05:14 UTC 2016


On Wednesday, March 16, 2016 03:37:09 PM Adrian Chadd wrote:
> I've fought this problem in USB drivers. Ideally you'd also have the
> detach path /also/ take said lock and drain anyone currently doing
> anything active (tx, rx, ioctls, net80211 methods, etc) to completion
> before continuing.
> 
> A lot of drivers don't do this very well, or at all.

There isn't a lock to take in detach to hold over drains.  Instead, the
various detach APIs (like if_detach) need to drain internally.  Only the
ifnet layer can keep track of if an ifnet is currently "busy" (any methods
currently executing for example).  You can't do that in the driver.  This is
why bus_teardown_intr() does a drain for example (as well as
callout_drain()).  destroy_dev() also handles this more correctly as it
does a drain (and drivers can even provide a d_purge callback to wakeup any
waiters inside of cdevsw methods during the drain).  if_detach() doesn't do
any drain at all and is broken.  It has to be fixed in the ifnet layer.
Changes in drivers are just band-aids (the current band-aids in this commit
and in other NIC drivers previously only hide witness warnings, they do
nothing to solve the problem of some thread that is already inside of
an if_foo method still running when detach is called, particularly if an
if_foo method can sleep).

-- 
John Baldwin


More information about the svn-src-head mailing list