Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 May 2010 23:07:03 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        mav@FreeBSD.org
Cc:        freebsd-arch@FreeBSD.org
Subject:   Re: Device driver unload
Message-ID:  <20100521.230703.1076064300569247858.imp@bsdimp.com>
In-Reply-To: <4BF751DD.7020701@FreeBSD.org>
References:  <4BF751DD.7020701@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <4BF751DD.7020701@FreeBSD.org>
            Alexander Motin <mav@freebsd.org> writes:
: Hi.
: 
: I think we have some inconsistency around device driver unloading. When
: devices gets no driver during boot, bus driver receives
: BUS_PROBE_NOMATCH() call, allowing to power-down the device. But if
: device looses driver after module unload - nothing happens.

Correct.

: So my question is: shouldn't we call either device_probe_and_attach() or
: BUS_PROBE_NOMATCH() for devices detached due to driver unload?

I don't think so.  We're not really setup to do that.  If we were to
do that, then reloading the old driver would break since the new,
alternative driver wouldn't detach when we kldload the new one.  This
is an important case to keep working, even if there might be some
slight benefit to your proposed change.  There's some infrastructure
to do this already, in the DF_REBID stuff I did a while ago.
Alternatively, we'll need to fix the so-called '/dev/foot' patches to
give direct control.

BUS_PROBE_NOMATCH likely isn't a bad choice to call on detach,
however.  Oh, and we'll need to unset DF_NOMATCH on attach.  At least
I think that's the right place...

: If there
: is no alternative driver - device_probe_and_attach() also result in
: BUS_PROBE_NOMATCH() call.

Sounds good in theory.  However, there's problems with this.  We'll
need to make a list of devices that are detached, and then call
device_probe_and_attach() after we've completely unwound the module
unload.  There may be other issues here as well.  I've not thought
through the consequences of doing this with multiple module unloads.

So, in short, we could do something like this, but we must do it very
carefully.  There's a lot of interrelated junk here, and I don't want
to break useful cases that work today...

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100521.230703.1076064300569247858.imp>