From: Matti Vaittinen <mazziesaccount@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Tomislav Denis" <tomislav.denis@avl.com>,
"Matt Ranostay" <mranostay@gmail.com>,
"Abhash Jha" <abhashkumarjha123@gmail.com>,
"Petre Rodan" <petre.rodan@subdimension.ro>,
"Mårten Lindahl" <martenli@axis.com>,
"Dan Murphy" <dmurphy@ti.com>, "Sean Nyekjaer" <sean@geanix.com>,
"Tomas Melin" <tomas.melin@vaisala.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Leonard Crestez" <cdleonard@gmail.com>,
"Peter Meerwald-Stadler" <pmeerw@pmeerw.net>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Dixit Parmar" <dixitparmar19@gmail.com>,
"Stepan Ionichev" <sozdayvek@gmail.com>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
"Joachim Eastwood" <manabian@gmail.com>,
"Tiberiu Breana" <tiberiu.a.breana@intel.com>,
"Maxwell Doose" <maxwell@maxwelld.cc>,
"Tomasz Duszynski" <tduszyns@gmail.com>,
"Alison Schofield" <amsfield22@gmail.com>,
"Christian Eggers" <ceggers@arri.de>,
"Andreas Klinger" <ak@it-klinger.de>,
linux-iio@vger.kernel.org, linux@analog.com
Cc: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Subject: Re: [PATCH 16/25] iio: pressure: rohm-bm1390: only return IRQ_NONE if data ready is not set
Date: Mon, 30 Nov 2026 13:03:23 +0200 [thread overview]
Message-ID: <6d2e75b8-2711-4144-911b-82a10751a08e@gmail.com> (raw)
In-Reply-To: <20261129-messing-fixes3323-v1-16-f01aa73aa628@oss.qualcomm.com>
On 29/11/2026 23:06, Jonathan Cameron wrote:
> From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
>
> bm1390_handle_trigger() returns false both when the status register
> shows that data ready is not set and when reading the status or the
> pressure fails. bm1390_trigger_handler() then always calls
> iio_trigger_notify_done() but returns IRQ_RETVAL() of that result, so a
> read error is reported as IRQ_NONE even though the trigger was handled
> and notified.
>
> Only return false from bm1390_handle_trigger() when data ready is not
> set, treating read errors as handled,
I don't like this because, if we have a permanent error on
bus/controller preventing the read, then the IRQ is not acked from the
sensor. This is specifically why the code returned IRQ_NONE if read failed.
With the IRQ_NONE, the "IRQ storm" resulting from un-acked IRQs will
trigger the 'safety mechanism' disabling the IRQ from the host side. On
single processor systems (which are admittably getting rare), this can
be the difference between completely unresponsive, not debuggable
device, and a device which hangs for a while, and then spits the
"disabling IRQx nobody cared" print which is a strong hint regarding
what's going on.
> as was already the case for a
> failed temperature read.
I believe that reading the temperature does not have similar "acking"
functionality.
> In bm1390_trigger_handler() return IRQ_NONE
> without notifying the trigger in that case, and otherwise notify it and
> return IRQ_HANDLED.
I have a feeling that notifying was needed, so that the IIO handler
propagates the next IRQ to the driver's handler - which can then (in
case of a failing to ACK again due to a read error), return another
IRQ_NONE. This is paramount for the above mentioned "safety IRQ
disabling" to take a place.
It is entirely possible I don't see something, the trigger stuff is not
simple (to me). :) If so, please bear with me and explain.
> This is a case where the simple 'fix' may not be the ideal one.
> The alternative would be to move the status check to the trigger
> itself. Thus not trigger if the flag is not set. That may have knock
> on effects if that read must occur when other triggers are in use.
>
> Cc: Matti Vaittinen <mazziesaccount@gmail.com>
> Fixes: d07bf43d175a ("iio: pressure: rohm-bm1390: harden trigger handler against transient errors")
> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> ---
> LLM found during rework for a more significant series.
> For that I need consistency of return value and whether
> iio_trigger_notify_done() is called. This corner case fell out of that
> requirement.
> ---
> drivers/iio/pressure/rohm-bm1390.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/pressure/rohm-bm1390.c b/drivers/iio/pressure/rohm-bm1390.c
> index 7a6a16cffb66..6d4764b0b5f2 100644
> --- a/drivers/iio/pressure/rohm-bm1390.c
> +++ b/drivers/iio/pressure/rohm-bm1390.c
> @@ -630,7 +630,10 @@ static bool bm1390_handle_trigger(struct iio_dev *idev)
>
> /* DRDY is acked by reading status reg */
> ret = regmap_read(data->regmap, BM1390_REG_STATUS, &status);
> - if (ret || !status)
> + if (ret)
> + return true;
> +
> + if (!status)
> return false;
>
> dev_dbg(data->dev, "DRDY trig status 0x%x\n", status);
> @@ -639,7 +642,7 @@ static bool bm1390_handle_trigger(struct iio_dev *idev)
> ret = bm1390_pressure_read(data, &data->buf.pressure);
> if (ret) {
> dev_warn(data->dev, "sample read failed %d\n", ret);
> - return false;
> + return true;
> }
> }
>
> @@ -662,12 +665,13 @@ static irqreturn_t bm1390_trigger_handler(int irq, void *p)
> {
> struct iio_poll_func *pf = p;
> struct iio_dev *idev = pf->indio_dev;
> - bool result;
>
> - result = bm1390_handle_trigger(idev);
> + if (!bm1390_handle_trigger(idev))
> + return IRQ_NONE;
I really like this better than hiding the IRQ_NONE case in IRQ_RETVAL().
Anyhow, I think we should still call the iio_trigger_notify_done() or
the bm1390_handle_trigger() will not see another IRQ? If this is the
case, then we only get this one IRQ_NONE returned, which is not enough
for the kernel to disable offending IRQ. So, badly behaving sensor/bus
shall hang the system. (Now, I didn't check this from the code, I just
think this was exactly the issue that got fixed by the d07bf43d175a).
> iio_trigger_notify_done(idev->trig);
>
> - return IRQ_RETVAL(result);
> + return IRQ_HANDLED;
> }
>
> /* Get timestamps and wake the thread if we need to read data */
>
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductor
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2026-11-30 11:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 21:06 [PATCH 00/25] IIO: Various fixes mostly related to buffered capture Jonathan Cameron
2026-11-29 21:06 ` [PATCH 01/25] iio: adc: ti-ads131e08: fix the size of the scan buffer Jonathan Cameron
2026-11-29 21:06 ` [PATCH 02/25] iio: potentiostat: lmp91000: fix NULL deref setting immutable trigger Jonathan Cameron
2026-11-30 0:01 ` Jonathan Cameron
2026-11-29 21:06 ` [PATCH 03/25] iio: light: vl6180: notify trigger when reading data fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 04/25] iio: accel: bma220: return error if triggered buffer setup fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 05/25] iio: adc: ti-adc084s021: don't push stale data if the conversion fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 06/25] iio: adc: ti-ads124s08: don't push data if reading a channel fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 07/25] iio: adc: ti-ads8688: don't push an error code as a sample Jonathan Cameron
2026-11-29 21:06 ` [PATCH 08/25] iio: adc: ti-ads8688: take the lock in the trigger handler Jonathan Cameron
2026-11-29 21:06 ` [PATCH 09/25] iio: adc: ti-ads8688: fix the endianness in the channel description Jonathan Cameron
2026-11-29 21:06 ` [PATCH 10/25] iio: accel: sca3300: hold the lock across error handling in register access Jonathan Cameron
2026-11-29 21:06 ` [PATCH 11/25] iio: imu: adis16400: don't push stale data if the SPI transfer fails Jonathan Cameron
2026-11-29 21:06 ` [PATCH 12/25] iio: light: si1145: return IRQ_NONE if no interrupt is flagged Jonathan Cameron
2026-11-29 21:06 ` [PATCH 13/25] iio: magnetometer: als31300: print the regmap error code on read failure Jonathan Cameron
2026-11-30 8:38 ` Neil Armstrong
2026-11-29 21:06 ` [PATCH 14/25] iio: magnetometer: tlv493d: fix polling for valid data Jonathan Cameron
2026-11-29 21:06 ` [PATCH 15/25] iio: proximity: isl29501: don't push uninitialized data on read failure Jonathan Cameron
2026-11-29 21:06 ` [PATCH 16/25] iio: pressure: rohm-bm1390: only return IRQ_NONE if data ready is not set Jonathan Cameron
2026-11-30 11:03 ` Matti Vaittinen [this message]
2026-11-30 23:45 ` Jonathan Cameron
2026-12-02 16:01 ` Matti Vaittinen
2026-11-29 21:06 ` [PATCH 17/25] iio: accel: kxcjk-1013: claim direct mode for raw reads Jonathan Cameron
2026-11-29 21:06 ` [PATCH 18/25] iio: accel: mma7455: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 19/25] iio: accel: mxc4005: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 20/25] iio: accel: stk8ba50: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 21/25] iio: chemical: scd30: claim direct mode before taking the lock in read_raw() Jonathan Cameron
2026-11-29 21:06 ` [PATCH 22/25] iio: humidity: hdc100x: " Jonathan Cameron
2026-11-29 21:06 ` [PATCH 23/25] iio: light: as73211: claim direct mode before taking the lock in write_raw() Jonathan Cameron
2026-11-29 21:06 ` [PATCH 24/25] iio: light: veml6046x00: claim direct mode before starting a single read Jonathan Cameron
2026-11-29 21:06 ` [PATCH 25/25] iio: magnetometer: bmc150_magn: claim direct mode for raw reads Jonathan Cameron
2026-11-30 0:20 ` [PATCH 00/25] IIO: Various fixes mostly related to buffered capture 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=6d2e75b8-2711-4144-911b-82a10751a08e@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=abhashkumarjha123@gmail.com \
--cc=ak@it-klinger.de \
--cc=amsfield22@gmail.com \
--cc=andy@kernel.org \
--cc=cdleonard@gmail.com \
--cc=ceggers@arri.de \
--cc=dixitparmar19@gmail.com \
--cc=dlechner@baylibre.com \
--cc=dmurphy@ti.com \
--cc=jic23@kernel.org \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux@analog.com \
--cc=manabian@gmail.com \
--cc=martenli@axis.com \
--cc=maxwell@maxwelld.cc \
--cc=mranostay@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=nuno.sa@analog.com \
--cc=petre.rodan@subdimension.ro \
--cc=pmeerw@pmeerw.net \
--cc=sean@geanix.com \
--cc=sozdayvek@gmail.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tduszyns@gmail.com \
--cc=tiberiu.a.breana@intel.com \
--cc=tomas.melin@vaisala.com \
--cc=tomislav.denis@avl.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