Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Guillaume Ranquet" <granquet@baylibre.com>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"kernel test robot" <lkp@intel.com>
Subject: Re: [PATCH] iio: adc: ad7173: fix compiling without gpiolib
Date: Sun, 27 Apr 2025 11:18:10 +0100	[thread overview]
Message-ID: <20250427111810.7c6c5caa@jic23-huawei> (raw)
In-Reply-To: <f5de85b7-489c-4a81-a111-fbe7a893694c@baylibre.com>

On Sat, 26 Apr 2025 17:45:02 -0500
David Lechner <dlechner@baylibre.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@gmail.com> wrote:
> >   
> >> On Tue, Apr 22, 2025 at 11:12 PM David Lechner <dlechner@baylibre.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

  reply	other threads:[~2025-04-27 10:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 20:12 [PATCH] iio: adc: ad7173: fix compiling without gpiolib David Lechner
2025-04-22 21:03 ` Andy Shevchenko
2025-04-25 16:55   ` David Lechner
2025-04-25 18:08     ` Andy Shevchenko
2025-04-26 15:18   ` Jonathan Cameron
2025-04-26 22:45     ` David Lechner
2025-04-27 10:18       ` Jonathan Cameron [this message]
2025-04-26 15:15 ` 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=20250427111810.7c6c5caa@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=granquet@baylibre.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=nuno.sa@analog.com \
    /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