Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Rasmus Villemoes <ravi@prevas.dk>
Cc: Peter Rosin <peda@axentia.se>,
	linux-iio@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH] iio: core: add separate lockdep class for info_exist_lock
Date: Sat, 27 Dec 2025 15:07:24 +0000	[thread overview]
Message-ID: <20251227150724.08e17cc3@jic23-huawei> (raw)
In-Reply-To: <875x9yucdh.fsf@prevas.dk>

On Mon, 22 Dec 2025 09:52:42 +0100
Rasmus Villemoes <ravi@prevas.dk> wrote:

> On Sun, Dec 21 2025, Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Mon, 15 Dec 2025 14:33:38 +0100
> > Peter Rosin <peda@axentia.se> wrote:
> >  
> >> Hi!
> >> 
> >> 2025-12-15 at 14:17, Rasmus Villemoes wrote:  
> >> > When one iio device is a consumer of another, it is possible that
> >> > the ->info_exist_lock of both ends up being taken when reading the
> >> > value of the consumer device.
> >> > 
> >> > Since they currently belong to the same lockdep class (being
> >> > initialized in a single location with mutex_init()), that results in a
> >> > lockdep warning    
> >> 
> >> ...
> >>   
> >> > Just as the mlock_key already has its own lockdep class, add a
> >> > lock_class_key for the info_exist mutex.
> >> > 
> >> > Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>    
> >> 
> >> Looks sane from here.
> >> 
> >> Reviewed-by: Peter Rosin <peda@axentia.se>  
> > Hi Rasmus,
> >
> > Thanks for doing this!  
> >>   
> > We should probably merge this as a fix and get it backported.
> > Whilst fairly rare anyone hits this it is also safe enough wrt
> > to very low chance of causing any problems.
> >
> > Would be good to have an appropriate Fixes tag though.
> > Ideally please reply to this thread with an appropriate one.
> > If not I'll try and figure one out, but not today!  
> 
> I tried to find one, but the problem goes way back, probably all the way
> to either the introduction of info_exist_lock or the ability for one iio
> channel to have a dependency on another, whichever came latest. And I'm
> not really very familiar with the iio subsystem, so I couldn't find one
> single commit to name.
> 
> Commit 2bc9cd66eb25d ("iio: Use per-device lockdep class for mlock")
> which introduced the mlock_key referred to 67e17300dc1d76 ("iio:
> potentiostat: add LMP91000 support"), but that feels more like a "this
> driver is what first exposed the problem" and not really "this is where
> the problem was introduced in the iio framework".
> 
> Wrt. backporting, it's probably worth mentioning c76ba4b264442 ("iio:
> core: Replace lockdep_set_class() + mutex_init() by combined call") as a
> prerequisite, as that is needed to make it cherry-pick cleanly.

Thanks for doing the archeology.  I had a dig as well and fairly sure it's.
That references the rules for consumers in the commit message so definitely
seems that all the relevant infrastructure was in there at that point.
Given it's from 2012 we can backport this to all kernels anyone still cares
about.

 ac917a81117c ("staging:iio:core set the iio_dev.info pointer to null on unregister under lock.")

So applied with that fixes tag to the fixes-togreg branch of iio.git.

thanks,

Jonathan


> Rasmus


      reply	other threads:[~2025-12-27 15:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 13:17 [PATCH] iio: core: add separate lockdep class for info_exist_lock Rasmus Villemoes
2025-12-15 13:33 ` Peter Rosin
2025-12-21 19:06   ` Jonathan Cameron
2025-12-22  8:52     ` Rasmus Villemoes
2025-12-27 15:07       ` Jonathan Cameron [this message]

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=20251227150724.08e17cc3@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=peda@axentia.se \
    --cc=ravi@prevas.dk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox