Skip to content

Commit 72a64c2

Browse files
odmykodavem330
authored andcommitted
mlxsw: thermal: Read module temperature thresholds using MTMP register
mlxsw_thermal_module_trips_update() is used to update the trip points of the module's thermal zone. Currently, this is done by querying the thresholds from the module's EEPROM via MCIA register. This data does not pass validation and in some cases can be unreliable. For example, due to some problem with transceiver module. Previous patch made it possible to read module's temperature and thresholds via MTMP register. Therefore, extend mlxsw_thermal_module_trips_update() to use the thresholds queried from MTMP, if valid. This is both more reliable and more efficient than current method, as temperature and thresholds are queried in one transaction instead of three. This is significant when working over a slow bus such as I2C. Signed-off-by: Mykola Kostenok <[email protected]> Acked-by: Vadim Pasternak <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e57977b commit 72a64c2

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

+30-17
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,27 @@ mlxsw_thermal_module_trips_reset(struct mlxsw_thermal_module *tz)
149149

150150
static int
151151
mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
152-
struct mlxsw_thermal_module *tz)
152+
struct mlxsw_thermal_module *tz,
153+
int crit_temp, int emerg_temp)
153154
{
154-
int crit_temp, emerg_temp;
155155
int err;
156156

157-
err = mlxsw_env_module_temp_thresholds_get(core, tz->module,
158-
SFP_TEMP_HIGH_WARN,
159-
&crit_temp);
160-
if (err)
161-
return err;
157+
/* Do not try to query temperature thresholds directly from the module's
158+
* EEPROM if we got valid thresholds from MTMP.
159+
*/
160+
if (!emerg_temp || !crit_temp) {
161+
err = mlxsw_env_module_temp_thresholds_get(core, tz->module,
162+
SFP_TEMP_HIGH_WARN,
163+
&crit_temp);
164+
if (err)
165+
return err;
162166

163-
err = mlxsw_env_module_temp_thresholds_get(core, tz->module,
164-
SFP_TEMP_HIGH_ALARM,
165-
&emerg_temp);
166-
if (err)
167-
return err;
167+
err = mlxsw_env_module_temp_thresholds_get(core, tz->module,
168+
SFP_TEMP_HIGH_ALARM,
169+
&emerg_temp);
170+
if (err)
171+
return err;
172+
}
168173

169174
if (crit_temp > emerg_temp) {
170175
dev_warn(dev, "%s : Critical threshold %d is above emergency threshold %d\n",
@@ -451,25 +456,26 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
451456
{
452457
struct mlxsw_thermal_module *tz = tzdev->devdata;
453458
struct mlxsw_thermal *thermal = tz->parent;
459+
int temp, crit_temp, emerg_temp;
454460
struct device *dev;
455461
u16 sensor_index;
456-
int temp;
457462
int err;
458463

459464
dev = thermal->bus_info->dev;
460465
sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + tz->module;
461466

462467
/* Read module temperature and thresholds. */
463468
mlxsw_thermal_module_temp_and_thresholds_get(thermal->core,
464-
sensor_index, &temp, NULL,
465-
NULL);
469+
sensor_index, &temp,
470+
&crit_temp, &emerg_temp);
466471
*p_temp = temp;
467472

468473
if (!temp)
469474
return 0;
470475

471476
/* Update trip points. */
472-
err = mlxsw_thermal_module_trips_update(dev, thermal->core, tz);
477+
err = mlxsw_thermal_module_trips_update(dev, thermal->core, tz,
478+
crit_temp, emerg_temp);
473479
if (!err && temp > 0)
474480
mlxsw_thermal_tz_score_update(thermal, tzdev, tz->trips, temp);
475481

@@ -736,7 +742,10 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
736742
struct mlxsw_thermal *thermal, u8 module)
737743
{
738744
struct mlxsw_thermal_module *module_tz;
745+
int crit_temp, emerg_temp;
746+
u16 sensor_index;
739747

748+
sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + module;
740749
module_tz = &thermal->tz_module_arr[module];
741750
/* Skip if parent is already set (case of port split). */
742751
if (module_tz->parent)
@@ -747,8 +756,12 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
747756
sizeof(thermal->trips));
748757
/* Initialize all trip point. */
749758
mlxsw_thermal_module_trips_reset(module_tz);
759+
/* Read module temperature and thresholds. */
760+
mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, NULL,
761+
&crit_temp, &emerg_temp);
750762
/* Update trip point according to the module data. */
751-
return mlxsw_thermal_module_trips_update(dev, core, module_tz);
763+
return mlxsw_thermal_module_trips_update(dev, core, module_tz,
764+
crit_temp, emerg_temp);
752765
}
753766

754767
static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)

0 commit comments

Comments
 (0)