[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7b3adc62-2bb5-97c7-c4ee-0df61968db29@linaro.org>
Date: Thu, 2 Mar 2023 11:00:48 +0100
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: Thierry Reding <thierry.reding@...il.com>
Cc: rafael@...nel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Jonathan Hunter <jonathanh@...dia.com>,
Niklas Söderlund
<niklas.soderlund+renesas@...natech.se>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Florian Fainelli <f.fainelli@...il.com>,
Jernej Skrabec <jernej.skrabec@...il.com>,
"open list:TEGRA ARCHITECTURE SUPPORT" <linux-tegra@...r.kernel.org>
Subject: Re: [PATCH v5 16/18] thermal/drivers/tegra: Remove unneeded lock when
setting a trip point
On 02/03/2023 10:47, Thierry Reding wrote:
> On Wed, Mar 01, 2023 at 09:14:44PM +0100, Daniel Lezcano wrote:
>> The function tegra_tsensor_enable_hw_channel() takes the thermal zone
>> lock to prevent "a potential" race with a call to set_trips()
>> callback.
>>
>> The driver must not play with the thermal framework core code
>> internals.
>>
>> The tegra_tsensor_enable_hw_channel() is called by:
>>
>> - the suspend / resume callbacks
>> - the probe function after the thermal zones are registered
>>
>> The thermal zone lock taken in this function is supposed to protect
>> from a call to the set_trips() callback which writes in the same
>> register.
>>
>> The potential race is when suspend / resume are called at the same
>> time as set_trips. This one is called only in
>> thermal_zone_device_update().
>>
>> - At suspend time, the 'in_suspend' is set, thus the
>> thermal_zone_device_update() bails out immediately and set_trips is
>> not called during this moment.
>>
>> - At resume time, the thermal zone is updated at PM_POST_SUSPEND,
>> thus the driver has already set the TH2 temperature.
>>
>> - At probe time, we register the thermal zone and then we set the
>> TH2. The only scenario I can see so far is the interrupt fires, the
>> thermal_zone_update() is called exactly at the moment
>> tegra_tsensor_enable_hw_channel() a few lines after registering it.
>>
>> Enable the channels before setting up the interrupt. We close the
>> potential race window without using the thermal zone's lock.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.org>
>> Suggested-by: Thierry Reding <thierry.reding@...il.com>
>> ---
>> drivers/thermal/tegra/tegra30-tsensor.c | 25 ++++++++++++++-----------
>> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> Acked-by: Thierry Reding <treding@...dia.com>
Thanks for your review
May I ask you to have a look at patch 2 and 8 ?
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
Powered by blists - more mailing lists