Date: Wed, 6 Dec 2006 11:35:55 -0500 From: John Baldwin <jhb@freebsd.org> To: freebsd-hackers@freebsd.org Cc: Iasen Kostoff <tbyte@otel.net> Subject: Re: Driver not unset properly after kldunload Message-ID: <200612061135.55487.jhb@freebsd.org> In-Reply-To: <1164842336.1066.6.camel@WarHeaD.OTEL.net> References: <1164842336.1066.6.camel@WarHeaD.OTEL.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 29 November 2006 18:18, Iasen Kostoff wrote: > Hi, > It seems that after I load and then unload a driver its name stays > linked to the device e.g: > > nfe0@pci0:10:0: class=0x068000 card=0x81411043 chip=0x005710de rev=0xa3 > hdr=0x00 > > but of course if_nfe is neither compiled in kernel nor is loaded as > module anymore. > I digged around in kernel and saw this in device_detach(): > > if (!(dev->flags & DF_FIXEDCLASS)) > devclass_delete_device(dev->devclass, dev); > > dev->state = DS_NOTPRESENT; > device_set_driver(dev, NULL); > device_set_desc(dev, NULL); > device_sysctl_fini(dev); > > I've put some device_printf()s around and then looked at > devclass_delete_device(). It destroys (frees) a lot of the info about > the device and so the device_printf() prints device name as > "unknown" (NULL). That seems to be a problem for at least > device_set_driver(dev, NULL) - it doesn't unset the driver. I'm not so > sure about the other 2 but I guess it's same there. So when I changed the > order of this funcs everything worked fine (at least it looks like it > worked fine :) I'm not absolutely sure that this won't broke something > else). I've attached a patch for review. I don't see why this patch changes things. devclass_delete_device() only clears dev->unit, dev->devclass, and dev->nameunit. device_set_driver() doesn't check or clear any of those. In fact, your change does make device_set_driver() not work at all since the device state will still be DS_ATTACHED when you call device_set_driver() now. So, I guess your patch actually makes the device _not_ be detached from the driver. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612061135.55487.jhb>