From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: Jonathan Santos <Jonathan.Santos@analog.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
lars@metafoo.de, Michael.Hennerich@analog.com,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
jonath4nns@gmail.com
Subject: Re: [PATCH] iio: adc: ad7768-1: disable IRQ autoenable
Date: Sat, 19 Jul 2025 13:08:44 +0100 [thread overview]
Message-ID: <20250719130844.7559e322@jic23-huawei> (raw)
In-Reply-To: <5llfgo2wifyi43zj24rv7ph5gebevcszrxl3hp3yc3ibaglcr3@fqdejauv6rmo>
On Fri, 18 Jul 2025 10:18:56 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Thu, Jul 17, 2025 at 10:33:07PM -0300, Jonathan Santos wrote:
> > The device continuously converts data while powered up, generating
> > interrupts in the background. Configure the IRQ to be enabled and
> > disabled manually as needed to avoid unnecessary CPU load.
This generates interrupts continuously even when in oneshot mode?
> >
> > Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
> > ---
>
> LGTM,
>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
>
> > drivers/iio/adc/ad7768-1.c | 18 +++++++++++++++++-
> > 1 file changed, 17 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> > index a2e061f0cb08..3eea03c004c3 100644
> > --- a/drivers/iio/adc/ad7768-1.c
> > +++ b/drivers/iio/adc/ad7768-1.c
> > @@ -395,8 +395,10 @@ static int ad7768_scan_direct(struct iio_dev *indio_dev)
> > if (ret < 0)
> > return ret;
> >
> > + enable_irq(st->spi->irq);
Looks racey to me in a number of ways.
Before this patch:
In continuous mode, reinit_completion called then interrupt before we enter
oneshot mode. What was captured?
After this patch
Oneshot mode starts - hardware interrupt happens but enable_irq() is not set
so we miss it - or do we get another pulse later?
I'm not sure how to solve this as a device generating a stream of garbage
interrupts is near impossible to deal with.
I'm not following the datasheet description of this features vs the code
though. It refers to oneshot mode requiring a pulse on sync in which I can't
find.
> > ret = wait_for_completion_timeout(&st->completion,
> > msecs_to_jiffies(1000));
> > + disable_irq(st->spi->irq);
> > if (!ret)
> > return -ETIMEDOUT;
> >
> > @@ -1130,7 +1132,21 @@ static const struct iio_buffer_setup_ops ad7768_buffer_ops = {
> > .predisable = &ad7768_buffer_predisable,
> > };
> >
> > +static int ad7768_set_trigger_state(struct iio_trigger *trig, bool enable)
> > +{
> > + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> > + struct ad7768_state *st = iio_priv(indio_dev);
> > +
> > + if (enable)
> > + enable_irq(st->spi->irq);
> > + else
> > + disable_irq(st->spi->irq);
> > +
> > + return 0;
> > +}
> > +
> > static const struct iio_trigger_ops ad7768_trigger_ops = {
> > + .set_trigger_state = ad7768_set_trigger_state,
> > .validate_device = iio_trigger_validate_own_device,
> > };
> >
> > @@ -1417,7 +1433,7 @@ static int ad7768_probe(struct spi_device *spi)
> >
> > ret = devm_request_irq(&spi->dev, spi->irq,
> > &ad7768_interrupt,
> > - IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> > + IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN,
Why drop oneshot?
> > indio_dev->name, indio_dev);
> > if (ret)
> > return ret;
> >
> > base-commit: 0a686b9c4f847dc21346df8e56d5b119918fefef
> > --
> > 2.34.1
> >
>
next prev parent reply other threads:[~2025-07-19 12:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 1:33 Jonathan Santos
2025-07-18 9:18 ` Nuno Sá
2025-07-19 12:08 ` Jonathan Cameron [this message]
2025-07-25 20:01 ` Jonathan Santos
2025-07-27 15:38 ` 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=20250719130844.7559e322@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Santos@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jonath4nns@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=noname.nuno@gmail.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
all inboxes | Powered by JetHome®