2002-09-26 19:26:34

by David Brownell

[permalink] [raw]
Subject: Re: [linux-usb-devel] [RFC] consolidate /sbin/hotplug call for pci and usb

>>>Well, that's a driver unload issue, which I think everyone agrees on the
>>>fact that it's not ok to do automatic driver unload when a device is
>>>removed, because of this very problem.
>>I think it _could_ be fine to do such rmmods, if all the module
>>remove races were removed ... and (for this issue) if the primitve
>>were actually "remove if the driver is not (a) in active use, or
>>(b) bound to any device". Today we have races and (a) ... but it's
>>the lack of (b) that prevents hotplug from even trying to rmmod,
>>on the optimistic assumption there are no races.
> But how do we accomplish (b) for devices that we can't remove from the
> system? Like 99.9% of the pci systems?
> I agree it would be "nice", but probably never realistic :)

There would be two modes for 'rmmod'. One is the "remove if the
kernel can tell it can't be used" (as described above), suitable
for automation. The other gives the rude end-user failure modes:
"remove this module if it's not in active use", which is all we
have today ... a mode suitable only for developers or sysadmins.

Userland needs to make the policy choice, then tell the kernel
whether to ignore any unopened (but bound) devices.

Highly realistic, IMO. It's just a question of ensuring some data
the kernel already holds (N devices are bound to this driver, even
if none are currently opened) is considered by rmmod. I almost put
together a patch for it at one time. There seems to be a change
in maintainer under way, maybe it'd be worth revisiting this.

- Dave