Skip to content

Commit

Permalink
thermal: core: Drop excessive lockdep_assert_held() calls
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/2042697

The lockdep_assert_held() calls added to cooling_device_stats_setup()
and cooling_device_stats_destroy() by commit 790930f ("thermal:
core: Introduce thermal_cooling_device_update()") trigger false-positive
lockdep reports in code paths that are not subject to race conditions
(before cooling device registration and after cooling device removal).

For this reason, remove the lockdep_assert_held() calls from both
cooling_device_stats_setup() and cooling_device_stats_destroy() and
add one to thermal_cooling_device_stats_reinit() that has to be called
under the cdev lock.

Fixes: 790930f ("thermal: core: Introduce thermal_cooling_device_update()")
Link: https://lore.kernel.org/linux-acpi/[email protected]
Reported-by: Imre Deak <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
(cherry picked from commit b57841f)
Acked-by: Jamie Nguyen <[email protected]>
Acked-by: Brad Figg <[email protected]>
Acked-by: Ian May <[email protected]>
Acked-by: Jacob Martin <[email protected]>
  • Loading branch information
rafaeljw authored and nvidia-bfigg committed Nov 6, 2023
1 parent d7f80ef commit 89cf480
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/thermal/thermal_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,6 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)
unsigned long states = cdev->max_state + 1;
int var;

lockdep_assert_held(&cdev->lock);

var = sizeof(*stats);
var += sizeof(*stats->time_in_state) * states;
var += sizeof(*stats->trans_table) * states * states;
Expand All @@ -950,8 +948,6 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)

static void cooling_device_stats_destroy(struct thermal_cooling_device *cdev)
{
lockdep_assert_held(&cdev->lock);

kfree(cdev->stats);
cdev->stats = NULL;
}
Expand All @@ -978,6 +974,8 @@ void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev)

void thermal_cooling_device_stats_reinit(struct thermal_cooling_device *cdev)
{
lockdep_assert_held(&cdev->lock);

cooling_device_stats_destroy(cdev);
cooling_device_stats_setup(cdev);
}
Expand Down

0 comments on commit 89cf480

Please sign in to comment.