Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#1984 - Coldplug system not firing all hotplug events during 'early' stage in procd #6871

Closed
openwrt-bot opened this issue Dec 6, 2018 · 2 comments
Labels

Comments

@openwrt-bot
Copy link

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.

@openwrt-bot
Copy link
Author

mkresin:

Please send your very detailed explanation and your patch to the [[https://openwrt.org/contact#mailing_lists|OpenWrt Devel mailing list]].

The bugtracker is the wrong place for discussions or patches. It's quite likely that you get the feedback you are looking for on the mailing list.

@openwrt-bot
Copy link
Author

HattinkT:

Thanks for the response! I'll post it on the mailing list and close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant