* [PATCH net] Revert "net/mlx5: Add sensor name to temperature event message"
@ 2026-08-28 4:55 Ben Cressey
2026-08-29 6:24 ` Will Mortensen
2026-09-01 10:18 ` Leon Romanovsky
0 siblings, 2 replies; 3+ messages in thread
From: Ben Cressey @ 2026-08-28 4:55 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Shahar Shitrit, Carolina Jubran, Simon Horman
Cc: netdev, linux-rdma, linux-kernel, stable, Will Mortensen,
Jose Fernandez (Anthropic), Ben Cressey
This reverts commit 46fd50cfcc12368bed9ae5257cc3beaea5b3c193.
print_sensor_names_in_bit_set() passes the sensor index from the
temperature warning event to hwmon_get_sensor_name(), which uses it
as an index into temp_channel_desc[]. That array is indexed by hwmon
channel, not by sensor index: it has one entry per ASIC or platform
sensor the device reports, plus at most one module sensor
(module_scount is 0 or 1). Module sensors have index 64 and up, so a
module temperature warning reads far past the end of the allocation
and prints whatever memory follows it, up to the next NUL byte, into
the log.
The mapping from sensor index to hwmon channel cannot be made
reliable here: the driver registers at most one module channel, while
the event can carry bits for other ports' modules, and the bitmap in
the existing warning already distinguishes the ASIC sensor (bit 0)
from module sensors (bit 64 and up). Drop the name lookup rather than
fix the mapping, as suggested in review of an earlier fix [1].
Fixes: 46fd50cfcc12 ("net/mlx5: Add sensor name to temperature event message")
Cc: stable@vger.kernel.org
Suggested-by: Leon Romanovsky <leon@kernel.org>
Link: https://lore.kernel.org/netdev/20260518112555.GM33515@unreal/
Reported-by: Will Mortensen <will@extrahop.com>
Closes: https://lore.kernel.org/netdev/20260512-b4-mlx5-sensor-fix-v2-1-531fee4fd7fd@extrahop.com/
Link: https://lore.kernel.org/netdev/20260515-b4-mlx5-sensor-fix-v3-1-f537ce191d6c@extrahop.com/ [1]
Assisted-by: LLM
Reviewed-by: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
The restored warning string intentionally lacks the trailing period
and newline: this is a pure revert of 46fd50cfcc12, the commit that
added them.
Will - happy for you to carry this as v4 if you'd prefer.
---
drivers/net/ethernet/mellanox/mlx5/core/events.c | 31 +++---------------------
drivers/net/ethernet/mellanox/mlx5/core/hwmon.c | 5 ----
drivers/net/ethernet/mellanox/mlx5/core/hwmon.h | 1 -
3 files changed, 3 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/events.c b/drivers/net/ethernet/mellanox/mlx5/core/events.c
index 4d7f35b968761..a5d4586edf435 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/events.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/events.c
@@ -6,7 +6,6 @@
#include "mlx5_core.h"
#include "lib/eq.h"
#include "lib/events.h"
-#include "hwmon.h"
struct mlx5_event_nb {
struct mlx5_nb nb;
@@ -154,28 +153,11 @@ static int any_notifier(struct notifier_block *nb,
return NOTIFY_OK;
}
-#if IS_ENABLED(CONFIG_HWMON)
-static void print_sensor_names_in_bit_set(struct mlx5_core_dev *dev, struct mlx5_hwmon *hwmon,
- u64 bit_set, int bit_set_offset)
-{
- unsigned long *bit_set_ptr = (unsigned long *)&bit_set;
- int num_bits = sizeof(bit_set) * BITS_PER_BYTE;
- int i;
-
- for_each_set_bit(i, bit_set_ptr, num_bits) {
- const char *sensor_name = hwmon_get_sensor_name(hwmon, i + bit_set_offset);
-
- mlx5_core_warn(dev, "Sensor name[%d]: %s\n", i + bit_set_offset, sensor_name);
- }
-}
-#endif /* CONFIG_HWMON */
-
/* type == MLX5_EVENT_TYPE_TEMP_WARN_EVENT */
static int temp_warn(struct notifier_block *nb, unsigned long type, void *data)
{
struct mlx5_event_nb *event_nb = mlx5_nb_cof(nb, struct mlx5_event_nb, nb);
struct mlx5_events *events = event_nb->ctx;
- struct mlx5_core_dev *dev = events->dev;
struct mlx5_eqe *eqe = data;
u64 value_lsb;
u64 value_msb;
@@ -187,17 +169,10 @@ static int temp_warn(struct notifier_block *nb, unsigned long type, void *data)
value_lsb &= 0x1;
value_msb = be64_to_cpu(eqe->data.temp_warning.sensor_warning_msb);
- if (net_ratelimit()) {
- mlx5_core_warn(dev, "High temperature on sensors with bit set %#llx %#llx.\n",
+ if (net_ratelimit())
+ mlx5_core_warn(events->dev,
+ "High temperature on sensors with bit set %#llx %#llx",
value_msb, value_lsb);
-#if IS_ENABLED(CONFIG_HWMON)
- if (dev->hwmon) {
- print_sensor_names_in_bit_set(dev, dev->hwmon, value_lsb, 0);
- print_sensor_names_in_bit_set(dev, dev->hwmon, value_msb,
- sizeof(value_lsb) * BITS_PER_BYTE);
- }
-#endif
- }
return NOTIFY_OK;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/hwmon.c b/drivers/net/ethernet/mellanox/mlx5/core/hwmon.c
index afcdebac9c4fd..bf36c1c9bf781 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/hwmon.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/hwmon.c
@@ -416,8 +416,3 @@ void mlx5_hwmon_dev_unregister(struct mlx5_core_dev *mdev)
mlx5_hwmon_free(hwmon);
mdev->hwmon = NULL;
}
-
-const char *hwmon_get_sensor_name(struct mlx5_hwmon *hwmon, int channel)
-{
- return hwmon->temp_channel_desc[channel].sensor_name;
-}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/hwmon.h b/drivers/net/ethernet/mellanox/mlx5/core/hwmon.h
index f38271c22c105..999654a9b9da5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/hwmon.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/hwmon.h
@@ -10,7 +10,6 @@
int mlx5_hwmon_dev_register(struct mlx5_core_dev *mdev);
void mlx5_hwmon_dev_unregister(struct mlx5_core_dev *mdev);
-const char *hwmon_get_sensor_name(struct mlx5_hwmon *hwmon, int channel);
#else
static inline int mlx5_hwmon_dev_register(struct mlx5_core_dev *mdev)
---
base-commit: 4e15e89faac9f308baeb01f46c13a051814d2449
change-id: 20260828-b4-mlx5-temp-warn-revert-9d28daaaeb6f
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] Revert "net/mlx5: Add sensor name to temperature event message"
2026-08-28 4:55 [PATCH net] Revert "net/mlx5: Add sensor name to temperature event message" Ben Cressey
@ 2026-08-29 6:24 ` Will Mortensen
2026-09-01 10:18 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Will Mortensen @ 2026-08-29 6:24 UTC (permalink / raw)
To: Ben Cressey
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Shahar Shitrit, Carolina Jubran, Simon Horman,
netdev, linux-rdma, linux-kernel, stable,
Jose Fernandez (Anthropic)
On Thu, Aug 27, 2026 at 9:56 PM Ben Cressey <ben@cressey.dev> wrote:
> print_sensor_names_in_bit_set() passes the sensor index from the
> temperature warning event to hwmon_get_sensor_name(), which uses it
> as an index into temp_channel_desc[]. That array is indexed by hwmon
> channel, not by sensor index: it has one entry per ASIC or platform
> sensor the device reports, plus at most one module sensor
> (module_scount is 0 or 1). Module sensors have index 64 and up, so a
> module temperature warning reads far past the end of the allocation
> and prints whatever memory follows it, up to the next NUL byte, into
> the log.
>
> The mapping from sensor index to hwmon channel cannot be made
> reliable here: the driver registers at most one module channel, while
> the event can carry bits for other ports' modules, and the bitmap in
> the existing warning already distinguishes the ASIC sensor (bit 0)
> from module sensors (bit 64 and up). Drop the name lookup rather than
> fix the mapping, as suggested in review of an earlier fix [1].
I don't know about "cannot be made reliable here", since my patch
hopefully did make the warning reliable (although it didn't fix other
fragile assumptions about sensors in hwmon.c, which aren't fixed by
reverting either).
Anyway, thanks for picking this up and sorry for dropping it on the floor. :-)
Reviewed-by: Will Mortensen <will@extrahop.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] Revert "net/mlx5: Add sensor name to temperature event message"
2026-08-28 4:55 [PATCH net] Revert "net/mlx5: Add sensor name to temperature event message" Ben Cressey
2026-08-29 6:24 ` Will Mortensen
@ 2026-09-01 10:18 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2026-09-01 10:18 UTC (permalink / raw)
To: Ben Cressey
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shahar Shitrit, Carolina Jubran, Simon Horman, netdev, linux-rdma,
linux-kernel, stable, Will Mortensen, Jose Fernandez (Anthropic)
On Fri, Aug 28, 2026 at 04:55:52AM +0000, Ben Cressey wrote:
> This reverts commit 46fd50cfcc12368bed9ae5257cc3beaea5b3c193.
>
> print_sensor_names_in_bit_set() passes the sensor index from the
> temperature warning event to hwmon_get_sensor_name(), which uses it
> as an index into temp_channel_desc[]. That array is indexed by hwmon
> channel, not by sensor index: it has one entry per ASIC or platform
> sensor the device reports, plus at most one module sensor
> (module_scount is 0 or 1). Module sensors have index 64 and up, so a
> module temperature warning reads far past the end of the allocation
> and prints whatever memory follows it, up to the next NUL byte, into
> the log.
>
> The mapping from sensor index to hwmon channel cannot be made
> reliable here: the driver registers at most one module channel, while
> the event can carry bits for other ports' modules, and the bitmap in
> the existing warning already distinguishes the ASIC sensor (bit 0)
> from module sensors (bit 64 and up). Drop the name lookup rather than
> fix the mapping, as suggested in review of an earlier fix [1].
>
> Fixes: 46fd50cfcc12 ("net/mlx5: Add sensor name to temperature event message")
> Cc: stable@vger.kernel.org
> Suggested-by: Leon Romanovsky <leon@kernel.org>
> Link: https://lore.kernel.org/netdev/20260518112555.GM33515@unreal/
> Reported-by: Will Mortensen <will@extrahop.com>
> Closes: https://lore.kernel.org/netdev/20260512-b4-mlx5-sensor-fix-v2-1-531fee4fd7fd@extrahop.com/
> Link: https://lore.kernel.org/netdev/20260515-b4-mlx5-sensor-fix-v3-1-f537ce191d6c@extrahop.com/ [1]
> Assisted-by: LLM
> Reviewed-by: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
> The restored warning string intentionally lacks the trailing period
> and newline: this is a pure revert of 46fd50cfcc12, the commit that
> added them.
>
> Will - happy for you to carry this as v4 if you'd prefer.
> ---
> drivers/net/ethernet/mellanox/mlx5/core/events.c | 31 +++---------------------
> drivers/net/ethernet/mellanox/mlx5/core/hwmon.c | 5 ----
> drivers/net/ethernet/mellanox/mlx5/core/hwmon.h | 1 -
> 3 files changed, 3 insertions(+), 34 deletions(-)
>
Thanks,
Acked-by: Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-01 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28 4:55 [PATCH net] Revert "net/mlx5: Add sensor name to temperature event message" Ben Cressey
2026-08-29 6:24 ` Will Mortensen
2026-09-01 10:18 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox