[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250427111810.7c6c5caa@jic23-huawei>
Date: Sun, 27 Apr 2025 11:18:10 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Andy Shevchenko <andy.shevchenko@...il.com>, Nuno Sá
<nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>, Lars-Peter Clausen
<lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>,
Guillaume Ranquet <granquet@...libre.com>, Jonathan Cameron
<Jonathan.Cameron@...wei.com>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH] iio: adc: ad7173: fix compiling without gpiolib
On Sat, 26 Apr 2025 17:45:02 -0500
David Lechner <dlechner@...libre.com> wrote:
> On 4/26/25 10:18 AM, Jonathan Cameron wrote:
> > On Wed, 23 Apr 2025 00:03:38 +0300
> > Andy Shevchenko <andy.shevchenko@...il.com> wrote:
> >
> >> On Tue, Apr 22, 2025 at 11:12 PM David Lechner <dlechner@...libre.com> wrote:
> >>>
>
> ...
>
> >>> Not related to the fix, but I also question the use of the regmap here.
> >>> This is one of the ad_sigma_delta drivers that does funny things with
> >>> the SPI bus, like keeping it locked during the entire time a buffer is
> >>> enabled. So, if someone tried to use a GPIO during a buffered read, the
> >>> GPIO call could block (waiting for the SPI bus mutex) until the buffer
> >>> is disabled, which could be an indefinitely long time. And to make it
> >>> even worse, this is not an interruptible wait, so the GPIO consumer
> >>> would effectively be deadlocked.
> >>
> >> I would say either the entire buffer mode is broken (in software), or
> >> hardware is broken and GPIO shouldn't be supported at all if the
> >> buffer mode is enabled. I think the best solution here is to remove
> >> the GPIO chip before enabling buffered mode. If GPIO is in use, fail
> >> the buffer mode.
> > I'd kind of assume that anyone using these GPIOs is doing it in a fashion
> > related closely to the ADC itself.
> >
> > Can we make any other use fail more cleanly?
> >
> > J
> >>
> >
>
> My inclination would be to implement it like [1] where we use iio_claim_direct()
> to return -EBUSY during buffered reads to avoid the deadlock-like possibility
> instead of using the gpio regmap.
>
> [1]: https://lore.kernel.org/linux-iio/2a789531fda5031c135fc207a547f2c3f00a13ea.1744325346.git.Jonathan.Santos@analog.com/
That sounds better.
J
Powered by blists - more mailing lists