OpenWrt/LEDE Project

  • Status Closed
  • Percent Complete
    100%
  • Task Type Bug Report
  • Category Base system
  • Assigned To No-one
  • Operating System All
  • Severity Low
  • Priority Very Low
  • Reported Version openwrt-18.06
  • Due in Version Undecided
  • Due Date Undecided
  • Votes 1
  • Private
Attached to Project: OpenWrt/LEDE Project
Opened by Tjalling Hattink - 06.12.2018
Last edited by Mathias Kresin - 07.12.2018

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

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.

Closed by  Mathias Kresin
07.12.2018 08:47
Reason for closing:  Invalid report
Project Manager
Mathias Kresin commented on 06.12.2018 20:29

Please send your very detailed explanation and your patch to the 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.

Tjalling Hattink commented on 07.12.2018 08:41

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

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing