[PATCH] thermal/core: Fix lockdep_assert() warning

Daniel Lezcano posted 1 patch 3 years, 8 months ago
drivers/thermal/thermal_core.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH] thermal/core: Fix lockdep_assert() warning
Posted by Daniel Lezcano 3 years, 8 months ago
The function thermal_zone_device_is_enabled() must be called with the
thermal zone lock held. In the resume path, it is called without.

As the thermal_zone_device_is_enabled() is also checked in
thermal_zone_device_update(), do the check in resume() function is
pointless, except for saving an extra initialization which does not
hurt if it is done in all the cases.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/thermal_core.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 50814009339d..dc8ff6a84df1 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1438,9 +1438,6 @@ static int thermal_pm_notify(struct notifier_block *nb,
 	case PM_POST_SUSPEND:
 		atomic_set(&in_suspend, 0);
 		list_for_each_entry(tz, &thermal_tz_list, node) {
-			if (!thermal_zone_device_is_enabled(tz))
-				continue;
-
 			thermal_zone_device_init(tz);
 			thermal_zone_device_update(tz,
 						   THERMAL_EVENT_UNSPECIFIED);
-- 
2.34.1
Re: [PATCH] thermal/core: Fix lockdep_assert() warning
Posted by Marek Szyprowski 3 years, 8 months ago
On 12.08.2022 15:12, Daniel Lezcano wrote:
> The function thermal_zone_device_is_enabled() must be called with the
> thermal zone lock held. In the resume path, it is called without.
>
> As the thermal_zone_device_is_enabled() is also checked in
> thermal_zone_device_update(), do the check in resume() function is
> pointless, except for saving an extra initialization which does not
> hurt if it is done in all the cases.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

This fixes the warning I've reported. Feel free to add:

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   drivers/thermal/thermal_core.c | 3 ---
>   1 file changed, 3 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 50814009339d..dc8ff6a84df1 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1438,9 +1438,6 @@ static int thermal_pm_notify(struct notifier_block *nb,
>   	case PM_POST_SUSPEND:
>   		atomic_set(&in_suspend, 0);
>   		list_for_each_entry(tz, &thermal_tz_list, node) {
> -			if (!thermal_zone_device_is_enabled(tz))
> -				continue;
> -
>   			thermal_zone_device_init(tz);
>   			thermal_zone_device_update(tz,
>   						   THERMAL_EVENT_UNSPECIFIED);

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland
Re: [PATCH] thermal/core: Fix lockdep_assert() warning
Posted by Daniel Lezcano 3 years, 8 months ago
On 12/08/2022 15:34, Marek Szyprowski wrote:
> On 12.08.2022 15:12, Daniel Lezcano wrote:
>> The function thermal_zone_device_is_enabled() must be called with the
>> thermal zone lock held. In the resume path, it is called without.
>>
>> As the thermal_zone_device_is_enabled() is also checked in
>> thermal_zone_device_update(), do the check in resume() function is
>> pointless, except for saving an extra initialization which does not
>> hurt if it is done in all the cases.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
> This fixes the warning I've reported. Feel free to add:
> 
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

Great, thanks for testing


-- 
<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
Re: [PATCH] thermal/core: Fix lockdep_assert() warning
Posted by Rafael J. Wysocki 3 years, 7 months ago
On Fri, Aug 12, 2022 at 3:54 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> On 12/08/2022 15:34, Marek Szyprowski wrote:
> > On 12.08.2022 15:12, Daniel Lezcano wrote:
> >> The function thermal_zone_device_is_enabled() must be called with the
> >> thermal zone lock held. In the resume path, it is called without.
> >>
> >> As the thermal_zone_device_is_enabled() is also checked in
> >> thermal_zone_device_update(), do the check in resume() function is
> >> pointless, except for saving an extra initialization which does not
> >> hurt if it is done in all the cases.
> >>
> >> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> >
> > This fixes the warning I've reported. Feel free to add:
> >
> > Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> >
> > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
>
> Great, thanks for testing

Do you want me to apply this for -rc3?