All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: mlxreg: Fix missing fan LEDs on systems reporting a unit count
@ 2026-10-21 14:28 Felix Radensky
  2026-10-21 14:34 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Radensky @ 2026-10-21 14:28 UTC (permalink / raw)
  To: lee, pavel, linux-leds; +Cc: vadimp, griffin, Felix Radensky

From: Vadim Pasternak <vadimp@nvidia.com>

LED platform data is shared between systems of the same family, and the
driver registers only the LED instances that are actually present on the
running system. The platform data entry names a capability register and
a bit in it, and an entry whose bit is clear is skipped.

The capability registers are a single byte wide, so a bitmap cannot
describe more than eight units, which is not enough for systems with ten
fan drawers. Recent CPLD revisions therefore report a count of the units
present instead of a bitmap, and do so uniformly rather than only where
the bitmap would overflow, leaving no per unit bit to test. Platform
data describes such an entry by its 'slot', the one based index of the
unit the LED belongs to, and leaves 'bit' at zero.

This driver only ever learned the bitmap flavour, so every such entry
fails the presence test: 'regval & 0' is zero and the LED is silently
skipped. All twenty fan LEDs of mlxplat_mlxcpld_xdr_led_data[] are lost
this way, on smart switch systems since the table was introduced, and on
SN5640 and SN5610 since commit 3113bcf4ccf0 ("platform/mellanox: Fix
SN5640/SN5610 LED platform data") moved them onto the same table.
Nothing reports an error, the LEDs simply never appear.

Use a non-zero 'slot' to select the counter interpretation: register the
LED when its slot index does not exceed the value read from the
capability register, and keep the bitmap test for entries that leave
'slot' at zero. The bit clearing that follows the bitmap test applies
only to the bitmap flavour, so move it into that branch.

This mirrors the counter handling that mlxreg-fan already does for the
fan drawer capability register, added by commit 1e11552ee54d ("hwmon:
(mlxreg-fan) Add support for new flavour of capability register").

Fixes: 783259e9b19d ("platform: mellanox: Introduce support of Nvidia smart switch")

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Felix Radensky <fradensky@nvidia.com>
---
Note for the LED maintainers: an upcoming platform driver,
nvsw-host-spc6, describes its per drawer fan LEDs the same way and
depends on this change as well. It is being reviewed separately against
platform-drivers-x86 and needs nothing from this tree, so the two can
be applied independently.

 drivers/leds/leds-mlxreg.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
index 1b70de72376c..e428531f4ac5 100644
--- a/drivers/leds/leds-mlxreg.c
+++ b/drivers/leds/leds-mlxreg.c
@@ -204,14 +204,26 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
 				dev_err(&priv->pdev->dev, "Failed to query capability register\n");
 				return err;
 			}
-			if (!(regval & data->bit))
-				continue;
 			/*
-			 * Field "bit" can contain one capability bit in 0 byte
-			 * and offset bit in 1-3 bytes. Clear capability bit and
-			 * keep only offset bit.
+			 * The capability register reports unit presence either
+			 * as a bitmap, or as a count of the units present when
+			 * platform data assigns a slot number to the LED.
 			 */
-			data->bit &= MLXREG_LED_CAPABILITY_CLEAR;
+			if (data->slot) {
+				if (data->slot > regval)
+					continue;
+			} else {
+				if (!(regval & data->bit))
+					continue;
+				/*
+				 * Byte 0 of "bit" is the capability bit just
+				 * tested, while bytes 1-3 hold the shift that
+				 * positions the LED's nibble within its
+				 * register. Clear the capability bit so that
+				 * only the shift remains.
+				 */
+				data->bit &= MLXREG_LED_CAPABILITY_CLEAR;
+			}
 		}
 
 		led_cdev = &led_data->led_cdev;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] leds: mlxreg: Fix missing fan LEDs on systems reporting a unit count
  2026-10-21 14:28 [PATCH] leds: mlxreg: Fix missing fan LEDs on systems reporting a unit count Felix Radensky
@ 2026-10-21 14:34 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-21 14:34 UTC (permalink / raw)
  To: Felix Radensky, linux-leds; +Cc: lee

> From: Vadim Pasternak <vadimp@nvidia.com>
> 
> LED platform data is shared between systems of the same family, and the
> driver registers only the LED instances that are actually present on the
> running system. The platform data entry names a capability register and
> a bit in it, and an entry whose bit is clear is skipped.
> 
> The capability registers are a single byte wide, so a bitmap cannot
> describe more than eight units, which is not enough for systems with ten
> fan drawers. Recent CPLD revisions therefore report a count of the units
> present instead of a bitmap, and do so uniformly rather than only where
> the bitmap would overflow, leaving no per unit bit to test. Platform
> data describes such an entry by its 'slot', the one based index of the
> unit the LED belongs to, and leaves 'bit' at zero.
> 
> [ ... ]
> 
> Fixes: 783259e9b19d ("platform: mellanox: Introduce support of Nvidia smart switch")
> 
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
> Signed-off-by: Felix Radensky <fradensky@nvidia.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021142824.603605-1-fradensky@nvidia.com?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-21 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 14:28 [PATCH] leds: mlxreg: Fix missing fan LEDs on systems reporting a unit count Felix Radensky
2026-10-21 14:34 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.