From: Mikko Perttunen <cyndis@kapsi.fi>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Srikar Srimath Tirumala <srikars@nvidia.com>,
Mikko Perttunen <mperttunen@nvidia.com>,
Timo Alho <talho@nvidia.com>,
linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] thermal: tegra-bpmp: Always (re)program trip temperatures
Date: Wed, 8 Feb 2023 17:35:22 +0200 [thread overview]
Message-ID: <d6a2a1d5-fc3b-2510-e5e8-e3f36f1652d5@kapsi.fi> (raw)
In-Reply-To: <Y+N8uMO3V5+YNm2E@orome>
On 2/8/23 12:43, Thierry Reding wrote:
> On Tue, Feb 07, 2023 at 03:56:09PM +0200, Mikko Perttunen wrote:
>> From: Mikko Perttunen <mperttunen@nvidia.com>
>>
>> In the rare case that calculation of trip temperatures would result
>> in the same trip temperatures that were previously programmed, the
>> thermal core skips calling .set_trips.
>
> That seems like an appropriate optimization.
>
>> However, presently, if it is not called, we may end up with no trip
>> temperatures programmed at all.
>
> I have a hard time understanding when this would happen. prev_low_trip
> and prev_high_trip are -INT_MAX and INT_MAX, respectively, so these are
> unlikely to be the result of anything we compute at runtime, based on
> temperatures specified in DT, for example.
Consider:
Temperature is 45C.
set_trips is called with low=40C high=50C. We program accordingly.
Temperature goes to 55C. Trip point triggers.
Before execution gets to CPU, temperature returns to 45C.
CPU gets the MRQ, calls into thermal core to update.
Thermal core notices that temperature is 45C and sets again the same
low=40C high=50C trip points, does not call set_trips.
No trip point is programmed to BPMP and we never get trips again.
The above, of course, is rather unlikely to happen, but theoretically
possible nevertheless.
Alternatively, where I discovered the issue originally, was the issue
described in the last paragraph of the commit message; see below.
>
> So I would expect ->set_trips() to get called at least once when the
> thermal zones are first registered. Are you saying there are cases where
> ->set_trips() doesn't get called at all?
No, not saying that. It will get called when registering the zone
initially, but see below.
>
>> To avoid this, make set_trips a no-op and in places where it would be
>> called, instead unconditionally program trip temperatures to the last
>> specified temperatures.
>
> Again, this seems more like a workaround for an issue that exists
> elsewhere. If ->set_trips() doesn't always get called when it should be,
> then that's what we should fix.
I think it depends on what the interpretation is with set_trips. If the
interpretation is that the the trips configured in the hardware are
persistent (not disabled when a trip occurs), then the current
implementation and this patch make sense. Otherwise a change in the
thermal core would make sense.
>
>> This also fixes the situation where a trip is triggered between
>> registering a thermal zone and registering the trip MRQ handler, in
>> which case we would also get stuck.
>
> Could this be fixed by requesting the MRQ prior to registering the
> zones? That seems like the more appropriate fix for this issue. It's
> similar to how we typically register IRQ handlers before enabling a
> device to make sure we don't miss any interrupts.
I considered that -- there are two reasons I didn't go for it:
1. It doesn't solve the race condition described in the first part of
the message
2. To handle the incoming MRQ, zone->tzd needs to be set. But we only
get tzd from the zone registration call, and already before that call
returns, set_trips has been called and we might have received an MRQ. I
tested using a completion object to block in the MRQ handler until the
initialization completes, but that's pretty ugly as well.
>
> Thierry
Thanks,
Mikko
next prev parent reply other threads:[~2023-02-08 15:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 13:56 [PATCH 1/2] thermal: tegra-bpmp: Handle offline zones Mikko Perttunen
2023-02-07 13:56 ` [PATCH 2/2] thermal: tegra-bpmp: Always (re)program trip temperatures Mikko Perttunen
2023-02-08 10:43 ` Thierry Reding
2023-02-08 15:35 ` Mikko Perttunen [this message]
2023-02-08 16:02 ` Thierry Reding
2023-02-08 10:31 ` [PATCH 1/2] thermal: tegra-bpmp: Handle offline zones Thierry Reding
2023-02-08 15:35 ` Mikko Perttunen
2023-02-08 16:05 ` Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d6a2a1d5-fc3b-2510-e5e8-e3f36f1652d5@kapsi.fi \
--to=cyndis@kapsi.fi \
--cc=amitk@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mperttunen@nvidia.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=srikars@nvidia.com \
--cc=talho@nvidia.com \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®