Commit 69115b7d authored by Vadim Pasternak's avatar Vadim Pasternak Committed by David S. Miller

mlxsw: core: Modify thermal zone definition

Modify thermal zone trip points setting for better alignment with system
thermal requirement.

Add hysteresis thresholds for thermal trips in order to avoid throttling
around thermal trip point. If hysteresis temperature is not considered,
PWM can have side effect of flip up/down on thermal trip point boundary.
Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3dcfe179
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define MLXSW_THERMAL_POLL_INT 1000 /* ms */ #define MLXSW_THERMAL_POLL_INT 1000 /* ms */
#define MLXSW_THERMAL_SLOW_POLL_INT 20000 /* ms */ #define MLXSW_THERMAL_SLOW_POLL_INT 20000 /* ms */
#define MLXSW_THERMAL_MAX_TEMP 110000 /* 110C */ #define MLXSW_THERMAL_MAX_TEMP 110000 /* 110C */
#define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */
#define MLXSW_THERMAL_MAX_STATE 10 #define MLXSW_THERMAL_MAX_STATE 10
#define MLXSW_THERMAL_MAX_DUTY 255 #define MLXSW_THERMAL_MAX_DUTY 255
/* Minimum and maximum fan allowed speed in percent: from 20% to 100%. Values /* Minimum and maximum fan allowed speed in percent: from 20% to 100%. Values
...@@ -30,6 +31,7 @@ ...@@ -30,6 +31,7 @@
struct mlxsw_thermal_trip { struct mlxsw_thermal_trip {
int type; int type;
int temp; int temp;
int hyst;
int min_state; int min_state;
int max_state; int max_state;
}; };
...@@ -38,25 +40,22 @@ static const struct mlxsw_thermal_trip default_thermal_trips[] = { ...@@ -38,25 +40,22 @@ static const struct mlxsw_thermal_trip default_thermal_trips[] = {
{ /* In range - 0-40% PWM */ { /* In range - 0-40% PWM */
.type = THERMAL_TRIP_ACTIVE, .type = THERMAL_TRIP_ACTIVE,
.temp = 75000, .temp = 75000,
.hyst = MLXSW_THERMAL_HYSTERESIS_TEMP,
.min_state = 0, .min_state = 0,
.max_state = (4 * MLXSW_THERMAL_MAX_STATE) / 10, .max_state = (4 * MLXSW_THERMAL_MAX_STATE) / 10,
}, },
{ /* High - 40-100% PWM */ {
/* In range - 40-100% PWM */
.type = THERMAL_TRIP_ACTIVE, .type = THERMAL_TRIP_ACTIVE,
.temp = 80000, .temp = 80000,
.hyst = MLXSW_THERMAL_HYSTERESIS_TEMP,
.min_state = (4 * MLXSW_THERMAL_MAX_STATE) / 10, .min_state = (4 * MLXSW_THERMAL_MAX_STATE) / 10,
.max_state = MLXSW_THERMAL_MAX_STATE, .max_state = MLXSW_THERMAL_MAX_STATE,
}, },
{
/* Very high - 100% PWM */
.type = THERMAL_TRIP_ACTIVE,
.temp = 85000,
.min_state = MLXSW_THERMAL_MAX_STATE,
.max_state = MLXSW_THERMAL_MAX_STATE,
},
{ /* Warning */ { /* Warning */
.type = THERMAL_TRIP_HOT, .type = THERMAL_TRIP_HOT,
.temp = 105000, .temp = 85000,
.hyst = MLXSW_THERMAL_HYSTERESIS_TEMP,
.min_state = MLXSW_THERMAL_MAX_STATE, .min_state = MLXSW_THERMAL_MAX_STATE,
.max_state = MLXSW_THERMAL_MAX_STATE, .max_state = MLXSW_THERMAL_MAX_STATE,
}, },
...@@ -246,6 +245,24 @@ static int mlxsw_thermal_set_trip_temp(struct thermal_zone_device *tzdev, ...@@ -246,6 +245,24 @@ static int mlxsw_thermal_set_trip_temp(struct thermal_zone_device *tzdev,
return 0; return 0;
} }
static int mlxsw_thermal_get_trip_hyst(struct thermal_zone_device *tzdev,
int trip, int *p_hyst)
{
struct mlxsw_thermal *thermal = tzdev->devdata;
*p_hyst = thermal->trips[trip].hyst;
return 0;
}
static int mlxsw_thermal_set_trip_hyst(struct thermal_zone_device *tzdev,
int trip, int hyst)
{
struct mlxsw_thermal *thermal = tzdev->devdata;
thermal->trips[trip].hyst = hyst;
return 0;
}
static struct thermal_zone_device_ops mlxsw_thermal_ops = { static struct thermal_zone_device_ops mlxsw_thermal_ops = {
.bind = mlxsw_thermal_bind, .bind = mlxsw_thermal_bind,
.unbind = mlxsw_thermal_unbind, .unbind = mlxsw_thermal_unbind,
...@@ -255,6 +272,8 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops = { ...@@ -255,6 +272,8 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops = {
.get_trip_type = mlxsw_thermal_get_trip_type, .get_trip_type = mlxsw_thermal_get_trip_type,
.get_trip_temp = mlxsw_thermal_get_trip_temp, .get_trip_temp = mlxsw_thermal_get_trip_temp,
.set_trip_temp = mlxsw_thermal_set_trip_temp, .set_trip_temp = mlxsw_thermal_set_trip_temp,
.get_trip_hyst = mlxsw_thermal_get_trip_hyst,
.set_trip_hyst = mlxsw_thermal_set_trip_hyst,
}; };
static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev, static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,
......
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