|
| 1 | +From b3fb34f9f6215e0677de88e07f2139b56ba7508f Mon Sep 17 00:00:00 2001 |
| 2 | +From: Vadim Pasternak < [email protected]> |
| 3 | +Date: Thu, 21 May 2020 13:34:17 +0300 |
| 4 | +Subject: [backport 4.19 2/3] mlxsw: core: thermal: Separate temperature trend |
| 5 | + read callback |
| 6 | + |
| 7 | +Separate temperature trend reading callback between chip thermal zone |
| 8 | +and others types of thermal zones (modules and gearboxes). |
| 9 | +Currently all these types use same get_trend() callback, which is wrong for |
| 10 | +the chip thermal zone, which is defined as "parent zone". |
| 11 | +When get_trend() callback is invoked, it obtains "parent zone" from the |
| 12 | +relevant thermal device data, which is correct for modules and |
| 13 | +gearboxes thermal devices, but not for chip thermal device, which is |
| 14 | +a parent. |
| 15 | +Keep using the existing get_trend() callback for modules and gearboxes, |
| 16 | +add new get_trend() callback for chip. |
| 17 | + |
| 18 | +Signed-off-by: Vadim Pasternak < [email protected]> |
| 19 | +--- |
| 20 | + drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 23 ++++++++++++++++++---- |
| 21 | + 1 file changed, 19 insertions(+), 4 deletions(-) |
| 22 | + |
| 23 | +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c |
| 24 | +index 77578f5bb..775343a25 100644 |
| 25 | +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c |
| 26 | ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c |
| 27 | +@@ -402,8 +402,7 @@ static int mlxsw_thermal_set_trip_hyst(struct thermal_zone_device *tzdev, |
| 28 | + static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev, |
| 29 | + int trip, enum thermal_trend *trend) |
| 30 | + { |
| 31 | +- struct mlxsw_thermal_module *tz = tzdev->devdata; |
| 32 | +- struct mlxsw_thermal *thermal = tz->parent; |
| 33 | ++ struct mlxsw_thermal *thermal = tzdev->devdata; |
| 34 | + |
| 35 | + if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS) |
| 36 | + return -EINVAL; |
| 37 | +@@ -614,6 +613,22 @@ mlxsw_thermal_module_trip_hyst_set(struct thermal_zone_device *tzdev, int trip, |
| 38 | + return 0; |
| 39 | + } |
| 40 | + |
| 41 | ++static int mlxsw_thermal_module_trend_get(struct thermal_zone_device *tzdev, |
| 42 | ++ int trip, enum thermal_trend *trend) |
| 43 | ++{ |
| 44 | ++ struct mlxsw_thermal_module *tz = tzdev->devdata; |
| 45 | ++ struct mlxsw_thermal *thermal = tz->parent; |
| 46 | ++ |
| 47 | ++ if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS) |
| 48 | ++ return -EINVAL; |
| 49 | ++ |
| 50 | ++ if (tzdev == thermal->tz_highest_dev) |
| 51 | ++ return 1; |
| 52 | ++ |
| 53 | ++ *trend = THERMAL_TREND_STABLE; |
| 54 | ++ return 0; |
| 55 | ++} |
| 56 | ++ |
| 57 | + static struct thermal_zone_device_ops mlxsw_thermal_module_ops = { |
| 58 | + .bind = mlxsw_thermal_module_bind, |
| 59 | + .unbind = mlxsw_thermal_module_unbind, |
| 60 | +@@ -625,7 +640,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_module_ops = { |
| 61 | + .set_trip_temp = mlxsw_thermal_module_trip_temp_set, |
| 62 | + .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get, |
| 63 | + .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set, |
| 64 | +- .get_trend = mlxsw_thermal_trend_get, |
| 65 | ++ .get_trend = mlxsw_thermal_module_trend_get, |
| 66 | + }; |
| 67 | + |
| 68 | + static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, |
| 69 | +@@ -670,7 +685,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = { |
| 70 | + .set_trip_temp = mlxsw_thermal_module_trip_temp_set, |
| 71 | + .get_trip_hyst = mlxsw_thermal_module_trip_hyst_get, |
| 72 | + .set_trip_hyst = mlxsw_thermal_module_trip_hyst_set, |
| 73 | +- .get_trend = mlxsw_thermal_trend_get, |
| 74 | ++ .get_trend = mlxsw_thermal_module_trend_get, |
| 75 | + }; |
| 76 | + |
| 77 | + static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev, |
| 78 | +-- |
| 79 | +2.11.0 |
| 80 | + |
0 commit comments