Re: [PATCH] regulator: simplify locking
From: Michał Mirosław
Date: Mon Aug 10 2020 - 12:12:21 EST
On Mon, Aug 10, 2020 at 08:14:20AM +0300, Dmitry Osipenko wrote:
> 10.08.2020 03:59, Michał Mirosław пишет:
> > On Mon, Aug 10, 2020 at 03:21:47AM +0300, Dmitry Osipenko wrote:
> >> 10.08.2020 01:30, Michał Mirosław пишет:
> >>> On Mon, Aug 10, 2020 at 12:40:04AM +0300, Dmitry Osipenko wrote:
> >>>> 10.08.2020 00:16, Michał Mirosław пишет:
> >>>>> - mutex_lock(®ulator_nesting_mutex);
> >>>>> + if (ww_ctx || !mutex_trylock_recursive(&rdev->mutex.base))
> >>> I think that reimplementing the function just to not use it is not the
> >>> right solution. The whole locking protocol is problematic and this patch
> >>> just uncovers one side of it.
> >> It's not clear to me what is uncovered, the ref_cnt was always accessed
> >> under lock. Could you please explain in a more details?
> The nested locking usage is discouraged in general because it is a
> source of bugs. I guess it should be possible to get rid of all nested
> lockings in the regulator core and use a pure ww_mutex, but somebody
> should dedicate time to work on it.
So using a deprecated function for deprecated functionality sounds just
appropriate, doesn't it? :-)