PERFORCE change 112835 for review

M. Warner Losh imp at bsdimp.com
Sun Jan 14 06:34:16 UTC 2007


In message: <200701140225.05299.hselasky at c2i.net>
            Hans Petter Selasky <hselasky at c2i.net> writes:
: 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.

I understand why mtx can't be held, but there's nothing to contend with...

: 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.

Giant will be locked when attach is called, but not in the deferred
attach.  So long as attach returns, this shouldn't be a problem.

Adding children does need Giant held at the moment.

Warner


More information about the p4-projects mailing list