Commit c7fce569 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-Various-fixes'

Ido Schimmel says:

====================
mlxsw: Various fixes

Patch #1 fixes the recently introduced QSFP thermal zones to correctly
work with split ports, where several ports are mapped to the same
module.

Patch #2 initializes the base MAC in the minimal driver. The driver is
using the base MAC as its parent ID and without initializing it, it is
reported as all zeroes to user space.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4ec850e5 426aa1fc
...@@ -111,7 +111,6 @@ struct mlxsw_thermal { ...@@ -111,7 +111,6 @@ struct mlxsw_thermal {
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS]; struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
enum thermal_device_mode mode; enum thermal_device_mode mode;
struct mlxsw_thermal_module *tz_module_arr; struct mlxsw_thermal_module *tz_module_arr;
unsigned int tz_module_num;
}; };
static inline u8 mlxsw_state_to_duty(int state) static inline u8 mlxsw_state_to_duty(int state)
...@@ -711,6 +710,9 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core, ...@@ -711,6 +710,9 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0); module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
module_tz = &thermal->tz_module_arr[module]; module_tz = &thermal->tz_module_arr[module];
/* Skip if parent is already set (case of port split). */
if (module_tz->parent)
return 0;
module_tz->module = module; module_tz->module = module;
module_tz->parent = thermal; module_tz->parent = thermal;
memcpy(module_tz->trips, default_thermal_trips, memcpy(module_tz->trips, default_thermal_trips,
...@@ -718,13 +720,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core, ...@@ -718,13 +720,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
/* Initialize all trip point. */ /* Initialize all trip point. */
mlxsw_thermal_module_trips_reset(module_tz); mlxsw_thermal_module_trips_reset(module_tz);
/* Update trip point according to the module data. */ /* Update trip point according to the module data. */
err = mlxsw_thermal_module_trips_update(dev, core, module_tz); return mlxsw_thermal_module_trips_update(dev, core, module_tz);
if (err)
return err;
thermal->tz_module_num++;
return 0;
} }
static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz) static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
...@@ -732,6 +728,7 @@ static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz) ...@@ -732,6 +728,7 @@ static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
if (module_tz && module_tz->tzdev) { if (module_tz && module_tz->tzdev) {
mlxsw_thermal_module_tz_fini(module_tz->tzdev); mlxsw_thermal_module_tz_fini(module_tz->tzdev);
module_tz->tzdev = NULL; module_tz->tzdev = NULL;
module_tz->parent = NULL;
} }
} }
...@@ -740,6 +737,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, ...@@ -740,6 +737,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
struct mlxsw_thermal *thermal) struct mlxsw_thermal *thermal)
{ {
unsigned int module_count = mlxsw_core_max_ports(core); unsigned int module_count = mlxsw_core_max_ports(core);
struct mlxsw_thermal_module *module_tz;
int i, err; int i, err;
thermal->tz_module_arr = kcalloc(module_count, thermal->tz_module_arr = kcalloc(module_count,
...@@ -754,8 +752,11 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core, ...@@ -754,8 +752,11 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
goto err_unreg_tz_module_arr; goto err_unreg_tz_module_arr;
} }
for (i = 0; i < thermal->tz_module_num; i++) { for (i = 0; i < module_count - 1; i++) {
err = mlxsw_thermal_module_tz_init(&thermal->tz_module_arr[i]); module_tz = &thermal->tz_module_arr[i];
if (!module_tz->parent)
continue;
err = mlxsw_thermal_module_tz_init(module_tz);
if (err) if (err)
goto err_unreg_tz_module_arr; goto err_unreg_tz_module_arr;
} }
......
...@@ -34,6 +34,18 @@ struct mlxsw_m_port { ...@@ -34,6 +34,18 @@ struct mlxsw_m_port {
u8 module; u8 module;
}; };
static int mlxsw_m_base_mac_get(struct mlxsw_m *mlxsw_m)
{
char spad_pl[MLXSW_REG_SPAD_LEN] = {0};
int err;
err = mlxsw_reg_query(mlxsw_m->core, MLXSW_REG(spad), spad_pl);
if (err)
return err;
mlxsw_reg_spad_base_mac_memcpy_from(spad_pl, mlxsw_m->base_mac);
return 0;
}
static int mlxsw_m_port_dummy_open_stop(struct net_device *dev) static int mlxsw_m_port_dummy_open_stop(struct net_device *dev)
{ {
return 0; return 0;
...@@ -314,6 +326,12 @@ static int mlxsw_m_init(struct mlxsw_core *mlxsw_core, ...@@ -314,6 +326,12 @@ static int mlxsw_m_init(struct mlxsw_core *mlxsw_core,
mlxsw_m->core = mlxsw_core; mlxsw_m->core = mlxsw_core;
mlxsw_m->bus_info = mlxsw_bus_info; mlxsw_m->bus_info = mlxsw_bus_info;
err = mlxsw_m_base_mac_get(mlxsw_m);
if (err) {
dev_err(mlxsw_m->bus_info->dev, "Failed to get base mac\n");
return err;
}
err = mlxsw_m_ports_create(mlxsw_m); err = mlxsw_m_ports_create(mlxsw_m);
if (err) { if (err) {
dev_err(mlxsw_m->bus_info->dev, "Failed to create ports\n"); dev_err(mlxsw_m->bus_info->dev, "Failed to create ports\n");
......
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