PERFORCE change 112835 for review

Hans Petter Selasky hselasky at c2i.net
Sun Jan 14 02:25:39 UTC 2007


On Saturday 13 January 2007 20:29, M. Warner Losh wrote:
> In message: <200701122132.l0CLWuAG096027 at repoman.freebsd.org>
>
>             Hans Petter Selasky <hselasky at freebsd.org> writes:
> : http://perforce.freebsd.org/chv.cgi?CH=112835
> :
> : Change 112835 by hselasky at hselasky_mini_itx on 2007/01/12 21:32:24
> :
> :  ether_ifattach() must be called without any mutexes held, hence
> :  it can sleep. Use generated typedef's for prototypes for exported
> :  device methods. This prevents invalid parameter passing and return.
>
> Why do the attach methods even have locked mutexes to drop?  That was
> a common error in the early locking efforts that too many network
> drivers inherited.  Maybe the right fix is to just remove the
> lock/unlock pairs in attach entirely...
>

The attach code in question is run from a separate config thread, which by 
default locks "sc->sc_mtx" before calling the callback function. Therefore 
the code unlocks that lock, to avoid sleeping with mutex locked errors.

Probably all of the attach code can run without "sc->sc_mtx" locked, but will 
require Giant locked, when changing the device tree, for example when adding 
new child devices like MII-bus instances.

--HPS


More information about the p4-projects mailing list