You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've made a build for the x86 target running on various embedded Intel or AMD x86 CPU boards. On these boards there are various USB devices connected to the on board USB hubs. Mostly EHCI (2.0) and OHCI/UHCI (1.1) root hubs. To detect these devices I'm using hotplug scripts in /etc/hotplug.d/usb/ that are triggered on ADD and REMOVE events.
I noticed that these triggers are not working during bootup of the openwrt firmware when the USB devices are already connected. Only when the USB devices are connected while the system is running the hotplug events are generated (by the kernel) and the scripts are running and detecting the devices.
Now during the boot of the firmware a coldplug stage is used to trigger hotplug events from devices that are already found during kernel initialisation. This coldplug stage is the 'early' stage in procd. In this stage a tool called udevtrigger (part of the procd package) searches for existing devices in the /sys tree and generates hotplug events where needed by writing into uevent files.
I noticed that not all devices will actually be triggered by udevtrigger, even if they have an uevent file in the /sys tree. And especially various USB devices will not be triggered. When looking into the implementation of udevtrigger I noticed that an extra check is done for each device for the availability of a dev file as well. When this file doesn't exist the uevent is not written. This check is done in line 165 in procd/plug/udevtrigger.c
After removing the check the udevtrigger script triggers all USB devices as well and my hotplug scripts are running for all USB devices found during boot as well.
The presence of the 'uevent' attribute file
does not always mean that a corresponding
device node can be created under '/dev'.
For valid device nodes, a 'dev' attribute
file must be present which cntains the major
and minor numbers of the device.
Modify the code to check the presence of the
dev attribute as well. This allows to avoid
superfluous trigger_uevent calls. On a test
system, the patch reduced the number of the
triegger_uevent calls from 144 to 70.
So it was mostly an optimization to only trigger events for devices that could be instantiated in /dev.
I think this optimization should be reverted and udevtrigger should fire all hotplug events again, otherwise special devices like USB will not work properly in detection scripts.
I've attached a patch that I placed in /openwrt/package/system/procd/patches to fix this situation for me for now. I hope this patch can be applied to procd directly if it is agreed that this fix is necessary.
The text was updated successfully, but these errors were encountered:
HattinkT:
I'm using openwrt version 18.06.01.
I've made a build for the x86 target running on various embedded Intel or AMD x86 CPU boards. On these boards there are various USB devices connected to the on board USB hubs. Mostly EHCI (2.0) and OHCI/UHCI (1.1) root hubs. To detect these devices I'm using hotplug scripts in /etc/hotplug.d/usb/ that are triggered on ADD and REMOVE events.
I noticed that these triggers are not working during bootup of the openwrt firmware when the USB devices are already connected. Only when the USB devices are connected while the system is running the hotplug events are generated (by the kernel) and the scripts are running and detecting the devices.
Now during the boot of the firmware a coldplug stage is used to trigger hotplug events from devices that are already found during kernel initialisation. This coldplug stage is the 'early' stage in procd. In this stage a tool called udevtrigger (part of the procd package) searches for existing devices in the /sys tree and generates hotplug events where needed by writing into uevent files.
I noticed that not all devices will actually be triggered by udevtrigger, even if they have an uevent file in the /sys tree. And especially various USB devices will not be triggered. When looking into the implementation of udevtrigger I noticed that an extra check is done for each device for the availability of a dev file as well. When this file doesn't exist the uevent is not written. This check is done in line 165 in procd/plug/udevtrigger.c
After removing the check the udevtrigger script triggers all USB devices as well and my hotplug scripts are running for all USB devices found during boot as well.
To figure out the reason why this check on dev is added I've looked in the git history and found the following commit e6021a8a in procd: https://git.openwrt.org/?p=project/procd.git;a=commit;h=e6021a8a34e39328ffc867141da03c19da9b2aec
udevtrigger: check presence of dev attribute
The presence of the 'uevent' attribute file
does not always mean that a corresponding
device node can be created under '/dev'.
For valid device nodes, a 'dev' attribute
file must be present which cntains the major
and minor numbers of the device.
Modify the code to check the presence of the
dev attribute as well. This allows to avoid
superfluous trigger_uevent calls. On a test
system, the patch reduced the number of the
triegger_uevent calls from 144 to 70.
Signed-off-by: Gabor Juhos juhosg@openwrt.org
So it was mostly an optimization to only trigger events for devices that could be instantiated in /dev.
I think this optimization should be reverted and udevtrigger should fire all hotplug events again, otherwise special devices like USB will not work properly in detection scripts.
I've attached a patch that I placed in /openwrt/package/system/procd/patches to fix this situation for me for now. I hope this patch can be applied to procd directly if it is agreed that this fix is necessary.
The text was updated successfully, but these errors were encountered: