[PATCH net] Revert "net/mlx5: Add sensor name to temperature event message"
From: Ben Cressey
Date: Fri Aug 28 2026 - 01:03:34 EST
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@xxxxxxxxxxxxxxx
Suggested-by: Leon Romanovsky <leon@xxxxxxxxxx>
Link: https://lore.kernel.org/netdev/20260518112555.GM33515@unreal/
Reported-by: Will Mortensen <will@xxxxxxxxxxxx>
Closes: https://lore.kernel.org/netdev/20260512-b4-mlx5-sensor-fix-v2-1-531fee4fd7fd@xxxxxxxxxxxx/
Link: https://lore.kernel.org/netdev/20260515-b4-mlx5-sensor-fix-v3-1-f537ce191d6c@xxxxxxxxxxxx/ [1]
Assisted-by: LLM
Reviewed-by: Jose Fernandez (Anthropic) <jose.fernandez@xxxxxxxxx>
Signed-off-by: Ben Cressey <ben@xxxxxxxxxxx>
---
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