From d4f1a76a2e12d4b9f0490e01884f2d2f810fb3a7 Mon Sep 17 00:00:00 2001 From: Val Packett Date: Sun, 20 Sep 2026 03:33:39 -0300 Subject: [PATCH] udev: rules: order ID_BUS assignment by specificity / bus nesting depth Only PCI was treated as a "less specific" bus that should not be assigned if USB was already assigned, so non-PCI USB controllers (under platform/DT or ACPI) would have all their devices *not* treated as USB at all, resulting in external peripherals being treated as internal ones on DT platforms. Clarify these assignments into specificity/nesting groups instead of having some arbitrary "X must be before Y" comments. Fixes a4381cae8bfacb1160967ac499c2919da7ff8c2b. --- rules.d/60-persistent-input.rules | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rules.d/60-persistent-input.rules b/rules.d/60-persistent-input.rules index 7ac43a8074..95037f88c6 100644 --- a/rules.d/60-persistent-input.rules +++ b/rules.d/60-persistent-input.rules @@ -5,20 +5,24 @@ SUBSYSTEM!="input", GOTO="persistent_input_end" SUBSYSTEMS=="bluetooth", ENV{ID_BUS}="bluetooth", GOTO="persistent_input_end" # Bluetooth devices don't always have the bluetooth subsystem ATTRS{id/bustype}=="0005", ENV{ID_BUS}="bluetooth", GOTO="persistent_input_end" -SUBSYSTEMS=="acpi", ENV{ID_BUS}="acpi" -# platform must be before serio as serio can be child -SUBSYSTEMS=="platform", ENV{ID_BUS}="platform" + +# we have to assign the most specific bus, so first check for leaf buses SUBSYSTEMS=="i2c", ENV{ID_BUS}="i2c" SUBSYSTEMS=="rmi4", ENV{ID_BUS}="rmi" SUBSYSTEMS=="serio", ENV{ID_BUS}="i8042" SUBSYSTEMS=="spi", ENV{ID_BUS}="spi" +# then only assign something less specific if ID_BUS was not set yet.. +# usb has middle specificity (e.g. could have an i2c bridge on it, but is under acpi/pci/platform) SUBSYSTEMS=="usb", ENV{ID_BUS}=="", IMPORT{builtin}="usb_id" -# subsystems before (usb, platform, i2c) can be under pci so only set them if we still have no ID_BUS. -# we could set this the first but will break the ENV{ID_BUS}=="" condition for usb. +# pci is usually below acpi/platform SUBSYSTEMS=="pci", ENV{ID_BUS}=="", ENV{ID_BUS}="pci" +# finally, these are the root buses +SUBSYSTEMS=="acpi", ENV{ID_BUS}=="", ENV{ID_BUS}="acpi" +SUBSYSTEMS=="platform", ENV{ID_BUS}=="", ENV{ID_BUS}="platform" + # determine class name for persistent symlinks ENV{ID_INPUT_KEYBOARD}=="?*", ENV{.INPUT_CLASS}="kbd" ENV{ID_INPUT_MOUSE}=="?*", ENV{.INPUT_CLASS}="mouse"