Linux Tegra architecture development
 help / color / mirror / Atom feed
* [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
@ 2022-11-29 15:39 Mikko Perttunen
  2023-01-26 14:52 ` Thierry Reding
  0 siblings, 1 reply; 9+ messages in thread
From: Mikko Perttunen @ 2022-11-29 15:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
  Cc: Mikko Perttunen, Thierry Reding, Jonathan Hunter, linux-pm,
	linux-tegra

From: Mikko Perttunen <mperttunen@nvidia.com>

Check if BPMP supports thermal trip points, and if not,
do not expose the .set_trips callback to the thermal core
framework. This can happen in virtualized environments
where asynchronous communication with VM BPMP drivers is not
available.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
 drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 +++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/tegra/tegra-bpmp-thermal.c b/drivers/thermal/tegra/tegra-bpmp-thermal.c
index 0b7a1a1948cb..c76e1ea62c8a 100644
--- a/drivers/thermal/tegra/tegra-bpmp-thermal.c
+++ b/drivers/thermal/tegra/tegra-bpmp-thermal.c
@@ -163,19 +163,69 @@ static int tegra_bpmp_thermal_get_num_zones(struct tegra_bpmp *bpmp,
 	return 0;
 }
 
+static int tegra_bpmp_thermal_trips_supported(struct tegra_bpmp *bpmp, bool *supported)
+{
+	struct mrq_thermal_host_to_bpmp_request req;
+	union mrq_thermal_bpmp_to_host_response reply;
+	struct tegra_bpmp_message msg;
+	int err;
+
+	memset(&req, 0, sizeof(req));
+	req.type = CMD_THERMAL_QUERY_ABI;
+	req.query_abi.type = CMD_THERMAL_SET_TRIP;
+
+	memset(&msg, 0, sizeof(msg));
+	msg.mrq = MRQ_THERMAL;
+	msg.tx.data = &req;
+	msg.tx.size = sizeof(req);
+	msg.rx.data = &reply;
+	msg.rx.size = sizeof(reply);
+
+	err = tegra_bpmp_transfer(bpmp, &msg);
+	if (err)
+		return err;
+
+	if (msg.rx.ret == 0) {
+		*supported = true;
+		return 0;
+	} else if (msg.rx.ret == -BPMP_ENODEV) {
+		*supported = false;
+		return 0;
+	} else {
+		return -EINVAL;
+	}
+}
+
 static const struct thermal_zone_device_ops tegra_bpmp_of_thermal_ops = {
 	.get_temp = tegra_bpmp_thermal_get_temp,
 	.set_trips = tegra_bpmp_thermal_set_trips,
 };
 
+static const struct thermal_zone_device_ops tegra_bpmp_of_thermal_ops_notrips = {
+	.get_temp = tegra_bpmp_thermal_get_temp,
+};
+
 static int tegra_bpmp_thermal_probe(struct platform_device *pdev)
 {
 	struct tegra_bpmp *bpmp = dev_get_drvdata(pdev->dev.parent);
+	const struct thermal_zone_device_ops *thermal_ops;
 	struct tegra_bpmp_thermal *tegra;
 	struct thermal_zone_device *tzd;
 	unsigned int i, max_num_zones;
+	bool supported;
 	int err;
 
+	err = tegra_bpmp_thermal_trips_supported(bpmp, &supported);
+	if (err) {
+		dev_err(&pdev->dev, "failed to determine if trip points are supported\n");
+		return err;
+	}
+
+	if (supported)
+		thermal_ops = &tegra_bpmp_of_thermal_ops;
+	else
+		thermal_ops = &tegra_bpmp_of_thermal_ops_notrips;
+
 	tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL);
 	if (!tegra)
 		return -ENOMEM;
@@ -213,7 +263,7 @@ static int tegra_bpmp_thermal_probe(struct platform_device *pdev)
 		}
 
 		tzd = devm_thermal_of_zone_register(
-			&pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops);
+			&pdev->dev, i, zone, thermal_ops);
 		if (IS_ERR(tzd)) {
 			if (PTR_ERR(tzd) == -EPROBE_DEFER)
 				return -EPROBE_DEFER;
-- 
2.37.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2022-11-29 15:39 [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points Mikko Perttunen
@ 2023-01-26 14:52 ` Thierry Reding
  2023-01-26 15:08   ` Daniel Lezcano
  0 siblings, 1 reply; 9+ messages in thread
From: Thierry Reding @ 2023-01-26 14:52 UTC (permalink / raw)
  To: Mikko Perttunen
  Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
	Mikko Perttunen, Jonathan Hunter, linux-pm, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
> From: Mikko Perttunen <mperttunen@nvidia.com>
> 
> Check if BPMP supports thermal trip points, and if not,
> do not expose the .set_trips callback to the thermal core
> framework. This can happen in virtualized environments
> where asynchronous communication with VM BPMP drivers is not
> available.
> 
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
>  drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 +++++++++++++++++++++-
>  1 file changed, 51 insertions(+), 1 deletion(-)

Applied, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2023-01-26 14:52 ` Thierry Reding
@ 2023-01-26 15:08   ` Daniel Lezcano
  2023-01-26 15:42     ` Thierry Reding
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2023-01-26 15:08 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen
  Cc: Rafael J. Wysocki, Amit Kucheria, Zhang Rui, Mikko Perttunen,
	Jonathan Hunter, linux-pm, linux-tegra


Hi Thierry,

On 26/01/2023 15:52, Thierry Reding wrote:
> On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
>> From: Mikko Perttunen <mperttunen@nvidia.com>
>>
>> Check if BPMP supports thermal trip points, and if not,
>> do not expose the .set_trips callback to the thermal core
>> framework. This can happen in virtualized environments
>> where asynchronous communication with VM BPMP drivers is not
>> available.
>>
>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>> ---
>>   drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 +++++++++++++++++++++-
>>   1 file changed, 51 insertions(+), 1 deletion(-)
> 
> Applied, thanks.

I prefer you provide an Acked-by and I take the thermal related patches. 
Especially in this period where we are reworking the framework with the 
thermal trip points ;)

Thanks
   -- Daniel

-- 
<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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2023-01-26 15:08   ` Daniel Lezcano
@ 2023-01-26 15:42     ` Thierry Reding
  2023-01-26 16:07       ` Daniel Lezcano
  0 siblings, 1 reply; 9+ messages in thread
From: Thierry Reding @ 2023-01-26 15:42 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Mikko Perttunen, Rafael J. Wysocki, Amit Kucheria, Zhang Rui,
	Mikko Perttunen, Jonathan Hunter, linux-pm, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

On Thu, Jan 26, 2023 at 04:08:03PM +0100, Daniel Lezcano wrote:
> 
> Hi Thierry,
> 
> On 26/01/2023 15:52, Thierry Reding wrote:
> > On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
> > > From: Mikko Perttunen <mperttunen@nvidia.com>
> > > 
> > > Check if BPMP supports thermal trip points, and if not,
> > > do not expose the .set_trips callback to the thermal core
> > > framework. This can happen in virtualized environments
> > > where asynchronous communication with VM BPMP drivers is not
> > > available.
> > > 
> > > Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> > > ---
> > >   drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 +++++++++++++++++++++-
> > >   1 file changed, 51 insertions(+), 1 deletion(-)
> > 
> > Applied, thanks.
> 
> I prefer you provide an Acked-by and I take the thermal related patches.
> Especially in this period where we are reworking the framework with the
> thermal trip points ;)

Sorry, my bad. I misread this as belonging to drivers/firmware/tegra
which goes in via ARM SoC. I'll drop this from the Tegra tree. Feel free
to pick this up:

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2023-01-26 15:42     ` Thierry Reding
@ 2023-01-26 16:07       ` Daniel Lezcano
  2023-04-03 10:22         ` Jon Hunter
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2023-01-26 16:07 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Mikko Perttunen, Rafael J. Wysocki, Amit Kucheria, Zhang Rui,
	Mikko Perttunen, Jonathan Hunter, linux-pm, linux-tegra

On 26/01/2023 16:42, Thierry Reding wrote:
> On Thu, Jan 26, 2023 at 04:08:03PM +0100, Daniel Lezcano wrote:
>>
>> Hi Thierry,
>>
>> On 26/01/2023 15:52, Thierry Reding wrote:
>>> On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
>>>> From: Mikko Perttunen <mperttunen@nvidia.com>
>>>>
>>>> Check if BPMP supports thermal trip points, and if not,
>>>> do not expose the .set_trips callback to the thermal core
>>>> framework. This can happen in virtualized environments
>>>> where asynchronous communication with VM BPMP drivers is not
>>>> available.
>>>>
>>>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>>>> ---
>>>>    drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 +++++++++++++++++++++-
>>>>    1 file changed, 51 insertions(+), 1 deletion(-)
>>>
>>> Applied, thanks.
>>
>> I prefer you provide an Acked-by and I take the thermal related patches.
>> Especially in this period where we are reworking the framework with the
>> thermal trip points ;)
> 
> Sorry, my bad. I misread this as belonging to drivers/firmware/tegra
> which goes in via ARM SoC.

No worries ;)

> I'll drop this from the Tegra tree. Feel free
> to pick this up:

Ok, thanks

> Acked-by: Thierry Reding <treding@nvidia.com>



-- 
<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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2023-01-26 16:07       ` Daniel Lezcano
@ 2023-04-03 10:22         ` Jon Hunter
  2023-04-03 10:26           ` Daniel Lezcano
  0 siblings, 1 reply; 9+ messages in thread
From: Jon Hunter @ 2023-04-03 10:22 UTC (permalink / raw)
  To: Daniel Lezcano, Thierry Reding
  Cc: Mikko Perttunen, Rafael J. Wysocki, Amit Kucheria, Zhang Rui,
	Mikko Perttunen, linux-pm, linux-tegra

Hi Daniel,

On 26/01/2023 16:07, Daniel Lezcano wrote:
> On 26/01/2023 16:42, Thierry Reding wrote:
>> On Thu, Jan 26, 2023 at 04:08:03PM +0100, Daniel Lezcano wrote:
>>>
>>> Hi Thierry,
>>>
>>> On 26/01/2023 15:52, Thierry Reding wrote:
>>>> On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
>>>>> From: Mikko Perttunen <mperttunen@nvidia.com>
>>>>>
>>>>> Check if BPMP supports thermal trip points, and if not,
>>>>> do not expose the .set_trips callback to the thermal core
>>>>> framework. This can happen in virtualized environments
>>>>> where asynchronous communication with VM BPMP drivers is not
>>>>> available.
>>>>>
>>>>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>>>>> ---
>>>>>    drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 
>>>>> +++++++++++++++++++++-
>>>>>    1 file changed, 51 insertions(+), 1 deletion(-)
>>>>
>>>> Applied, thanks.
>>>
>>> I prefer you provide an Acked-by and I take the thermal related patches.
>>> Especially in this period where we are reworking the framework with the
>>> thermal trip points ;)
>>
>> Sorry, my bad. I misread this as belonging to drivers/firmware/tegra
>> which goes in via ARM SoC.
> 
> No worries ;)
> 
>> I'll drop this from the Tegra tree. Feel free
>> to pick this up:
> 
> Ok, thanks
> 
>> Acked-by: Thierry Reding <treding@nvidia.com>


I don't see this one in -next. Are you able to pick this one up now?

Thanks!
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2023-04-03 10:22         ` Jon Hunter
@ 2023-04-03 10:26           ` Daniel Lezcano
  2023-08-21 10:08             ` Mikko Perttunen
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2023-04-03 10:26 UTC (permalink / raw)
  To: Jon Hunter, Thierry Reding
  Cc: Mikko Perttunen, Rafael J. Wysocki, Amit Kucheria, Zhang Rui,
	Mikko Perttunen, linux-pm, linux-tegra

On 03/04/2023 12:22, Jon Hunter wrote:
> Hi Daniel,
> 
> On 26/01/2023 16:07, Daniel Lezcano wrote:
>> On 26/01/2023 16:42, Thierry Reding wrote:
>>> On Thu, Jan 26, 2023 at 04:08:03PM +0100, Daniel Lezcano wrote:
>>>>
>>>> Hi Thierry,
>>>>
>>>> On 26/01/2023 15:52, Thierry Reding wrote:
>>>>> On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
>>>>>> From: Mikko Perttunen <mperttunen@nvidia.com>
>>>>>>
>>>>>> Check if BPMP supports thermal trip points, and if not,
>>>>>> do not expose the .set_trips callback to the thermal core
>>>>>> framework. This can happen in virtualized environments
>>>>>> where asynchronous communication with VM BPMP drivers is not
>>>>>> available.
>>>>>>
>>>>>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>>>>>> ---
>>>>>>    drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 
>>>>>> +++++++++++++++++++++-
>>>>>>    1 file changed, 51 insertions(+), 1 deletion(-)
>>>>>
>>>>> Applied, thanks.
>>>>
>>>> I prefer you provide an Acked-by and I take the thermal related 
>>>> patches.
>>>> Especially in this period where we are reworking the framework with the
>>>> thermal trip points ;)
>>>
>>> Sorry, my bad. I misread this as belonging to drivers/firmware/tegra
>>> which goes in via ARM SoC.
>>
>> No worries ;)
>>
>>> I'll drop this from the Tegra tree. Feel free
>>> to pick this up:
>>
>> Ok, thanks
>>
>>> Acked-by: Thierry Reding <treding@nvidia.com>
> 
> 
> I don't see this one in -next. Are you able to pick this one up now?

Before going in -next, it will go through bleeding-edge then -next, 
logically tomorrow.


-- 
<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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2023-04-03 10:26           ` Daniel Lezcano
@ 2023-08-21 10:08             ` Mikko Perttunen
  2023-08-23  7:50               ` Daniel Lezcano
  0 siblings, 1 reply; 9+ messages in thread
From: Mikko Perttunen @ 2023-08-21 10:08 UTC (permalink / raw)
  To: Daniel Lezcano, Jon Hunter, Thierry Reding
  Cc: Rafael J. Wysocki, Amit Kucheria, Zhang Rui, Mikko Perttunen,
	linux-pm, linux-tegra

On 4/3/23 13:26, Daniel Lezcano wrote:
> On 03/04/2023 12:22, Jon Hunter wrote:
>> Hi Daniel,
>>
>> On 26/01/2023 16:07, Daniel Lezcano wrote:
>>> On 26/01/2023 16:42, Thierry Reding wrote:
>>>> On Thu, Jan 26, 2023 at 04:08:03PM +0100, Daniel Lezcano wrote:
>>>>>
>>>>> Hi Thierry,
>>>>>
>>>>> On 26/01/2023 15:52, Thierry Reding wrote:
>>>>>> On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
>>>>>>> From: Mikko Perttunen <mperttunen@nvidia.com>
>>>>>>>
>>>>>>> Check if BPMP supports thermal trip points, and if not,
>>>>>>> do not expose the .set_trips callback to the thermal core
>>>>>>> framework. This can happen in virtualized environments
>>>>>>> where asynchronous communication with VM BPMP drivers is not
>>>>>>> available.
>>>>>>>
>>>>>>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>>>>>>> ---
>>>>>>>    drivers/thermal/tegra/tegra-bpmp-thermal.c | 52 
>>>>>>> +++++++++++++++++++++-
>>>>>>>    1 file changed, 51 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> Applied, thanks.
>>>>>
>>>>> I prefer you provide an Acked-by and I take the thermal related 
>>>>> patches.
>>>>> Especially in this period where we are reworking the framework with 
>>>>> the
>>>>> thermal trip points ;)
>>>>
>>>> Sorry, my bad. I misread this as belonging to drivers/firmware/tegra
>>>> which goes in via ARM SoC.
>>>
>>> No worries ;)
>>>
>>>> I'll drop this from the Tegra tree. Feel free
>>>> to pick this up:
>>>
>>> Ok, thanks
>>>
>>>> Acked-by: Thierry Reding <treding@nvidia.com>
>>
>>
>> I don't see this one in -next. Are you able to pick this one up now?
> 
> Before going in -next, it will go through bleeding-edge then -next, 
> logically tomorrow.
> 
> 

Hi, still not seeing this in -next.

Cheers,
Mikko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points
  2023-08-21 10:08             ` Mikko Perttunen
@ 2023-08-23  7:50               ` Daniel Lezcano
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2023-08-23  7:50 UTC (permalink / raw)
  To: Mikko Perttunen, Jon Hunter, Thierry Reding
  Cc: Rafael J. Wysocki, Amit Kucheria, Zhang Rui, Mikko Perttunen,
	linux-pm, linux-tegra

On 21/08/2023 12:08, Mikko Perttunen wrote:
> On 4/3/23 13:26, Daniel Lezcano wrote:
>> On 03/04/2023 12:22, Jon Hunter wrote:
>>> Hi Daniel,
>>>
>>> On 26/01/2023 16:07, Daniel Lezcano wrote:
>>>> On 26/01/2023 16:42, Thierry Reding wrote:
>>>>> On Thu, Jan 26, 2023 at 04:08:03PM +0100, Daniel Lezcano wrote:
>>>>>>
>>>>>> Hi Thierry,
>>>>>>
>>>>>> On 26/01/2023 15:52, Thierry Reding wrote:
>>>>>>> On Tue, Nov 29, 2022 at 05:39:14PM +0200, Mikko Perttunen wrote:
>>>>>>>> From: Mikko Perttunen <mperttunen@nvidia.com>
>>>>>>>>
>>>>>>>> Check if BPMP supports thermal trip points, and if not,
>>>>>>>> do not expose the .set_trips callback to the thermal core
>>>>>>>> framework. This can happen in virtualized environments
>>>>>>>> where asynchronous communication with VM BPMP drivers is not
>>>>>>>> available.
>>>>>>>>
>>>>>>>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>>>>>>>> ---

Thanks for the head up, that should be fixed now.



-- 
<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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-08-23  7:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29 15:39 [PATCH] thermal: tegra-bpmp: Check if BPMP supports trip points Mikko Perttunen
2023-01-26 14:52 ` Thierry Reding
2023-01-26 15:08   ` Daniel Lezcano
2023-01-26 15:42     ` Thierry Reding
2023-01-26 16:07       ` Daniel Lezcano
2023-04-03 10:22         ` Jon Hunter
2023-04-03 10:26           ` Daniel Lezcano
2023-08-21 10:08             ` Mikko Perttunen
2023-08-23  7:50               ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox