Commit c89c9af9 authored by Vadim Pasternak's avatar Vadim Pasternak Committed by Greg Kroah-Hartman

mlxsw: core: Prevent QSFP module initialization for old hardware

[ Upstream commit c52ecff7 ]

Old Mellanox silicons, like switchx-2, switch-ib do not support reading
QSFP modules temperature through MTMP register. Attempt to access this
register on systems equipped with the this kind of silicon will cause
initialization flow failure.
Test for hardware resource capability is added in order to distinct
between old and new silicon - old silicons do not have such capability.

Fixes: 6a79507c ("mlxsw: core: Extend thermal module with per QSFP module thermal zones")
Fixes: 5c42eaa0 ("mlxsw: core: Extend hwmon interface with QSFP module temperature attributes")
Reported-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2d08f204
...@@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core) ...@@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
} }
EXPORT_SYMBOL(mlxsw_core_driver_priv); EXPORT_SYMBOL(mlxsw_core_driver_priv);
bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core)
{
return mlxsw_core->driver->res_query_enabled;
}
EXPORT_SYMBOL(mlxsw_core_res_query_enabled);
struct mlxsw_rx_listener_item { struct mlxsw_rx_listener_item {
struct list_head list; struct list_head list;
struct mlxsw_rx_listener rxl; struct mlxsw_rx_listener rxl;
......
...@@ -28,6 +28,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core); ...@@ -28,6 +28,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver); int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver); void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
......
...@@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon) ...@@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struct mlxsw_hwmon *mlxsw_hwmon)
u8 width; u8 width;
int err; int err;
if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core))
return 0;
/* Add extra attributes for module temperature. Sensor index is /* Add extra attributes for module temperature. Sensor index is
* assigned to sensor_count value, while all indexed before * assigned to sensor_count value, while all indexed before
* sensor_count are already utilized by the sensors connected through * sensor_count are already utilized by the sensors connected through
......
...@@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, ...@@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
struct mlxsw_thermal_module *module_tz; struct mlxsw_thermal_module *module_tz;
int i, err; int i, err;
if (!mlxsw_core_res_query_enabled(core))
return 0;
thermal->tz_module_arr = kcalloc(module_count, thermal->tz_module_arr = kcalloc(module_count,
sizeof(*thermal->tz_module_arr), sizeof(*thermal->tz_module_arr),
GFP_KERNEL); GFP_KERNEL);
...@@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal) ...@@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal)
unsigned int module_count = mlxsw_core_max_ports(thermal->core); unsigned int module_count = mlxsw_core_max_ports(thermal->core);
int i; int i;
if (!mlxsw_core_res_query_enabled(thermal->core))
return;
for (i = module_count - 1; i >= 0; i--) for (i = module_count - 1; i >= 0; i--)
mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]);
kfree(thermal->tz_module_arr); kfree(thermal->tz_module_arr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment