svn commit: r187978 - user/thompsa/usb/sys/dev/usb2/ethernet

Alfred Perlstein alfred at freebsd.org
Mon Feb 9 22:01:41 PST 2009


* M. Warner Losh <imp at bsdimp.com> [090209 15:03] wrote:
> In message: <20090209223439.GP68801 at elvis.mu.org>
>             Alfred Perlstein <alfred at FreeBSD.org> writes:
> : * M. Warner Losh <imp at bsdimp.com> [090201 21:24] wrote:
> : > In message: <20090202051421.GE43513 at michelle.cdnetworks.co.kr>
> : >             Pyun YongHyeon <pyunyh at gmail.com> writes:
> : > : On Sun, Feb 01, 2009 at 09:52:18PM -0700, M. Warner Losh wrote:
> : > : > In message: <20090202044416.GC43513 at michelle.cdnetworks.co.kr>
> : > : >             Pyun YongHyeon <pyunyh at gmail.com> writes:
> : > : > : On Sun, Feb 01, 2009 at 08:36:18PM -0700, M. Warner Losh wrote:
> : > : > : > In message: <20090201213749.GJ32503 at citylink.fud.org.nz>
> : > : > : >             Andrew Thompson <thompsa at FreeBSD.org> writes:
> : > : > : > : On Sun, Feb 01, 2009 at 02:28:08PM -0700, M. Warner Losh wrote:
> : > : > : > : > In message: <200902010650.n116obU1045871 at svn.freebsd.org>
> : > : > : > : >             Andrew Thompson <thompsa at FreeBSD.org> writes:
> : > : > : > : > : +	locked = mtx_owned(&sc->sc_mtx);
> : > : > : > : > : +	if (!locked)
> : > : > : > : > : +		AUE_LOCK(sc);
> : > : > : > : > 
> : > : > : > : > You do know this is racy, right?
> : > : > : > : 
> : > : > : > : Yea... It only get called unlocked during mii probe+attach so its fine.
> : > : > : > : I havnt actaully checked if its ok to hold a mutex during
> : > : > : > : mii_phy_probe() which would make this go away.
> : > : > : > 
> : > : > : > You hold GIANT when probe+attach, which means I think you can't
> : > : > : 
> : > : > : AFAIK this is not true on USB2 and I think this is reason why
> : > : > : it have to lock/unlock dance in probe/attach.
> : > : > 
> : > : > It is a newbus requirement that all probe/attach routines have to be
> : > : > called with GIANT held.
> : > : > 
> : > : 
> : > : If this can be done on USB2 it would greatly simplify MII attach
> : > : part as well as locks used in MII access routines in all USB2
> : > : ethernet drivers. I vaguely remember I asked for this to HPS, but
> : > : he seem to forget about it.
> : > 
> : > I'll take a look into the matter in more detail.  It is an absolute
> : > requirement of newbus at the moment that any call to
> : > device_probe_and_attach(), including bus_generic_attach().
> : 
> : Can some asserts be added?
> : 
> : Maybe under an additonal ifdef considering usb2 for a short time?
> 
> Are these not sufficient:
> 
> int
> device_probe_child(device_t dev, device_t child)
> {
> 	devclass_t dc;
> 	driverlink_t best = NULL;
> 	driverlink_t dl;
> 	int result, pri = 0;
> 	int hasclass = (child->devclass != NULL);
> 
> 	GIANT_REQUIRED;
> ...

It sounded like usb2 was calling it without Giant...

-- 
- Alfred Perlstein


More information about the svn-src-user mailing list