Skip to content

Commit 8719c20

Browse files
Saeed MahameedBrian Maly
authored andcommitted
net/mlx5: Register a unique thermal zone per device
Prior to this patch only one "mlx5" thermal zone could have been registered regardless of the number of individual mlx5 devices in the system. To fix this setup a unique name per device to register its own thermal zone. In order to not register a thermal zone for a virtual device (VF/SF) add a check for PF device type. The new name is a concatenation between "mlx5_" and "<PCI_DEV_BDF>", which will also help associating a thermal zone with its PCI device. $ lspci | grep ConnectX 00:04.0 Ethernet controller: Mellanox Technologies MT2892 Family [ConnectX-6 Dx] 00:05.0 Ethernet controller: Mellanox Technologies MT2892 Family [ConnectX-6 Dx] $ cat /sys/devices/virtual/thermal/thermal_zone0/type mlx5_0000:00:04.0 $ cat /sys/devices/virtual/thermal/thermal_zone1/type mlx5_0000:00:05.0 Fixes: c1fef61 ("net/mlx5: Implement thermal zone") CC: Sandipan Patra <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Orabug: 35622106 (cherry picked from commit 631079e) cherry-pick-repo=kernel/git/torvalds/linux.git unmodified-from-upstream: 631079e Signed-off-by: Mikhael Goikhman <[email protected]> Signed-off-by: Qing Huang <[email protected]> Reviewed-by: Devesh Sharma <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 124d1ff commit 8719c20

File tree

1 file changed

+12
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+12
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/thermal.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ static struct thermal_zone_device_ops mlx5_thermal_ops = {
6868

6969
int mlx5_thermal_init(struct mlx5_core_dev *mdev)
7070
{
71+
char data[THERMAL_NAME_LENGTH];
7172
struct mlx5_thermal *thermal;
72-
struct thermal_zone_device *tzd;
73-
const char *data = "mlx5";
73+
int err;
7474

75-
tzd = thermal_zone_get_zone_by_name(data);
76-
if (!IS_ERR(tzd))
75+
if (!mlx5_core_is_pf(mdev) && !mlx5_core_is_ecpf(mdev))
7776
return 0;
7877

78+
err = snprintf(data, sizeof(data), "mlx5_%s", dev_name(mdev->device));
79+
if (err < 0 || err >= sizeof(data)) {
80+
mlx5_core_err(mdev, "Failed to setup thermal zone name, %d\n", err);
81+
return -EINVAL;
82+
}
83+
7984
thermal = kzalloc(sizeof(*thermal), GFP_KERNEL);
8085
if (!thermal)
8186
return -ENOMEM;
@@ -89,10 +94,10 @@ int mlx5_thermal_init(struct mlx5_core_dev *mdev)
8994
&mlx5_thermal_ops,
9095
NULL, 0, MLX5_THERMAL_POLL_INT_MSEC);
9196
if (IS_ERR(thermal->tzdev)) {
92-
dev_err(mdev->device, "Failed to register thermal zone device (%s) %ld\n",
93-
data, PTR_ERR(thermal->tzdev));
97+
err = PTR_ERR(thermal->tzdev);
98+
mlx5_core_err(mdev, "Failed to register thermal zone device (%s) %d\n", data, err);
9499
kfree(thermal);
95-
return -EINVAL;
100+
return err;
96101
}
97102

98103
mdev->thermal = thermal;

0 commit comments

Comments
 (0)