|
| 1 | +From 3d4e440640d63c5bc599a4ad6802ad84dcd0c329 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Vadim Pasternak < [email protected]> |
| 3 | +Date: Wed, 10 Jul 2019 17:47:56 +0000 |
| 4 | +Subject: [PATCH v1 backport] mlxsw: core: Skip port split entries in hwmon |
| 5 | + subsystem |
| 6 | + |
| 7 | +Skip split entries in hwmon. |
| 8 | +Run loop for port creation over maximum port counter, otherwise |
| 9 | +in some split configuration with holes, some last modules can be |
| 10 | +missed. |
| 11 | + |
| 12 | +Signed-of-by: Vadim Pasternak < [email protected]> |
| 13 | +--- |
| 14 | + drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 7 ++++++- |
| 15 | + drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 2 +- |
| 16 | + drivers/net/ethernet/mellanox/mlxsw/minimal.c | 5 +++-- |
| 17 | + 3 files changed, 10 insertions(+), 4 deletions(-) |
| 18 | + |
| 19 | +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c |
| 20 | +index a414a09efb5d..95b890298952 100644 |
| 21 | +--- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c |
| 22 | ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c |
| 23 | +@@ -512,9 +512,9 @@ static int mlxsw_hwmon_fans_init(struct mlxsw_hwmon *mlxsw_hwmon) |
| 24 | + static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) |
| 25 | + { |
| 26 | + unsigned int module_count = mlxsw_core_max_ports(mlxsw_hwmon->core); |
| 27 | ++ u8 width, module, last_module = module_count; |
| 28 | + char pmlp_pl[MLXSW_REG_PMLP_LEN] = {0}; |
| 29 | + int i, index; |
| 30 | +- u8 width; |
| 31 | + int err; |
| 32 | + |
| 33 | + if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core)) |
| 34 | +@@ -538,6 +538,11 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) |
| 35 | + width = mlxsw_reg_pmlp_width_get(pmlp_pl); |
| 36 | + if (!width) |
| 37 | + continue; |
| 38 | ++ module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0); |
| 39 | ++ /* Skip, if port belongs to the cluster */ |
| 40 | ++ if (module == last_module) |
| 41 | ++ continue; |
| 42 | ++ last_module = module; |
| 43 | + mlxsw_hwmon_attr_add(mlxsw_hwmon, |
| 44 | + MLXSW_HWMON_ATTR_TYPE_TEMP_MODULE, index, |
| 45 | + index); |
| 46 | +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c |
| 47 | +index 499c82cea1cb..e9451e447bf0 100644 |
| 48 | +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c |
| 49 | ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c |
| 50 | +@@ -906,7 +906,7 @@ mlxsw_thermal_gearboxes_fini(struct mlxsw_thermal *thermal) |
| 51 | + int i; |
| 52 | + |
| 53 | + for (i = thermal->tz_gearbox_num - 1; i >= 0; i--) |
| 54 | +- mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); /*Remove*/ |
| 55 | ++ mlxsw_thermal_gearbox_tz_fini(&thermal->tz_gearbox_arr[i]); |
| 56 | + kfree(thermal->tz_gearbox_arr); |
| 57 | + } |
| 58 | + |
| 59 | +diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c |
| 60 | +index 5290993ff93f..0aa3abc974ff 100644 |
| 61 | +--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c |
| 62 | ++++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c |
| 63 | +@@ -264,7 +264,7 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m) |
| 64 | + } |
| 65 | + |
| 66 | + /* Create port objects for each valid entry */ |
| 67 | +- for (i = 0; i < mlxsw_m->max_ports; i++) { |
| 68 | ++ for (i = 0; i < max_ports; i++) { |
| 69 | + if (mlxsw_m->module_to_port[i] > 0) { |
| 70 | + err = mlxsw_m_port_create(mlxsw_m, |
| 71 | + mlxsw_m->module_to_port[i], |
| 72 | +@@ -294,9 +294,10 @@ static int mlxsw_m_ports_create(struct mlxsw_m *mlxsw_m) |
| 73 | + |
| 74 | + static void mlxsw_m_ports_remove(struct mlxsw_m *mlxsw_m) |
| 75 | + { |
| 76 | ++ unsigned int max_ports = mlxsw_core_max_ports(mlxsw_m->core); |
| 77 | + int i; |
| 78 | + |
| 79 | +- for (i = 0; i < mlxsw_m->max_ports; i++) { |
| 80 | ++ for (i = 0; i < max_ports; i++) { |
| 81 | + if (mlxsw_m->module_to_port[i] > 0) { |
| 82 | + mlxsw_m_port_remove(mlxsw_m, |
| 83 | + mlxsw_m->module_to_port[i]); |
| 84 | +-- |
| 85 | +2.11.0 |
| 86 | + |
0 commit comments