All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chi-Wen Weng <cwweng.linux@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	chernyakin.victor.j@outlook.com, cwweng@nuvoton.com
Subject: Re: [PATCH v5 3/3] iio: adc: Add Nuvoton MA35D1 EADC driver
Date: Tue, 24 Nov 2026 16:41:51 +0800	[thread overview]
Message-ID: <c88fd429-025a-406d-ad80-ec464db7d1cd@gmail.com> (raw)
In-Reply-To: <20261122030647.70b41b61@jic23-hlaptop>

On Sun, Nov 22, 2026 at 03:06:47AM +0000, Jonathan Cameron wrote:
 > > +	/*
 > > +	 * pollfunc->irq is not initialized until the pollfunc is first
 > > +	 * attached to a trigger, so only suspend and resume triggering
 > > +	 * while the buffer is enabled.
 > > +	 */
 >
 > True enough but isn't it also guarded by if indio_dev->pollfunc
 > inside the iio_device_suspend_triggering()?
 >
 > I think in the case you are avoiding it is a noop anyway.
 >
 > disable_irq() nests fine so it shouldn't even matter if anyone turned
 > it on yet.

I checked this again on v7.4-rc4 (b6a9fa34ce41).

iio_alloc_pollfunc() uses kmalloc_obj() without initializing pf->irq, 
while iio_triggered_buffer_setup_ext() allocates the pollfunc before the 
buffer is enabled.

The PM helpers check whether pollfunc is non-NULL and pf->irq > 0. If 
the uninitialized IRQ value happens to be positive, disable_irq() could 
be called with an invalid or unrelated IRQ number.

This is why I added the iio_buffer_enabled() check for the 
inactive-buffer case.

 > > +	if (!iio_buffer_enabled(indio_dev))
 > > +		return 0;
 >
 > As above, I'm missing why we need to protect the call
 > to resume_triggering. The pollfunc can't change between
 > suspend and resume so there is either one there or not
 > in both cases and the guards inside that call should take care
 > of the rest. If I'm missing something we should look to
 > fix it in those calls!

Agreed. The same uninitialized IRQ concern applies to the resume helper.

I also noticed that iio_trigger_attach_poll_func() does not clear 
pf->irq on its error paths. If request_threaded_irq() or 
set_trigger_state() fails, pf->irq can retain a stale positive IRQ 
number after the resources have been released. The normal detach path 
explicitly resets it to 0.

The error propagation from iio_trigger_get_irq() was fixed by 
dff701806ab6, but these two IRQ state issues remain in v7.4-rc4.

Would it make sense to initialize pf->irq to 0 in iio_alloc_pollfunc() 
and clear it on the attach error paths?

I agree that fixing this in the IIO core would be preferable to relying 
on driver-specific checks. I haven't reproduced an IRQ failure at 
runtime; these findings are based on source inspection.

Thanks,
Chi-Wen

  reply	other threads:[~2026-11-24  8:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  8:28 [PATCH v5 0/3] iio: adc: Add Nuvoton MA35D1 EADC support Chi-Wen Weng
2026-11-17  8:28 ` [PATCH v5 1/3] dt-bindings: iio: adc: Fix channel property validation Chi-Wen Weng
2026-11-18 16:31   ` Rob Herring (Arm)
2026-11-17  8:28 ` [PATCH v5 2/3] dt-bindings: iio: adc: Add Nuvoton MA35D1 EADC Chi-Wen Weng
2026-11-17  8:42   ` sashiko-bot
2026-11-25  1:40     ` Chi-Wen Weng
2026-11-29  0:12       ` Jonathan Cameron
2026-11-18 16:33   ` Rob Herring (Arm)
2026-11-17  8:28 ` [PATCH v5 3/3] iio: adc: Add Nuvoton MA35D1 EADC driver Chi-Wen Weng
2026-11-17  9:43   ` Andy Shevchenko
2026-11-22  3:06   ` Jonathan Cameron
2026-11-24  8:41     ` Chi-Wen Weng [this message]
2026-11-29  0:17       ` 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=c88fd429-025a-406d-ad80-ec464db7d1cd@gmail.com \
    --to=cwweng.linux@gmail.com \
    --cc=andy@kernel.org \
    --cc=chernyakin.victor.j@outlook.com \
    --cc=conor+dt@kernel.org \
    --cc=cwweng@nuvoton.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.