Skip to contentSkip to conversation

Question about USB hotplug

DISCUSSION Simon Guo 2 participants 4 messages Jun 14, 2014 – Jun 16, 2014

lore
Share & tools
lore

Simon Guo

author
#0 lore raw

Hi, dear list,

I want to be clear about the USB hotplug procedure.

I read "Linux Device Driver" and "Documentation/usb/hotplug.txt", and google much. Per my understanding, the USB hotplug works as following:
1) Insertion of physical U-disk will trigger a hardware interrupt. And interrupt handler (installed by USB bus driver?) will create kobj at /sys.
2) According to Linux device model, the creation of kobj will raise hotplug event (implemented in USB bus driver).
3) user space hotplug helper is invoked to handle hotplug event. Hotplug helper will read "modules.usbmaps" and decide to load which USB driver. If there are many drivers matching the device, they will all be loaded?
4) udev will create approparite dev under /dev according to rules defined. Please correct me if I am wrong in the above.

I am using Ubuntu 11, and with my own build kernel version 3.15.0. Currently a new plugged USB disk can be recognized by my Ubuntu. But I didn't see "modules.usbmaps" file under /lib/modules/uname -r root at thunderCat:/mnt/data# ls /lib/modules/uname -r
build modules.alias modules.builtin modules.dep
modules.devname modules.softdep modules.symbols.bin kernel modules.alias.bin modules.builtin.bin modules.dep.bin
modules.order modules.symbols source

And there is no /proc/sys/kernel/hotplug
root at thunderCat:/mnt/data# cat /proc/sys/kernel/hotplug

root at thunderCat:/mnt/data# file /sbin/hotplug /sbin/hotplug: ERROR: cannot open `/sbin/hotplug' (No such file or directory)

My Question is:
1) How can my Ubuntu hotplug work without "modules.usbmaps" and "/sbin/hotplug"?
2) Is there any tech I can use to "trace" the kernel/driver behavior of the USB hotplug procedure? (for example, kernel functions traversed)

Thanks,
Simon

The config should have enabled HOTPLUG:

root at thunderCat:/mnt/data# grep CONFIG_HOTPLUG /boot/config-uname -r CONFIG_HOTPLUG_CPU=y
CONFIG_HOTPLUG_PCI_PCIE=y
CONFIG_HOTPLUG_PCI=y
# CONFIG_HOTPLUG_PCI_COMPAQ is not set
# CONFIG_HOTPLUG_PCI_IBM is not set
# CONFIG_HOTPLUG_PCI_ACPI is not set CONFIG_HOTPLUG_PCI_CPCI=y
# CONFIG_HOTPLUG_PCI_CPCI_ZT5550 is not set
# CONFIG_HOTPLUG_PCI_CPCI_GENERIC is not set
# CONFIG_HOTPLUG_PCI_SHPC is not set

author
#1 lore raw

Forward to USB mail alias for the USB question.

-------- Original post --------
Subject: Question about USB hotplug
Date: Sat, 14 Jun 2014 09:59:45 +0800
Sender: Simon Guo <[email protected]>
Receiver: kernelnewbies at kernelnewbies.org, wei.guo.simon at gmail.com

Hi, dear list,

I want to be clear about the USB hotplug procedure.

I read "Linux Device Driver" and "Documentation/usb/hotplug.txt", and google much. Per my understanding, the USB hotplug works as following:
1) Insertion of physical U-disk will trigger a hardware interrupt. And interrupt handler (installed by USB bus driver?) will create kobj at /sys.
2) According to Linux device model, the creation of kobj will raise hotplug event (implemented in USB bus driver).
3) user space hotplug helper is invoked to handle hotplug event. Hotplug helper will read "modules.usbmaps" and decide to load which USB driver. If there are many drivers matching the device, they will all be loaded?
4) udev will create approparite dev under /dev according to rules defined. Please correct me if I am wrong in the above.

I am using Ubuntu 11, and with my own build kernel version 3.15.0. Currently a new plugged USB disk can be recognized by my Ubuntu. But I didn't see "modules.usbmaps" file under /lib/modules/uname -r root at thunderCat:/mnt/data# ls /lib/modules/uname -r
build modules.alias modules.builtin modules.dep
modules.devname modules.softdep modules.symbols.bin kernel modules.alias.bin modules.builtin.bin modules.dep.bin
modules.order modules.symbols source

And there is no /proc/sys/kernel/hotplug
root at thunderCat:/mnt/data# cat /proc/sys/kernel/hotplug

root at thunderCat:/mnt/data# file /sbin/hotplug /sbin/hotplug: ERROR: cannot open `/sbin/hotplug' (No such file or directory)

My Question is:
1) How can my Ubuntu hotplug work without "modules.usbmaps" and "/sbin/hotplug"?
2) Is there any tech I can use to "trace" the kernel/driver behavior of the USB hotplug procedure? (for example, kernel functions traversed)

Thanks,
Simon

The config should have enabled HOTPLUG:

root at thunderCat:/mnt/data# grep CONFIG_HOTPLUG /boot/config-uname -r CONFIG_HOTPLUG_CPU=y
CONFIG_HOTPLUG_PCI_PCIE=y
CONFIG_HOTPLUG_PCI=y
# CONFIG_HOTPLUG_PCI_COMPAQ is not set
# CONFIG_HOTPLUG_PCI_IBM is not set
# CONFIG_HOTPLUG_PCI_ACPI is not set CONFIG_HOTPLUG_PCI_CPCI=y
# CONFIG_HOTPLUG_PCI_CPCI_ZT5550 is not set
# CONFIG_HOTPLUG_PCI_CPCI_GENERIC is not set
# CONFIG_HOTPLUG_PCI_SHPC is not set

#2 lore raw
Quoted 24 lines · Simon Guo

Forward to USB mail alias for the USB question.

-------- Original post --------
Subject: Question about USB hotplug
Date: Sat, 14 Jun 2014 09:59:45 +0800
Sender: Simon Guo <[email protected]>
Receiver: kernelnewbies at kernelnewbies.org, wei.guo.simon at gmail.com

Hi, dear list,

I want to be clear about the USB hotplug procedure.

I read "Linux Device Driver" and "Documentation/usb/hotplug.txt", and google much. Per my understanding, the USB hotplug works as following:
1) Insertion of physical U-disk will trigger a hardware interrupt. And interrupt handler (installed by USB bus driver?) will create kobj at /sys.
2) According to Linux device model, the creation of kobj will raise hotplug event (implemented in USB bus driver).
3) user space hotplug helper is invoked to handle hotplug event. Hotplug helper will read "modules.usbmaps" and decide to load which USB driver. If there are many drivers matching the device, they will all be loaded?
4) udev will create approparite dev under /dev according to rules defined. Please correct me if I am wrong in the above.

Quoted 1 line

I am using Ubuntu 11, and with my own build kernel version 3.15.0.

Please ask on a Ubuntu mailing list, they are the only distro that people have problems with this, so they must be doing something "odd" compared to everyone else.

sorry,

greg k-h

author
#3 lore raw
Quoted 25 lines · Greg KH
Quoted 24 lines · Simon Guo

Forward to USB mail alias for the USB question.

-------- Original post --------
Subject: Question about USB hotplug
Date: Sat, 14 Jun 2014 09:59:45 +0800
Sender: Simon Guo <[email protected]>
Receiver: kernelnewbies at kernelnewbies.org, wei.guo.simon at gmail.com

Hi, dear list,

I want to be clear about the USB hotplug procedure.

I read "Linux Device Driver" and "Documentation/usb/hotplug.txt", and google much. Per my understanding, the USB hotplug works as following:
1) Insertion of physical U-disk will trigger a hardware interrupt. And interrupt handler (installed by USB bus driver?) will create kobj at /sys.
2) According to Linux device model, the creation of kobj will raise hotplug event (implemented in USB bus driver).
3) user space hotplug helper is invoked to handle hotplug event. Hotplug helper will read "modules.usbmaps" and decide to load which USB driver. If there are many drivers matching the device, they will all be loaded?
4) udev will create approparite dev under /dev according to rules defined. Please correct me if I am wrong in the above.

Quoted 6 lines
Quoted 1 line

I am using Ubuntu 11, and with my own build kernel version 3.15.0.

Please ask on a Ubuntu mailing list, they are the only distro that people have problems with this, so they must be doing something "odd" compared to everyone else.

Thanks Greg. The feedback from Ubuntu list indicates udev(which was developed by you) is used to handle hotplug, and the procedure I listed was out-of-date.

Whereas "Documentation/usb/hotplug.txt" doesn't mention udev at all.

BR,
Simon