From: Rasmus Villemoes <ravi@prevas.dk>
To: Peter Rosin <peda@axentia.se>
Cc: Guenter Roeck <linux@roeck-us.net>,
Jonathan Cameron <jic23@kernel.org>,
<linux-iio@vger.kernel.org>, <linux-hwmon@vger.kernel.org>
Subject: Re: lockdep splat involving iio-hwmon and iio-rescale drivers
Date: Fri, 12 Dec 2025 14:12:48 +0100 [thread overview]
Message-ID: <87ms3nu9m7.fsf@prevas.dk> (raw)
In-Reply-To: <307296eb-e5b4-705b-6851-53cecb87a69c@axentia.se> (Peter Rosin's message of "Thu, 11 Dec 2025 00:29:56 +0100")
On Thu, Dec 11 2025, Peter Rosin <peda@axentia.se> wrote:
> 2025-12-10 at 23:54, Peter Rosin wrote:
>> Before commit 3092bde731ca ("iio: inkern: move to the cleanup.h
>> magic") I think this could have been solved with a number of:
>>
>> - mutex_lock(&iio_dev_opaque->info_exist_lock);
>> + mutex_lock_nested(&iio_dev_opaque->info_exist_lock);
>
> Oops, we need something clever for the (missing) subclass
> argument to the mutex_lock_nested() calls, which I simply forgot
> all about. It should have been:
>
> + mutex_lock_nested(&iio_dev_opaque->info_exist_lock, *subclass*);
>
> I don't know what sane subclasses there are. One thing could be
> the recursion depth, but I don't think we want to keep track of that
> just for lockdep? Another is to use one lockdep class for every
> info_exist_lock, but that can generate a lot of lockdep classes...
It doesn't seem to me that that info_exist_lock is the proper
mechanism for whatever it is it is protecting against.
I'm not even sure it's needed, because if the device could be
unregistered while somebody has a reference to it, why is it even
allowed to take that lock in the first place (i.e., why is the memory
containing the info_exist_lock guaranteed to still be valid)?
But, since I'm not going to propose just ripping it out, perhaps a
better approach would be something like what the gpio subsystem did in
d83cee3d2bb1 ("gpio: protect the pointer to gpio_chip in gpio_device
with SRCU"), at least superficially it seems to be about a similar
problem.
Rasmus
next prev parent reply other threads:[~2025-12-12 13:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 14:31 lockdep splat involving iio-hwmon and iio-rescale drivers Rasmus Villemoes
2025-12-10 19:12 ` Guenter Roeck
2025-12-10 22:54 ` Peter Rosin
2025-12-10 23:29 ` Peter Rosin
2025-12-12 13:12 ` Rasmus Villemoes [this message]
2025-12-13 16:57 ` Jonathan Cameron
[not found] ` <98101700-35EB-4D45-AEE4-6FF1E9D55505@axentia.se>
2025-12-14 14:39 ` Jonathan Cameron
2025-12-15 9:14 ` Rasmus Villemoes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ms3nu9m7.fsf@prevas.dk \
--to=ravi@prevas.dk \
--cc=jic23@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=peda@axentia.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.