PCI/NPEM: Set LED_HW_PLUGGABLE for hotplug-capable ports
PATCH 1/1 PCI/NPEM: Set LED_HW_PLUGGABLE for hotplug-capable ports
NPEM registers LED classdevs on PCI endpoint that may be behind hotplug-capable ports. During hot-removal, led_classdev_unregister() calls led_set_brightness(LED_OFF) which PCI config on a disconnected device, returning -ENODEV:
``` leds 0003:01:00.0:enclosure:ok: Setting an LED's brightness failed (-19) ```
The LED core already suppresses this for devices with LED_HW_PLUGGABLE set, but NPEM never sets it. Add the flag since NPEM LEDs are on hot-pluggable hardware by nature.
---
The bug was triggered on an ARM64 machine with CPU model Olympus. Kernel version is v6.17.
The PCI topology is
```
$ sudo lspci -tv
-[0001:00]---00.0-[01]--+-00.0 Mellanox Technologies CX8 Family [ConnectX-8]
+-00.1 Mellanox Technologies CX8 Family [ConnectX-8]
+-00.2 Mellanox Technologies CX8 Family [ConnectX-8]
\-00.3 Mellanox Technologies CX8 Family [ConnectX-8]
-[0002:00]---00.0-[01]--
-+-[0003:00]---00.0-[01]----00.0 Montage Technology Co., Ltd. Device c002
\-[0003:80]---00.0-[81]----00.0 Montage Technology Co., Ltd. Device c002
-[0004:00]---00.0-[01]--
-+-[0005:00]---00.0-[01]----00.0 Samsung Electronics Co Ltd Device a810
+-[0005:40]---00.0-[41]----00.0 Samsung Electronics Co Ltd Device a810
+-[0005:c0]---00.0-[c1]----00.0 Intel Corporation I210 Gigabit Network Connection
\-[0005:e0]---00.0-[e1-e2]----00.0-[e2]--+-00.0 ASPEED Technology, Inc. ASPEED Graphics Family
\-02.0 ASPEED Technology, Inc. Device 2603
-+-[0006:00]---00.0-[01]--
\-[0006:80]---00.0-[81]--
```We're targeting on 0003:01:00.0 CXL [0502]: Montage Technology Co., Ltd. Device [1b00:c002] (rev 03). First use sudo setpci -s 0003:00:00.0 0x1f4.w=0x0002 to set UnmaskLinkDisable in CXL DVSEC. Then disable the link with sudo setpci -v -s 0003:00:00.0 CAP_EXP+0x10.b=0x10:0x10
Best regards,
Richard Cheng.
--- drivers/pci/npem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/npem.c +1 -1
@@ -504,7 +504,7 @@ static int pci_npem_set_led_classdev(struct npem *npem, struct npem_led *nled) led->brightness_get = brightness_get; led->max_brightness =1 ; led->default_trigger ="none" ; - led->flags =0 ; + led->flags =LED_HW_PLUGGABLE ; ret =led_classdev_register (&npem->dev->dev, led);if (ret)
Signature · 1 line
2.43.0
Quoted 9 lines · Richard Cheng
NPEM registers LED classdevs on PCI endpoint that may be behind hotplug-capable ports. During hot-removal,
led_classdev_unregister()callsled_set_brightness(LED_OFF)which PCI config on a disconnected device, returning-ENODEV:``` leds 0003:01:00.0:enclosure:ok: Setting an LED's brightness failed (-19) ```
Quoted 7 lines
The LED core already suppresses this for devices with
LED_HW_PLUGGABLEset, but NPEM never sets it. Add the flag since NPEM LEDs are on hot-pluggable hardware by nature.Fixes 4e893545ef87 ("PCI/NPEM: Add Native PCIe Enclosure Management support")Signed-off-by Richard Cheng <[email protected]>Acked-by Kai-Heng Feng <[email protected]>
Bjorn Helgaas
AppliedQuoted 9 lines · Richard Cheng
NPEM registers LED classdevs on PCI endpoint that may be behind hotplug-capable ports. During hot-removal,
led_classdev_unregister()callsled_set_brightness(LED_OFF)which PCI config on a disconnected device, returning-ENODEV:``` leds 0003:01:00.0:enclosure:ok: Setting an LED's brightness failed (-19) ```
Quoted 7 lines
The LED core already suppresses this for devices with
LED_HW_PLUGGABLEset, but NPEM never sets it. Add the flag since NPEM LEDs are on hot-pluggable hardware by nature.Fixes 4e893545ef87 ("PCI/NPEM: Add Native PCIe Enclosure Management support")Signed-off-by Richard Cheng <[email protected]>Acked-by Kai-Heng Feng <[email protected]>
Applied to pci/hotplug for v7.1, thank you!
Quoted 49 lines
---
The bug was triggered on an ARM64 machine with CPU model Olympus. Kernel version is v6.17.
The PCI topology is``` $ sudo lspci -tv -[0001:00]---00.0-[01]--+-00.0 Mellanox Technologies CX8 Family [ConnectX-8] +-00.1 Mellanox Technologies CX8 Family [ConnectX-8] +-00.2 Mellanox Technologies CX8 Family [ConnectX-8] \-00.3 Mellanox Technologies CX8 Family [ConnectX-8] -[0002:00]---00.0-[01]-- -+-[0003:00]---00.0-[01]----00.0 Montage Technology Co., Ltd. Device c002 \-[0003:80]---00.0-[81]----00.0 Montage Technology Co., Ltd. Device c002 -[0004:00]---00.0-[01]-- -+-[0005:00]---00.0-[01]----00.0 Samsung Electronics Co Ltd Device a810 +-[0005:40]---00.0-[41]----00.0 Samsung Electronics Co Ltd Device a810 +-[0005:c0]---00.0-[c1]----00.0 Intel Corporation I210 Gigabit Network Connection \-[0005:e0]---00.0-[e1-e2]----00.0-[e2]--+-00.0 ASPEED Technology, Inc. ASPEED Graphics Family \-02.0 ASPEED Technology, Inc. Device 2603 -+-[0006:00]---00.0-[01]-- \-[0006:80]---00.0-[81]-- ```We're targeting on 0003:01:00.0 CXL [0502]: Montage Technology Co., Ltd. Device [1b00:c002] (rev 03). First use
sudo setpci -s 0003:00:00.0 0x1f4.w=0x0002to set UnmaskLinkDisable in CXL DVSEC. Then disable the link withsudo setpci -v -s 0003:00:00.0 CAP_EXP+0x10.b=0x10:0x10Best regards,
Richard Cheng.--- drivers/pci/npem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/npem.c +1
-1@@ -504,7 +504,7 @@ static int pci_npem_set_led_classdev(struct npem *npem, struct npem_led *nled) led->brightness_get = brightness_get; led->max_brightness =1 ; led->default_trigger ="none" ; - led->flags =0 ; + led->flags =LED_HW_PLUGGABLE ; ret =led_classdev_register (&npem->dev->dev, led);if (ret)Signature · 1 line
2.43.0