Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>, "Sa, Nuno" <Nuno.Sa@analog.com>
Cc: "Bolboaca, Ramona" <Ramona.Bolboaca@analog.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 0/8] Remove adis_initial_startup usage
Date: Tue, 15 Nov 2022 13:47:56 +0100	[thread overview]
Message-ID: <334af9a1281673c0ac43dedccb6c1aea16494827.camel@gmail.com> (raw)
In-Reply-To: <20221105150647.2c9cbff7@jic23-huawei>

On Sat, 2022-11-05 at 15:06 +0000, Jonathan Cameron wrote:
> On Thu, 3 Nov 2022 12:35:31 +0000
> "Sa, Nuno" <Nuno.Sa@analog.com> wrote:
> 
> > > From: Ramona Bolboaca <ramona.bolboaca@analog.com>
> > > Sent: Thursday, November 3, 2022 9:09 AM
> > > To: jic23@kernel.org; linux-iio@vger.kernel.org; linux-
> > > kernel@vger.kernel.org
> > > Cc: Bolboaca, Ramona <Ramona.Bolboaca@analog.com>
> > > Subject: [PATCH v2 0/8] Remove adis_initial_startup usage
> > > 
> > > 
> > > Remove 'adis_initial_startup()' usage due to the fact that it
> > > leads to a
> > > deadlock.
> > > The same mutex is acquired twice, without releasing it, once
> > > inside
> > > 'adis_initial_startup()' and once inside 'adis_enable_irq()'.
> > > Instead of 'adis_initial_startup()', use
> > > '__adis_initial_startup()'.
> > > 
> > > Ramona Bolboaca (8):
> > >   iio: accel: adis16201: Fix deadlock in probe
> > >   iio: accel: adis16209: Fix deadlock in probe
> > >   iio: gyro: adis16136: Fix deadlock in probe
> > >   iio: gyro: adis16260: Fix deadlock in probe
> > >   iio: imu: adis16400: Fix deadlock in probe
> > >   staging: iio: accel: adis16203: Fix deadlock in probe
> > >   staging: iio: accel: adis16240: Fix deadlock in probe
> > >   iio: imu: adis: Remove adis_initial_startup function
> > > 
> > >  drivers/iio/accel/adis16201.c         |  2 +-
> > >  drivers/iio/accel/adis16209.c         |  2 +-
> > >  drivers/iio/gyro/adis16136.c          |  2 +-
> > >  drivers/iio/gyro/adis16260.c          |  2 +-
> > >  drivers/iio/imu/adis16400.c           |  2 +-
> > >  drivers/staging/iio/accel/adis16203.c |  2 +-
> > >  drivers/staging/iio/accel/adis16240.c |  2 +-
> > >  include/linux/iio/imu/adis.h          | 12 ------------
> > >  8 files changed, 7 insertions(+), 19 deletions(-)
> > >   
> > 
> > You could have placed your v2 changelog in the cover letter.
> > Moreover it's the same for all patches... Anyways: 
> > 
> > Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> 
> This feels a little backwards.  Normally we'd expect the
> outer function to take the lock and the inner call to not
> do so.  Now it's fine to not take the lock here at all because
> the outer function call is in probe anyway, before we reach
> the point where there should be an concurrency.
> 
> I wonder if we should instead do this by having
> an unlocked __adis_enable_irq() that is always called
> by __adis_initial_startup().  That would be the fix that
> then needs backporting.
> 

I did mentioned the same thing in the first version of the series but
did not really pushed for it. Now that you mention, I agree it feels
weird (and wrong from a design perspective) to have the lock,
"silently", taken inside a function starting with double underscore
(which should mean unlocked call).

> Switching the calls from adis_initial_startup() to
> __adis_initial_startup() would then just be a trivial
> optimization to not take locks before they should ever matter.
> 
> This all hinges on my assumption that the lock isn't useful.
> Am I right on that?
> 

I think so as all the calls happen during probe before registering the
userspace interface.

- Nuno Sá


      reply	other threads:[~2022-11-15 12:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03  8:08 [PATCH v2 0/8] Remove adis_initial_startup usage Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 1/8] iio: accel: adis16201: Fix deadlock in probe Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 2/8] iio: accel: adis16209: " Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 3/8] iio: gyro: adis16136: " Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 4/8] iio: gyro: adis16260: " Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 5/8] iio: imu: adis16400: " Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 6/8] staging: iio: accel: adis16203: " Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 7/8] staging: iio: accel: adis16240: " Ramona Bolboaca
2022-11-03  8:08 ` [PATCH v2 8/8] iio: imu: adis: Remove adis_initial_startup function Ramona Bolboaca
2022-11-03 12:35 ` [PATCH v2 0/8] Remove adis_initial_startup usage Sa, Nuno
2022-11-05 15:06   ` Jonathan Cameron
2022-11-15 12:47     ` Nuno Sá [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=334af9a1281673c0ac43dedccb6c1aea16494827.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Nuno.Sa@analog.com \
    --cc=Ramona.Bolboaca@analog.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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