Skip to contentSkip to conversation

Fixes for Tegra soctherm

PATCH Superseded Wei Ni 4 participants 16 messages Dec 14, 2018 – Dec 20, 2018

Subsystems (2)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Wei Ni

author
#0 lore raw

v6 cover Fixes for Tegra soctherm

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

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 (4):
thermal: tegra: remove unnecessary warnings
thermal: tegra: fix memory allocation
thermal: tegra: parse sensor id before sensor register
thermal: tegra: add get_trend ops

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

PATCH v6 1/4 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
Acked-by on v6 1/4
#2 lore raw

Re: [PATCH v6 1/4] thermal: tegra: remove unnecessary warnings

Quoted 7 lines · Wei Ni

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(-)
author
#3 lore raw

PATCH v6 2/4 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
author
#4 lore raw

PATCH v6 3/4 thermal: tegra: parse sensor id before sensor register

In reply to Wei Ni

Since different platforms may not support all 4 sensors, so the sensor registration may be failed. Add codes to parse dt to find sensor id which need to be registered. So that the registration can be successful on all platform.

---
 drivers/thermal/tegra/soctherm.c | 45 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +43 -2
index fd2703c0cfc5..6bee31cd4621 100644
@@ -1224,6 +1224,41 @@ static void soctherm_init(struct platform_device *pdev)
 	tegra_soctherm_throttle(&pdev->dev);
 }
 
+static bool tegra_soctherm_find_sensor_id(unsigned int sensor_id)
+{
+	bool ret = false;
+	struct of_phandle_args sensor_specs;
+	struct device_node *np, *sensor_np;
+
+	np = of_find_node_by_name(NULL, "thermal-zones");
+	if (!np)
+		return ret;
+
+	for_each_available_child_of_node(np, sensor_np) {
+		if (of_parse_phandle_with_args(sensor_np, "thermal-sensors",
+						 "#thermal-sensor-cells",
+						 0, &sensor_specs))
+			continue;
+
+		if (sensor_specs.args_count != 1) {
+			WARN(sensor_specs.args_count != 1,
+			     "%s: wrong cells in sensor specifier %d\n",
+			     sensor_specs.np->name, sensor_specs.args_count);
+			continue;
+		}
+
+		if (sensor_specs.args[0] == sensor_id) {
+			of_node_put(sensor_np);
+			ret = true;
+			break;
+		}
+	}
+
+	of_node_put(np);
+
+	return ret;
+}
+
 static const struct of_device_id tegra_soctherm_of_match[] = {
 #ifdef CONFIG_ARCH_TEGRA_124_SOC
 	{
@@ -1365,13 +1400,16 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 		zone->sg = soc->ttgs[i];
 		zone->ts = tegra;
 
+		if (!tegra_soctherm_find_sensor_id(soc->ttgs[i]->id))
+			continue;
+
 		z = devm_thermal_zone_of_sensor_register(&pdev->dev,
 							 soc->ttgs[i]->id, zone,
 							 &tegra_of_thermal_ops);
 		if (IS_ERR(z)) {
 			err = PTR_ERR(z);
-			dev_err(&pdev->dev, "failed to register sensor: %d\n",
-				err);
+			dev_err(&pdev->dev, "failed to register sensor %s: %d\n",
+				soc->ttgs[i]->name, err);
 			goto disable_clocks;
 		}
 
@@ -1434,6 +1472,9 @@ static int __maybe_unused soctherm_resume(struct device *dev)
 		struct thermal_zone_device *tz;
 
 		tz = tegra->thermctl_tzs[soc->ttgs[i]->id];
+		if (!tz)
+			continue;
+
 		err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz);
 		if (err) {
 			dev_err(&pdev->dev,
Signature · 1 line
2.7.4
Acked-by on v6 3/4
#5 lore raw

Re: [PATCH v6 3/4] thermal: tegra: parse sensor id before sensor register

Quoted 10 lines · Wei Ni

Since different platforms may not support all 4 sensors, so the sensor registration may be failed. Add codes to parse dt to find sensor id which need to be registered. So that the registration can be successful on all platform.

---
 drivers/thermal/tegra/soctherm.c | 45 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
#6 lore raw

Re: [PATCH v6 3/4] thermal: tegra: parse sensor id before sensor register

In reply to Wei Ni
Quoted 43 lines · Wei Ni

Since different platforms may not support all 4 sensors, so the sensor registration may be failed. Add codes to parse dt to find sensor id which need to be registered. So that the registration can be successful on all platform.

---
 drivers/thermal/tegra/soctherm.c | 45 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +24 -0
index fd2703c0cfc5..6bee31cd4621 100644
@@ -1224,6 +1224,41 @@ static void soctherm_init(struct platform_device *pdev)
 	tegra_soctherm_throttle(&pdev->dev);
 }
 
+static bool tegra_soctherm_find_sensor_id(unsigned int sensor_id)
+{
+	bool ret = false;
+	struct of_phandle_args sensor_specs;
+	struct device_node *np, *sensor_np;
+
+	np = of_find_node_by_name(NULL, "thermal-zones");
+	if (!np)
+		return ret;
+
+	for_each_available_child_of_node(np, sensor_np) {
+		if (of_parse_phandle_with_args(sensor_np, "thermal-sensors",
+						 "#thermal-sensor-cells",
+						 0, &sensor_specs))
+			continue;
+
+		if (sensor_specs.args_count != 1) {
+			WARN(sensor_specs.args_count != 1,
+			     "%s: wrong cells in sensor specifier %d\n",
+			     sensor_specs.np->name, sensor_specs.args_count);
+			continue;
+		}
+
+		if (sensor_specs.args[0] == sensor_id) {

drivers/thermal/tegra/soctherm.c static void soctherm_init(struct platform_device *pdev) · line 1260

Quoted 10 lines
drivers/thermal/tegra/soctherm.c +10 -0
+			of_node_put(sensor_np);
+			ret = true;
+			break;
+		}
+	}
+
+	of_node_put(np);
+
+	return ret;
+}

So, I am still failing to see why this is really needed.

Why can't you simply resolve this with different compatibles? If the sensor is not present or disabled, the compatible is not, well, compatible anymore.

Quoted 36 lines
drivers/thermal/tegra/soctherm.c +9 -2
+
 static const struct of_device_id tegra_soctherm_of_match[] = {
 #ifdef CONFIG_ARCH_TEGRA_124_SOC
 	{
@@ -1365,13 +1400,16 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 		zone->sg = soc->ttgs[i];
 		zone->ts = tegra;
 
+		if (!tegra_soctherm_find_sensor_id(soc->ttgs[i]->id))
+			continue;
+
 		z = devm_thermal_zone_of_sensor_register(&pdev->dev,
 							 soc->ttgs[i]->id, zone,
 							 &tegra_of_thermal_ops);
 		if (IS_ERR(z)) {
 			err = PTR_ERR(z);
-			dev_err(&pdev->dev, "failed to register sensor: %d\n",
-				err);
+			dev_err(&pdev->dev, "failed to register sensor %s: %d\n",
+				soc->ttgs[i]->name, err);
 			goto disable_clocks;
 		}
 
@@ -1434,6 +1472,9 @@ static int __maybe_unused soctherm_resume(struct device *dev)
 		struct thermal_zone_device *tz;
 
 		tz = tegra->thermctl_tzs[soc->ttgs[i]->id];
+		if (!tz)
+			continue;
+
 		err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz);
 		if (err) {
 			dev_err(&pdev->dev,
Signature · 1 line
2.7.4
author
#7 lore raw

Re: [PATCH v6 3/4] thermal: tegra: parse sensor id before sensor register

Quoted 57 lines · Eduardo Valentin
Quoted 43 lines · Wei Ni

Since different platforms may not support all 4 sensors, so the sensor registration may be failed. Add codes to parse dt to find sensor id which need to be registered. So that the registration can be successful on all platform.

---
 drivers/thermal/tegra/soctherm.c | 45 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +24 -0
index fd2703c0cfc5..6bee31cd4621 100644
@@ -1224,6 +1224,41 @@ static void soctherm_init(struct platform_device *pdev)
 	tegra_soctherm_throttle(&pdev->dev);
 }
 
+static bool tegra_soctherm_find_sensor_id(unsigned int sensor_id)
+{
+	bool ret = false;
+	struct of_phandle_args sensor_specs;
+	struct device_node *np, *sensor_np;
+
+	np = of_find_node_by_name(NULL, "thermal-zones");
+	if (!np)
+		return ret;
+
+	for_each_available_child_of_node(np, sensor_np) {
+		if (of_parse_phandle_with_args(sensor_np, "thermal-sensors",
+						 "#thermal-sensor-cells",
+						 0, &sensor_specs))
+			continue;
+
+		if (sensor_specs.args_count != 1) {
+			WARN(sensor_specs.args_count != 1,
+			     "%s: wrong cells in sensor specifier %d\n",
+			     sensor_specs.np->name, sensor_specs.args_count);
+			continue;
+		}
+
+		if (sensor_specs.args[0] == sensor_id) {

drivers/thermal/tegra/soctherm.c static void soctherm_init(struct platform_device *pdev) · line 1260

Quoted 10 lines
drivers/thermal/tegra/soctherm.c +10 -0
+			of_node_put(sensor_np);
+			ret = true;
+			break;
+		}
+	}
+
+	of_node_put(np);
+
+	return ret;
+}

So, I am still failing to see why this is really needed.

Quoted 3 lines

Why can't you simply resolve this with different compatibles? If the sensor is not present or disabled, the compatible is not, well, compatible anymore.

This driver can support three Tegra chip t124, t132 and t210. And we also support some platforms for every chips. As the description in the commit, different platforms may not support all 4 sensors, so I upstreamed this patch.
If we use different compatibles, I think we can't resolve it simply, because we also need to add codes to configure which platform support which sensors, and may add more in the future. If use this patch, we doesn't need to do any more in the future.
Actually in my original change, I just ignore the registration failure to fix this issue, it will not affect loading driver, but as Daniel's comment, it's not better to ignore, so I followed his comment to refer the QORIQ thermal driver to get the sensor id.

Thanks.
Wei.

Quoted 37 lines
Quoted 37 lines
drivers/thermal/tegra/soctherm.c +9 -2
+
 static const struct of_device_id tegra_soctherm_of_match[] = {
 #ifdef CONFIG_ARCH_TEGRA_124_SOC
 	{
@@ -1365,13 +1400,16 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 		zone->sg = soc->ttgs[i];
 		zone->ts = tegra;
 
+		if (!tegra_soctherm_find_sensor_id(soc->ttgs[i]->id))
+			continue;
+
 		z = devm_thermal_zone_of_sensor_register(&pdev->dev,
 							 soc->ttgs[i]->id, zone,
 							 &tegra_of_thermal_ops);
 		if (IS_ERR(z)) {
 			err = PTR_ERR(z);
-			dev_err(&pdev->dev, "failed to register sensor: %d\n",
-				err);
+			dev_err(&pdev->dev, "failed to register sensor %s: %d\n",
+				soc->ttgs[i]->name, err);
 			goto disable_clocks;
 		}
 
@@ -1434,6 +1472,9 @@ static int __maybe_unused soctherm_resume(struct device *dev)
 		struct thermal_zone_device *tz;
 
 		tz = tegra->thermctl_tzs[soc->ttgs[i]->id];
+		if (!tz)
+			continue;
+
 		err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz);
 		if (err) {
 			dev_err(&pdev->dev,
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH v6 3/4] thermal: tegra: parse sensor id before sensor register

Quoted 60 lines · Wei Ni
Quoted 57 lines · Eduardo Valentin
Quoted 43 lines · Wei Ni

Since different platforms may not support all 4 sensors, so the sensor registration may be failed. Add codes to parse dt to find sensor id which need to be registered. So that the registration can be successful on all platform.

---
 drivers/thermal/tegra/soctherm.c | 45 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +24 -0
index fd2703c0cfc5..6bee31cd4621 100644
@@ -1224,6 +1224,41 @@ static void soctherm_init(struct platform_device *pdev)
 	tegra_soctherm_throttle(&pdev->dev);
 }
 
+static bool tegra_soctherm_find_sensor_id(unsigned int sensor_id)
+{
+	bool ret = false;
+	struct of_phandle_args sensor_specs;
+	struct device_node *np, *sensor_np;
+
+	np = of_find_node_by_name(NULL, "thermal-zones");
+	if (!np)
+		return ret;
+
+	for_each_available_child_of_node(np, sensor_np) {
+		if (of_parse_phandle_with_args(sensor_np, "thermal-sensors",
+						 "#thermal-sensor-cells",
+						 0, &sensor_specs))
+			continue;
+
+		if (sensor_specs.args_count != 1) {
+			WARN(sensor_specs.args_count != 1,
+			     "%s: wrong cells in sensor specifier %d\n",
+			     sensor_specs.np->name, sensor_specs.args_count);
+			continue;
+		}
+
+		if (sensor_specs.args[0] == sensor_id) {

drivers/thermal/tegra/soctherm.c static void soctherm_init(struct platform_device *pdev) · line 1260

Quoted 10 lines
drivers/thermal/tegra/soctherm.c +10 -0
+			of_node_put(sensor_np);
+			ret = true;
+			break;
+		}
+	}
+
+	of_node_put(np);
+
+	return ret;
+}

So, I am still failing to see why this is really needed.

Quoted 8 lines
Quoted 3 lines

Why can't you simply resolve this with different compatibles? If the sensor is not present or disabled, the compatible is not, well, compatible anymore.

This driver can support three Tegra chip t124, t132 and t210. And we also support some platforms for every chips. As the description in the commit, different platforms may not support all 4 sensors, so I upstreamed this patch.

ok.. Which means, all platforms need to have a proper DT that describes the correct amount of sensors.

Quoted 3 lines

If we use different compatibles, I think we can't resolve it simply, because we also need to add codes to configure which platform support which sensors, and may add more in the future. If use this patch, we

There is a very common way of solving this, you can pass .data and grab after calling of_node_match(), just like the tegra soc thermal driver already does.

Quoted 1 line

doesn't need to do any more in the future.

Well, if the patch is needed to add support for different versions of your sensor block, then there is no reason why not patching.

Quoted 3 lines

Actually in my original change, I just ignore the registration failure to fix this issue, it will not affect loading driver, but as Daniel's comment, it's not better to ignore, so I followed his comment to refer

It is not good to ignore. The correct thing to do here is for tegra to have correct DT entries for each sensor block version, to correctly represent the amount of sensors present in the RTL, then you reflect that in device driver using compatible. This way you wont need to ignore failures, and you will support the correct amount of sensors for each block version.

Quoted 2 lines

the QORIQ thermal driver to get the sensor id.

I am not sure that is a good example to follow.

Quoted 40 lines

Thanks.
Wei.

Quoted 37 lines
Quoted 37 lines
drivers/thermal/tegra/soctherm.c +9 -2
+
 static const struct of_device_id tegra_soctherm_of_match[] = {
 #ifdef CONFIG_ARCH_TEGRA_124_SOC
 	{
@@ -1365,13 +1400,16 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 		zone->sg = soc->ttgs[i];
 		zone->ts = tegra;
 
+		if (!tegra_soctherm_find_sensor_id(soc->ttgs[i]->id))
+			continue;
+
 		z = devm_thermal_zone_of_sensor_register(&pdev->dev,
 							 soc->ttgs[i]->id, zone,
 							 &tegra_of_thermal_ops);
 		if (IS_ERR(z)) {
 			err = PTR_ERR(z);
-			dev_err(&pdev->dev, "failed to register sensor: %d\n",
-				err);
+			dev_err(&pdev->dev, "failed to register sensor %s: %d\n",
+				soc->ttgs[i]->name, err);
 			goto disable_clocks;
 		}
 
@@ -1434,6 +1472,9 @@ static int __maybe_unused soctherm_resume(struct device *dev)
 		struct thermal_zone_device *tz;
 
 		tz = tegra->thermctl_tzs[soc->ttgs[i]->id];
+		if (!tz)
+			continue;
+
 		err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz);
 		if (err) {
 			dev_err(&pdev->dev,
Signature · 1 line
2.7.4
author
#9 lore raw

Re: [PATCH v6 3/4] thermal: tegra: parse sensor id before sensor register

Quoted 65 lines · Eduardo Valentin
Quoted 64 lines · Wei Ni
Quoted 60 lines · Eduardo Valentin
Quoted 43 lines · Wei Ni

Since different platforms may not support all 4 sensors, so the sensor registration may be failed. Add codes to parse dt to find sensor id which need to be registered. So that the registration can be successful on all platform.

---
 drivers/thermal/tegra/soctherm.c | 45 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/thermal/tegra/soctherm.c +24 -0
index fd2703c0cfc5..6bee31cd4621 100644
@@ -1224,6 +1224,41 @@ static void soctherm_init(struct platform_device *pdev)
 	tegra_soctherm_throttle(&pdev->dev);
 }
 
+static bool tegra_soctherm_find_sensor_id(unsigned int sensor_id)
+{
+	bool ret = false;
+	struct of_phandle_args sensor_specs;
+	struct device_node *np, *sensor_np;
+
+	np = of_find_node_by_name(NULL, "thermal-zones");
+	if (!np)
+		return ret;
+
+	for_each_available_child_of_node(np, sensor_np) {
+		if (of_parse_phandle_with_args(sensor_np, "thermal-sensors",
+						 "#thermal-sensor-cells",
+						 0, &sensor_specs))
+			continue;
+
+		if (sensor_specs.args_count != 1) {
+			WARN(sensor_specs.args_count != 1,
+			     "%s: wrong cells in sensor specifier %d\n",
+			     sensor_specs.np->name, sensor_specs.args_count);
+			continue;
+		}
+
+		if (sensor_specs.args[0] == sensor_id) {

drivers/thermal/tegra/soctherm.c static void soctherm_init(struct platform_device *pdev) · line 1260

Quoted 10 lines
drivers/thermal/tegra/soctherm.c +10 -0
+			of_node_put(sensor_np);
+			ret = true;
+			break;
+		}
+	}
+
+	of_node_put(np);
+
+	return ret;
+}

So, I am still failing to see why this is really needed.

Why can't you simply resolve this with different compatibles? If the sensor is not present or disabled, the compatible is not, well, compatible anymore.

Quoted 7 lines
Quoted 4 lines

This driver can support three Tegra chip t124, t132 and t210. And we also support some platforms for every chips. As the description in the commit, different platforms may not support all 4 sensors, so I upstreamed this patch.

ok.. Which means, all platforms need to have a proper DT that describes the correct amount of sensors.

Thanks for your comments.
I thought about it carefully again, and found we doesn't need to change any codes for this issue.
In the DT, actually the node "thermal-zones{} already describes the correct sensors, so we doesn't need to add more changes in DT.

Quoted 8 lines
Quoted 4 lines

If we use different compatibles, I think we can't resolve it simply, because we also need to add codes to configure which platform support which sensors, and may add more in the future. If use this patch, we

There is a very common way of solving this, you can pass .data and grab after calling of_node_match(), just like the tegra soc thermal driver already does.

Yes, for the driver, we just need to add a new file, something like tegra210-soctherm.c, to configure a new platform, which can remove the configuration for the disabled sensor, so that the soctherm driver will not try to register that sensors anymore.

Quoted 5 lines
Quoted 2 lines

doesn't need to do any more in the future.

Well, if the patch is needed to add support for different versions of your sensor block, then there is no reason why not patching.

Since in current released platforms, they support all 4 sensors, so I will not send new patches by now.

So please ignore this change.
And will you take other 3 changes?

Thanks.
Wei.

Quoted 57 lines
Quoted 4 lines

Actually in my original change, I just ignore the registration failure to fix this issue, it will not affect loading driver, but as Daniel's comment, it's not better to ignore, so I followed his comment to refer

It is not good to ignore. The correct thing to do here is for tegra to have correct DT entries for each sensor block version, to correctly represent the amount of sensors present in the RTL, then you reflect that in device driver using compatible. This way you wont need to ignore failures, and you will support the correct amount of sensors for each block version.

Quoted 2 lines

the QORIQ thermal driver to get the sensor id.

I am not sure that is a good example to follow.

Quoted 40 lines

Thanks.
Wei.

Quoted 37 lines
Quoted 37 lines
drivers/thermal/tegra/soctherm.c +9 -2
+
 static const struct of_device_id tegra_soctherm_of_match[] = {
 #ifdef CONFIG_ARCH_TEGRA_124_SOC
 	{
@@ -1365,13 +1400,16 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 		zone->sg = soc->ttgs[i];
 		zone->ts = tegra;
 
+		if (!tegra_soctherm_find_sensor_id(soc->ttgs[i]->id))
+			continue;
+
 		z = devm_thermal_zone_of_sensor_register(&pdev->dev,
 							 soc->ttgs[i]->id, zone,
 							 &tegra_of_thermal_ops);
 		if (IS_ERR(z)) {
 			err = PTR_ERR(z);
-			dev_err(&pdev->dev, "failed to register sensor: %d\n",
-				err);
+			dev_err(&pdev->dev, "failed to register sensor %s: %d\n",
+				soc->ttgs[i]->name, err);
 			goto disable_clocks;
 		}
 
@@ -1434,6 +1472,9 @@ static int __maybe_unused soctherm_resume(struct device *dev)
 		struct thermal_zone_device *tz;
 
 		tz = tegra->thermctl_tzs[soc->ttgs[i]->id];
+		if (!tz)
+			continue;
+
 		err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz);
 		if (err) {
 			dev_err(&pdev->dev,
Signature · 1 line
2.7.4
author
#10 lore raw

PATCH v6 4/4 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 6bee31cd4621..330bffd38fdd 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
Acked-by on v6 4/4
#11 lore raw

Re: [PATCH v6 4/4] thermal: tegra: add get_trend ops

Quoted 7 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(+)
author
#12 lore raw
In reply to Wei Ni

Hi Rui,
I moved get_trend() patch https://lkml.org/lkml/2018/11/20/643 in this serial.
Since no more comments on these patches, will you take them?

Thanks.
Wei.

Quoted 33 lines · Wei Ni

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

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 (4):
thermal: tegra: remove unnecessary warnings
thermal: tegra: fix memory allocation
thermal: tegra: parse sensor id before sensor register
thermal: tegra: add get_trend ops

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

Hi Rui,
I moved get_trend() patch https://lkml.org/lkml/2018/11/20/643 in this
serial.
Since no more comments on these patches, will you take them?

I think Eduardo will take care of this patch series.

thanks,
rui

Quoted 39 lines

Thanks.
Wei.

Quoted 35 lines · Wei Ni

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

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 (4):
  thermal: tegra: remove unnecessary warnings
  thermal: tegra: fix memory allocation
  thermal: tegra: parse sensor id before sensor register
  thermal: tegra: add get_trend ops

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

 1 file changed, 80 insertions(+), 5 deletions(-)
#14 lore raw
Quoted 8 lines · Zhang Rui
Quoted 6 lines · Wei Ni

Hi Rui,
I moved get_trend() patch https://lkml.org/lkml/2018/11/20/643 in this
serial.
Since no more comments on these patches, will you take them?

I think Eduardo will take care of this patch series.

Yes, I will take a look on this series.

But, please, next time you send a series of patches on thermal, copy the [email protected] mailing list. This way we can track your patches on patchwork.

Quoted 42 lines

thanks,
rui

Quoted 39 lines

Thanks.
Wei.

Quoted 35 lines · Wei Ni

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

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 (4):
  thermal: tegra: remove unnecessary warnings
  thermal: tegra: fix memory allocation
  thermal: tegra: parse sensor id before sensor register
  thermal: tegra: add get_trend ops

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

 1 file changed, 80 insertions(+), 5 deletions(-)
author
#15 lore raw
Quoted 8 lines · Eduardo Valentin
Quoted 7 lines · Zhang Rui
Quoted 6 lines · Wei Ni

Hi Rui,
I moved get_trend() patch https://lkml.org/lkml/2018/11/20/643 in this
serial.
Since no more comments on these patches, will you take them?

Quoted 7 lines
Quoted 1 line

I think Eduardo will take care of this patch series.

Yes, I will take a look on this series.

But, please, next time you send a series of patches on thermal, copy the [email protected] mailing list. This way we can track your patches on patchwork.

Sure, will do it.

Thanks.
Wei.

Quoted 43 lines
Quoted 43 lines

thanks,
rui

Quoted 39 lines

Thanks.
Wei.

Quoted 35 lines · Wei Ni

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

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 (4):
  thermal: tegra: remove unnecessary warnings
  thermal: tegra: fix memory allocation
  thermal: tegra: parse sensor id before sensor register
  thermal: tegra: add get_trend ops

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

 1 file changed, 80 insertions(+), 5 deletions(-)