From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>
Subject: Re: [PATCH] iio: gyro: adis16260: remove indio_dev mlock
Date: Sat, 5 Oct 2019 15:49:56 +0100 [thread overview]
Message-ID: <20191005154949.4c339235@archlinux> (raw)
In-Reply-To: <20191005153837.25e5be57@archlinux>
On Sat, 5 Oct 2019 15:38:45 +0100
Jonathan Cameron <jic23@kernel.org> wrote:
> On Thu, 19 Sep 2019 14:57:16 +0300
> Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
>
> > The internal lock that is by the ADIS library should be sufficient to keep
> > state consistent. There is no need for an extra lock.
>
> I'm not sure that's true. In theory we could get two different attempts
> to set the sampling frequency running concurrently. That could lead to
> a race between the point where we set the spi frequency for future
> messages and the point where we set the devices sampling frequency.
>
> Bang it stops working. So, whilst it is arguably paranoid I think
> you do need a lock here, but it should be something that is driver
> local rather than mlock.
Thinking a bit more on this do we have a potential issue where we
race with a read on the spi bus as we are changing this frequency?
They might all be 'safe' but I haven't thought it through properly yet.
>
> thanks,
>
> Jonathan
>
>
> >
> > This patch removes it.
> >
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> > drivers/iio/gyro/adis16260.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
> > index 207a0ce13439..0fa93d02062a 100644
> > --- a/drivers/iio/gyro/adis16260.c
> > +++ b/drivers/iio/gyro/adis16260.c
> > @@ -293,7 +293,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
> > addr = adis16260_addresses[chan->scan_index][1];
> > return adis_write_reg_16(adis, addr, val);
> > case IIO_CHAN_INFO_SAMP_FREQ:
> > - mutex_lock(&indio_dev->mlock);
> > if (spi_get_device_id(adis->spi)->driver_data)
> > t = 256 / val;
> > else
> > @@ -310,7 +309,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
> > adis->spi->max_speed_hz = ADIS16260_SPI_FAST;
> > ret = adis_write_reg_8(adis, ADIS16260_SMPL_PRD, t);
> >
> > - mutex_unlock(&indio_dev->mlock);
> > return ret;
> > }
> > return -EINVAL;
>
next prev parent reply other threads:[~2019-10-05 14:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 11:57 [PATCH] iio: gyro: adis16260: remove indio_dev mlock Alexandru Ardelean
2019-10-05 14:38 ` Jonathan Cameron
2019-10-05 14:49 ` Jonathan Cameron [this message]
2019-10-07 7:56 ` Ardelean, Alexandru
2019-10-08 8:22 ` [PATCH v2] iio: gyro: adis16260: replace mlock with ADIS lib's state_lock Alexandru Ardelean
2019-10-12 13:43 ` Jonathan Cameron
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=20191005154949.4c339235@archlinux \
--to=jic23@kernel.org \
--cc=alexandru.ardelean@analog.com \
--cc=linux-iio@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;
as well as URLs for NNTP newsgroup(s).