From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Radu Sabau via B4 Relay"
<devnull+radu.sabau.analog.com@kernel.org>,
radu.sabau@analog.com, "Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Thomas Gleixner" <tglx@linutronix.de>
Subject: Re: [PATCH v4 2/2] iio: adc: ad_sigma_delta: fix clear_pending_event for registerless devices
Date: Fri, 22 May 2026 17:20:37 +0200 [thread overview]
Message-ID: <ahBwbklQh9VKkfKZ@monoceros> (raw)
In-Reply-To: <20260522145143.1e651c12@jic23-huawei>
[-- Attachment #1: Type: text/plain, Size: 2389 bytes --]
Hello,
[adding Thomas to the discussion as he also participated in the old
linked discussion]
On Fri, May 22, 2026 at 02:51:43PM +0100, Jonathan Cameron wrote:
> On Thu, 21 May 2026 13:30:49 +0300
> Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org> wrote:
>
> > From: Radu Sabau <radu.sabau@analog.com>
> >
> > ad_sigma_delta_clear_pending_event() falls through to the status register
> > read path for devices with has_registers = false and no rdy_gpiod. For
> > such devices, ad_sd_read_reg() skips the address byte entirely and clocks
> > raw MISO bytes with no address phase — making it byte-for-byte identical
> > to reading conversion data. If a pending conversion result is present,
> > this partially consumes it and corrupts the data stream for the subsequent
> > ad_sd_read_reg() call in ad_sigma_delta_single_conversion().
> >
> > Furthermore, with num_resetclks = 0 on these devices, data_read_len
> > evaluates to 0. If the clocked byte has bit 7 clear, pending_event is set
> > and the code attempts memset(data + 2, 0xff, 0 - 1), overflowing to
> > SIZE_MAX and corrupting the heap.
> >
> > Fix by returning 0 immediately when neither rdy_gpiod nor has_registers
> > is set. This is safe because the IRQ is requested with IRQF_NO_AUTOEN and
> > IRQ_DISABLE_UNLAZY, which keeps the hardware IRQ line unmasked even while
> > software-disabled. Any falling edge from a completed conversion is latched
> > by the IRQ controller.
>
> David raised this on v2.
>
> This sounds suspiciously like we are in implementation defined territory.
> IIRC if an irq is disabled, whether the interrupt is latched is down
> to whether the irq controller happens to do so. There is no hard rule on this
> or way to detect whether it will or not.
>
> https://lore.kernel.org/all/io53lznz3qp3jd5rohqsjhosnmdzd6d44sdbwu5jcfrs3rz2a2@orquwgflrtyc/
> Was I think the most recent detailed thread on this.
>
> Uwe - you were driving that discussion can you sanity check what we have
> here if you have a moment? Thanks!
Without having looked at the code but skimmed through the old discussion
again, the result back then was that you won't get reliable behaviour
without rdy-gpio.
I didn't try to understand what's different fro "registerless devices",
but I doubt this implements a robust solution.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-05-22 15:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 10:30 [PATCH v4 0/2] iio: adc: ad_sigma_delta: fix CS assertion and registerless device handling Radu Sabau via B4 Relay
2026-05-21 10:30 ` [PATCH v4 1/2] iio: adc: ad_sigma_delta: fix CS held asserted and state leaks Radu Sabau via B4 Relay
2026-05-21 10:30 ` [PATCH v4 2/2] iio: adc: ad_sigma_delta: fix clear_pending_event for registerless devices Radu Sabau via B4 Relay
2026-05-22 13:51 ` Jonathan Cameron
2026-05-22 15:20 ` Uwe Kleine-König [this message]
2026-05-25 12:16 ` Sabau, Radu bogdan
2026-05-26 12:39 ` 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=ahBwbklQh9VKkfKZ@monoceros \
--to=u.kleine-koenig@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=devnull+radu.sabau.analog.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=radu.sabau@analog.com \
--cc=tglx@linutronix.de \
/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®