Skip to content

Commit b83a177

Browse files
diandersbroonie
authored andcommitted
regulator: core: Consistently set mutex_owner when using ww_mutex_lock_slow()
When a codepath locks a rdev using ww_mutex_lock_slow() directly then that codepath is responsible for incrementing the "ref_cnt" and also setting the "mutex_owner" to "current". The regulator core consistently got that right for "ref_cnt" but didn't always get it right for "mutex_owner". Let's fix this. It's unlikely that this truly matters because the "mutex_owner" is only needed if we're going to do subsequent locking of the same rdev. However, even though it's not truly needed it seems less surprising if we consistently set "mutex_owner" properly. Fixes: f8702f9 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/20230329143317.RFC.v2.1.I4e9d433ea26360c06dd1381d091c82bb1a4ce843@changeid Signed-off-by: Mark Brown <[email protected]>
1 parent fc4fef6 commit b83a177

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/regulator/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ static void regulator_lock_dependent(struct regulator_dev *rdev,
334334
ww_mutex_lock_slow(&new_contended_rdev->mutex, ww_ctx);
335335
old_contended_rdev = new_contended_rdev;
336336
old_contended_rdev->ref_cnt++;
337+
old_contended_rdev->mutex_owner = current;
337338
}
338339

339340
err = regulator_lock_recursive(rdev,
@@ -6048,6 +6049,7 @@ static void regulator_summary_lock(struct ww_acquire_ctx *ww_ctx)
60486049
ww_mutex_lock_slow(&new_contended_rdev->mutex, ww_ctx);
60496050
old_contended_rdev = new_contended_rdev;
60506051
old_contended_rdev->ref_cnt++;
6052+
old_contended_rdev->mutex_owner = current;
60516053
}
60526054

60536055
err = regulator_summary_lock_all(ww_ctx,

0 commit comments

Comments
 (0)