Skip to contentSkip to conversation

Fixes for Tegra soctherm

PATCH Superseded Wei Ni 3 participants 15 messages Jan 3, 2019 – Mar 30, 2020

Subsystems (2)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Wei Ni

author
#0 lore raw

v7 cover Fixes for Tegra soctherm

This series fixed some issues for Tegra soctherm,
and add get_trend().

Main changes from v6:
1. Per Eduardo's comment, we can remove the change:
"thermal: tegra: parse sensor id before sensor register"

Main changes from v5:
1. Move the get_trend() patch https://lkml.org/lkml/2018/11/20/643
into this serial.

Main changes from v4:
1. fixed for the parsing sensor id.
2. keep warning for missing critical trips.

Main changes from v3:
1. updated codes for parsing sensor id, per Thierry's comments

Main changes from v2:
1. add codes to parse sensor id to avoid registration failure.

Main changes from v1:
1. Acked by Thierry Reding <[email protected]> for the patch "thermal: tegra: fix memory allocation".
2. Print out the sensor name when register failed.
2. Remove patch "thermal: tegra: fix coverity defect"

Wei Ni (3):
thermal: tegra: remove unnecessary warnings
thermal: tegra: fix memory allocation
thermal: tegra: add get_trend ops

 drivers/thermal/tegra/soctherm.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v7 1/3 thermal: tegra: remove unnecessary warnings

Convert warnings to info as not all platforms may
have all the thresholds and sensors enabled.

---
 drivers/thermal/tegra/soctherm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +2 -2
index ed28110a3535..f07de8258e93 100644
@@ -569,7 +569,7 @@ static int tegra_soctherm_set_hwtrips(struct device *dev,
 set_throttle:
 	ret = get_hot_temp(tz, &trip, &temperature);
 	if (ret) {
-		dev_warn(dev, "throttrip: %s: missing hot temperature\n",
+		dev_info(dev, "throttrip: %s: missing hot temperature\n",
 			 sg->name);
 		return 0;
 	}
@@ -600,7 +600,7 @@ static int tegra_soctherm_set_hwtrips(struct device *dev,
 	}
 
 	if (i == THROTTLE_SIZE)
-		dev_warn(dev, "throttrip: %s: missing throttle cdev\n",
+		dev_info(dev, "throttrip: %s: missing throttle cdev\n",
 			 sg->name);
 
 	return 0;
Signature · 1 line
2.7.4
Reviewed-by on v7 1/3
#2 lore raw

Re: [PATCH v7 1/3] thermal: tegra: remove unnecessary warnings

Quoted 5 lines · Wei Ni

Convert warnings to info as not all platforms may
have all the thresholds and sensors enabled.

---

Quoted 26 lines
 drivers/thermal/tegra/soctherm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +2 -2
index ed28110a3535..f07de8258e93 100644
@@ -569,7 +569,7 @@ static int tegra_soctherm_set_hwtrips(struct device *dev,
 set_throttle:
 	ret = get_hot_temp(tz, &trip, &temperature);
 	if (ret) {
-		dev_warn(dev, "throttrip: %s: missing hot temperature\n",
+		dev_info(dev, "throttrip: %s: missing hot temperature\n",
 			 sg->name);
 		return 0;
 	}
@@ -600,7 +600,7 @@ static int tegra_soctherm_set_hwtrips(struct device *dev,
 	}
 
 	if (i == THROTTLE_SIZE)
-		dev_warn(dev, "throttrip: %s: missing throttle cdev\n",
+		dev_info(dev, "throttrip: %s: missing throttle cdev\n",
 			 sg->name);
 
 	return 0;
Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author
#3 lore raw

Re: [PATCH v7 1/3] thermal: tegra: remove unnecessary warnings

Quoted 8 lines · Daniel Lezcano
Quoted 5 lines · Wei Ni

Convert warnings to info as not all platforms may
have all the thresholds and sensors enabled.

---

Daniel, thank you for your review.

Quoted 29 lines
Quoted 27 lines
 drivers/thermal/tegra/soctherm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +2 -2
index ed28110a3535..f07de8258e93 100644
@@ -569,7 +569,7 @@ static int tegra_soctherm_set_hwtrips(struct device *dev,
 set_throttle:
 	ret = get_hot_temp(tz, &trip, &temperature);
 	if (ret) {
-		dev_warn(dev, "throttrip: %s: missing hot temperature\n",
+		dev_info(dev, "throttrip: %s: missing hot temperature\n",
 			 sg->name);
 		return 0;
 	}
@@ -600,7 +600,7 @@ static int tegra_soctherm_set_hwtrips(struct device *dev,
 	}
 
 	if (i == THROTTLE_SIZE)
-		dev_warn(dev, "throttrip: %s: missing throttle cdev\n",
+		dev_info(dev, "throttrip: %s: missing throttle cdev\n",
 			 sg->name);
 
 	return 0;
author
#4 lore raw

PATCH v7 2/3 thermal: tegra: fix memory allocation

In reply to Wei Ni

Fix memory allocation to store the pointers to
thermal_zone_device.

---
 drivers/thermal/tegra/soctherm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/tegra/soctherm.c +1 -1
index f07de8258e93..fd2703c0cfc5 100644
@@ -1339,7 +1339,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 	}
 
 	tegra->thermctl_tzs = devm_kcalloc(&pdev->dev,
-					   soc->num_ttgs, sizeof(*z),
+					   soc->num_ttgs, sizeof(z),
 					   GFP_KERNEL);
 	if (!tegra->thermctl_tzs)
 		return -ENOMEM;
Signature · 1 line
2.7.4
Reviewed-by on v7 2/3
#5 lore raw

Re: [PATCH v7 2/3] thermal: tegra: fix memory allocation

Quoted 6 lines · Wei Ni

Fix memory allocation to store the pointers to
thermal_zone_device.

---

Good catch

Quoted 17 lines
 drivers/thermal/tegra/soctherm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/tegra/soctherm.c +1 -1
index f07de8258e93..fd2703c0cfc5 100644
@@ -1339,7 +1339,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 	}
 
 	tegra->thermctl_tzs = devm_kcalloc(&pdev->dev,
-					   soc->num_ttgs, sizeof(*z),
+					   soc->num_ttgs, sizeof(z),
 					   GFP_KERNEL);
 	if (!tegra->thermctl_tzs)
 		return -ENOMEM;
Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author
#6 lore raw

PATCH v7 3/3 thermal: tegra: add get_trend ops

In reply to Wei Ni

Add support for get_trend ops that allows soctherm sensors to be used with the step-wise governor.

---
 drivers/thermal/tegra/soctherm.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/thermal/tegra/soctherm.c +34 -0
index fd2703c0cfc5..864205af104b 100644
@@ -488,9 +488,43 @@ static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp)
 	return 0;
 }
 
+static int tegra_thermctl_get_trend(void *data, int trip,
+				    enum thermal_trend *trend)
+{
+	struct tegra_thermctl_zone *zone = data;
+	struct thermal_zone_device *tz = zone->tz;
+	int trip_temp, temp, last_temp, ret;
+
+	if (!tz)
+		return -EINVAL;
+
+	ret = tz->ops->get_trip_temp(zone->tz, trip, &trip_temp);
+	if (ret)
+		return ret;
+
+	mutex_lock(&tz->lock);
+	temp = tz->temperature;
+	last_temp = tz->last_temperature;
+	mutex_unlock(&tz->lock);
+
+	if (temp > trip_temp) {
+		if (temp >= last_temp)
+			*trend = THERMAL_TREND_RAISING;
+		else
+			*trend = THERMAL_TREND_STABLE;
+	} else if (temp < trip_temp) {
+		*trend = THERMAL_TREND_DROPPING;
+	} else {
+		*trend = THERMAL_TREND_STABLE;
+	}
+
+	return 0;
+}
+
 static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = {
 	.get_temp = tegra_thermctl_get_temp,
 	.set_trip_temp = tegra_thermctl_set_trip_temp,
+	.get_trend = tegra_thermctl_get_trend,
 };
 
 static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *temp)
Signature · 1 line
2.7.4
#7 lore raw

Re: [PATCH v7 3/3] thermal: tegra: add get_trend ops

Quoted 21 lines · Wei Ni

Add support for get_trend ops that allows soctherm sensors to be used with the step-wise governor.

---
 drivers/thermal/tegra/soctherm.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/thermal/tegra/soctherm.c +5 -0
index fd2703c0cfc5..864205af104b 100644
@@ -488,9 +488,43 @@ static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp)
 	return 0;
 }
 
+static int tegra_thermctl_get_trend(void *data, int trip,
+				    enum thermal_trend *trend)
+{
+	struct tegra_thermctl_zone *zone = data;
+	struct thermal_zone_device *tz = zone->tz;

drivers/thermal/tegra/soctherm.c static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp) · line 505

Quoted 10 lines
drivers/thermal/tegra/soctherm.c +10 -0
+	int trip_temp, temp, last_temp, ret;
+
+	if (!tz)
+		return -EINVAL;
+
+	ret = tz->ops->get_trip_temp(zone->tz, trip, &trip_temp);
+	if (ret)
+		return ret;
+
+	mutex_lock(&tz->lock);

No need to use the mutex here.

Why not ?

temp = READ_ONCE(tz->temperature);
last_temp = READ_ONCE(tz->last_temperature);

Quoted 26 lines
drivers/thermal/tegra/soctherm.c +19 -0
+	temp = tz->temperature;
+	last_temp = tz->last_temperature;
+	mutex_unlock(&tz->lock);
+
+	if (temp > trip_temp) {
+		if (temp >= last_temp)
+			*trend = THERMAL_TREND_RAISING;
+		else
+			*trend = THERMAL_TREND_STABLE;
+	} else if (temp < trip_temp) {
+		*trend = THERMAL_TREND_DROPPING;
+	} else {
+		*trend = THERMAL_TREND_STABLE;
+	}
+
+	return 0;
+}
+
 static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = {
 	.get_temp = tegra_thermctl_get_temp,
 	.set_trip_temp = tegra_thermctl_set_trip_temp,
+	.get_trend = tegra_thermctl_get_trend,
 };
 
 static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *temp)
Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author
#8 lore raw

Re: [PATCH v7 3/3] thermal: tegra: add get_trend ops

Quoted 35 lines · Daniel Lezcano
Quoted 21 lines · Wei Ni

Add support for get_trend ops that allows soctherm sensors to be used with the step-wise governor.

---
 drivers/thermal/tegra/soctherm.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/thermal/tegra/soctherm.c +5 -0
index fd2703c0cfc5..864205af104b 100644
@@ -488,9 +488,43 @@ static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp)
 	return 0;
 }
 
+static int tegra_thermctl_get_trend(void *data, int trip,
+				    enum thermal_trend *trend)
+{
+	struct tegra_thermctl_zone *zone = data;
+	struct thermal_zone_device *tz = zone->tz;

drivers/thermal/tegra/soctherm.c static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp) · line 505

Quoted 10 lines
drivers/thermal/tegra/soctherm.c +10 -0
+	int trip_temp, temp, last_temp, ret;
+
+	if (!tz)
+		return -EINVAL;
+
+	ret = tz->ops->get_trip_temp(zone->tz, trip, &trip_temp);
+	if (ret)
+		return ret;
+
+	mutex_lock(&tz->lock);

No need to use the mutex here.

Quoted 4 lines

Why not ?

temp = READ_ONCE(tz->temperature);
last_temp = READ_ONCE(tz->last_temperature);

Yes, you are right, will change it in next version.

Wei.

Quoted 29 lines
Quoted 27 lines
drivers/thermal/tegra/soctherm.c +19 -0
+	temp = tz->temperature;
+	last_temp = tz->last_temperature;
+	mutex_unlock(&tz->lock);
+
+	if (temp > trip_temp) {
+		if (temp >= last_temp)
+			*trend = THERMAL_TREND_RAISING;
+		else
+			*trend = THERMAL_TREND_STABLE;
+	} else if (temp < trip_temp) {
+		*trend = THERMAL_TREND_DROPPING;
+	} else {
+		*trend = THERMAL_TREND_STABLE;
+	}
+
+	return 0;
+}
+
 static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = {
 	.get_temp = tegra_thermctl_get_temp,
 	.set_trip_temp = tegra_thermctl_set_trip_temp,
+	.get_trend = tegra_thermctl_get_trend,
 };
 
 static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *temp)
#9 lore raw

Re: [PATCH v7 3/3] thermal: tegra: add get_trend ops

Hi Wei,

Quoted 2 lines · Wei Ni
Quoted 2 lines
Quoted 2 lines

+static int tegra_thermctl_get_trend(void *data, int trip, + enum thermal_trend *trend)

[ ... ]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
(quoted diff) +1 -0
+	temp = tz->temperature; +	last_temp = tz->last_temperature; +

mutex_unlock(&tz->lock); + + if (temp > trip_temp) { + if
(temp >= last_temp) + *trend = THERMAL_TREND_RAISING; +
else + *trend = THERMAL_TREND_STABLE; + } else if (temp <
trip_temp) { + *trend = THERMAL_TREND_DROPPING; + } else { +
*trend = THERMAL_TREND_STABLE; + } + + return 0; +} + static
const struct thermal_zone_of_device_ops tegra_of_thermal_ops = { .get_temp = tegra_thermctl_get_temp, .set_trip_temp =
tegra_thermctl_set_trip_temp, + .get_trend =
tegra_thermctl_get_trend, };

It has been awhile since this patch was submitted and merged by Eduardo. I replace him to co-maintain the thermal framework with Rui.

While figuring out the internals for code cleanup, I ended up in this function above.

Why do you have to use this routine instead of the generic one in get_tz_trend()?

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author
#10 lore raw
In reply to Wei Ni

Hi Eduardo,
Do you have any more comments, will you take this serial?

Thanks.
Wei.

Quoted 36 lines · Wei Ni

This series fixed some issues for Tegra soctherm,
and add get_trend().

Main changes from v6:
1. Per Eduardo's comment, we can remove the change:
"thermal: tegra: parse sensor id before sensor register"

Main changes from v5:
1. Move the get_trend() patch https://lkml.org/lkml/2018/11/20/643
into this serial.

Main changes from v4:
1. fixed for the parsing sensor id.
2. keep warning for missing critical trips.

Main changes from v3:
1. updated codes for parsing sensor id, per Thierry's comments

Main changes from v2:
1. add codes to parse sensor id to avoid registration failure.

Main changes from v1:
1. Acked by Thierry Reding <[email protected]> for the patch "thermal: tegra: fix memory allocation".
2. Print out the sensor name when register failed.
2. Remove patch "thermal: tegra: fix coverity defect"

Wei Ni (3):
thermal: tegra: remove unnecessary warnings
thermal: tegra: fix memory allocation
thermal: tegra: add get_trend ops

 drivers/thermal/tegra/soctherm.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
author
#11 lore raw

Does there have any comments?

Thanks.
Wei.

Quoted 43 lines · Wei Ni

Hi Eduardo,
Do you have any more comments, will you take this serial?

Thanks.
Wei.

Quoted 36 lines · Wei Ni

This series fixed some issues for Tegra soctherm,
and add get_trend().

Main changes from v6:
1. Per Eduardo's comment, we can remove the change:
"thermal: tegra: parse sensor id before sensor register"

Main changes from v5:
1. Move the get_trend() patch https://lkml.org/lkml/2018/11/20/643
into this serial.

Main changes from v4:
1. fixed for the parsing sensor id.
2. keep warning for missing critical trips.

Main changes from v3:
1. updated codes for parsing sensor id, per Thierry's comments

Main changes from v2:
1. add codes to parse sensor id to avoid registration failure.

Main changes from v1:
1. Acked by Thierry Reding <[email protected]> for the patch "thermal: tegra: fix memory allocation".
2. Print out the sensor name when register failed.
2. Remove patch "thermal: tegra: fix coverity defect"

Wei Ni (3):
thermal: tegra: remove unnecessary warnings
thermal: tegra: fix memory allocation
thermal: tegra: add get_trend ops

 drivers/thermal/tegra/soctherm.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
author
#12 lore raw

Rui,
Will you take this serial?

Thanks.
Wei.

Quoted 49 lines · Wei Ni

Does there have any comments?

Thanks.
Wei.

Quoted 43 lines · Wei Ni

Hi Eduardo,
Do you have any more comments, will you take this serial?

Thanks.
Wei.

Quoted 36 lines · Wei Ni

This series fixed some issues for Tegra soctherm,
and add get_trend().

Main changes from v6:
1. Per Eduardo's comment, we can remove the change:
"thermal: tegra: parse sensor id before sensor register"

Main changes from v5:
1. Move the get_trend() patch https://lkml.org/lkml/2018/11/20/643
into this serial.

Main changes from v4:
1. fixed for the parsing sensor id.
2. keep warning for missing critical trips.

Main changes from v3:
1. updated codes for parsing sensor id, per Thierry's comments

Main changes from v2:
1. add codes to parse sensor id to avoid registration failure.

Main changes from v1:
1. Acked by Thierry Reding <[email protected]> for the patch "thermal: tegra: fix memory allocation".
2. Print out the sensor name when register failed.
2. Remove patch "thermal: tegra: fix coverity defect"

Wei Ni (3):
thermal: tegra: remove unnecessary warnings
thermal: tegra: fix memory allocation
thermal: tegra: add get_trend ops

 drivers/thermal/tegra/soctherm.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)
reviewer
#13 lore raw
Quoted 3 lines · Wei Ni

Rui,
Will you take this serial?

it is already in my tree.
I missed -rc6, thus I will queue them for 5.1-rc1.

thanks,
rui

Quoted 58 lines

Thanks.
Wei.

Quoted 54 lines · Wei Ni

Does there have any comments?

Thanks.
Wei.

Quoted 47 lines · Wei Ni

Hi Eduardo,
Do you have any more comments, will you take this serial?

Thanks.
Wei.

Quoted 39 lines · Wei Ni

This series fixed some issues for Tegra soctherm,
and add get_trend().

Main changes from v6:
1. Per Eduardo's comment, we can remove the change:
"thermal: tegra: parse sensor id before sensor register"

Main changes from v5:
1. Move the get_trend() patch https://lkml.org/lkml/2018/11/20/
643
into this serial.

Main changes from v4:
1. fixed for the parsing sensor id.
2. keep warning for missing critical trips.

Main changes from v3:
1. updated codes for parsing sensor id, per Thierry's comments

Main changes from v2:
1. add codes to parse sensor id to avoid registration failure.

Main changes from v1:
1. Acked by Thierry Reding <[email protected]> for the patch "thermal: tegra: fix memory allocation".
2. Print out the sensor name when register failed.
2. Remove patch "thermal: tegra: fix coverity defect"

Wei Ni (3):
  thermal: tegra: remove unnecessary warnings
  thermal: tegra: fix memory allocation
  thermal: tegra: add get_trend ops

 drivers/thermal/tegra/soctherm.c | 40
+++++++++++++++++++++++++++++++++++++---

 1 file changed, 37 insertions(+), 3 deletions(-)
author
#14 lore raw
Quoted 6 lines · Zhang Rui
Quoted 3 lines · Wei Ni

Rui,
Will you take this serial?

it is already in my tree.
I missed -rc6, thus I will queue them for 5.1-rc1.

Thanks.
I updated v8 patch per Daniel Lezcano's comment.
Please check it.

Wei.

Quoted 62 lines

thanks,
rui

Quoted 58 lines

Thanks.
Wei.

Quoted 54 lines · Wei Ni

Does there have any comments?

Thanks.
Wei.

Quoted 47 lines · Wei Ni

Hi Eduardo,
Do you have any more comments, will you take this serial?

Thanks.
Wei.

Quoted 39 lines · Wei Ni

This series fixed some issues for Tegra soctherm,
and add get_trend().

Main changes from v6:
1. Per Eduardo's comment, we can remove the change:
"thermal: tegra: parse sensor id before sensor register"

Main changes from v5:
1. Move the get_trend() patch https://lkml.org/lkml/2018/11/20/
643
into this serial.

Main changes from v4:
1. fixed for the parsing sensor id.
2. keep warning for missing critical trips.

Main changes from v3:
1. updated codes for parsing sensor id, per Thierry's comments

Main changes from v2:
1. add codes to parse sensor id to avoid registration failure.

Main changes from v1:
1. Acked by Thierry Reding <[email protected]> for the patch "thermal: tegra: fix memory allocation".
2. Print out the sensor name when register failed.
2. Remove patch "thermal: tegra: fix coverity defect"

Wei Ni (3):
  thermal: tegra: remove unnecessary warnings
  thermal: tegra: fix memory allocation
  thermal: tegra: add get_trend ops

 drivers/thermal/tegra/soctherm.c | 40
+++++++++++++++++++++++++++++++++++++---

 1 file changed, 37 insertions(+), 3 deletions(-)