One new feature in the 2.6.13-RC3 kernel release, is the ability to bind and unbind drivers from devices manually from user space. previusly, the only way to disconnect a driver from a device was usually to unload the whole driver from memory, usingRmmod.
In the sysfs tree, every driver now hasBindAndUnbindFiles associated with it:
$ tree /sys/bus/usb/drivers/ub/ /sys/bus/usb/drivers/ub/ |-- 1-1:1.0 -> ../../../../devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0 |-- bind |-- module -> ../../../../module/ub `-- unbind
In order to unbind a device from a driver, simply write the bus ID of the device to the unbind file:
echo -n "1-1:1.0" > /sys/bus/usb/drivers/ub/unbind
And the device will no longer be bound to the driver:
$ tree /sys/bus/usb/drivers/ub/ /sys/bus/usb/drivers/ub/ |-- bind |-- module -> ../../../../module/ub `-- unbind
To bind a device to a driver, the device must first not be controlled by any other driver. To ensure this, look for the "driver" symlink in the Device directory:
$ tree /sys/bus/usb/devices/1-1:1.0 /sys/bus/usb/devices/1-1:1.0 |-- bAlternateSetting |-- bInterfaceClass |-- bInterfaceNumber |-- bInterfaceProtocol |-- bInterfaceSubClass |-- bNumEndpoints |-- bus -> ../../../../../../bus/usb |-- modalias `-- power `-- state
Then, simply write the bus ID of the device you wish to bind, intoBindFile for that driver:
echo -n "1-1:1.0" > /sys/bus/usb/drivers/usb-storage/bind
And check that the binding was successful:
$ tree /sys/bus/usb/devices/1-1:1.0 /sys/bus/usb/devices/1-1:1.0 |-- bAlternateSetting |-- bInterfaceClass |-- bInterfaceNumber |-- bInterfaceProtocol |-- bInterfaceSubClass |-- bNumEndpoints |-- bus -> ../../../../../../bus/usb |-- driver -> ../../../../../../bus/usb/drivers/usb-storage |-- host2 | `-- power | `-- state |-- modalias `-- power `-- state
As the example above shows, this capability is very useful for switching devices between drivers which handle the same type of device (bothUBAndUSB-storageDrivers handle USB mass storage devices, like flash drives .)
A number of "enterprise" Linux distributions offer multiple drivers of different version levels in their kernel packages. this manual binding feature will allow configuration tools to pick and choose which devices shoshould be bound to which drivers, allowing
Users to upgrade only specific devices if they wish.
In order for a device to bind successfully with a driver, that driver must already support that device. this is why you can not just arbitrarily bind any device to any driver. to help with the issue of adding new devices support to drivers after they are
Built, the PCI system offersDynamic_idFile in sysfs so that user space can write in new device IDs that the driver shocould bind too. in the future, this ability to add new driver IDs to a running kernel will be moved into the driver core to make
It available for all buses.
(Log in to post comments)
Manual driver binding and unbinding
Posted Jul 15,200 5 UTC (Fri)Mdomsch(Subscriber, #5920) [LINK]
Last paragraph, It's not 'dynamic _ id', but shoshould be 'new _ id '.
Manual driver binding and unbinding
Posted Jul 27,200 5 UTC (WED)Markwilliam-son(Guest, #30166) [LINK]
This'll very _ Very _ handy for USB virtualisation under xen-we'll be able
To unbind a device from the "host" kernel and plumb it through the USB
Virtualising driver and into a guest kernel. Great stuff!
Manual driver binding and unbinding
Posted Nov 25,200 5 :26 UTC (Fri)Jik(Guest, #34093) [LINK]
I 've got Fedora Core Development kernel 2.6.14-1.1707 _ fc5smp. I tried the directions here to unbind the usbfs driver from my workshop. after doing so, "lsusb" indeed shows "driver = (none)", but when I look in/sys/bus/USB/devices/1-2:1. 0, the directory
For the specified device, I see that it still has a driver link pointing back at the usbfs driver, and/sys/bus/USB/Drivers/usbfs still has a link pointing at the device. furthermore, I still can't open the secrets from inside VMWare, so it appears that
Unbind didn't completely "take." Any ideas?