All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "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,
	"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: Wed, 2 Dec 2026 18:01:35 +0200	[thread overview]
Message-ID: <c10586c1-bf70-42e3-91cf-151e862834d8@gmail.com> (raw)
In-Reply-To: <20261130234510.35cb704c@jic23-hlaptop>

On 01/12/2026 01:45, Jonathan Cameron wrote:
> On Mon, 30 Nov 2026 13:03:23 +0200
> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> 
>> 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.
> 
> I fully agree with the argument for a general interrupt, but these
> aren't real interrupts  - those are on the trigger side of the
> trigger /pollfunc divide.

Ah, right! I only now see this! (Dangnabbit, after I already wrote all 
the other replies in this post - need to go edit them)

Maybe we can move the status-reading in bm1390_irq_thread_handler(), 
inside the if (data->trigger_enabled)? Perhaps we should also store the 
status in the driver data before calling the iio_trigger_poll_nested(). 
So, the trigger handler could then read the status if it was not read by 
the trigger.

  This part should not be deciding if we have
> an interrupt but should be acting on that interrupt. The trigger
> side should figure out if there is one to handle. Blocking that
> real interrupt is the ideal outcome of the spurious IRQ detection
> code.
> 
> I understand that divide gets tricky in some devices where the act
> of reading the status register is required prior to a read because
> otherwise we don't get fresh data.
> 
> I'm not sure if that change is possible here or not.

Not sure either :)
I did dig out my old questions I sent to the HQ, and answers I received. 
Judging these, the status register reading will ACK the data-ready 
interrupt (which is a level IRQ, so acking is required). It was not 
explicitly said if new sample(s) are accepted while data-ready IRQ stays 
active. The data-sheet however says that the data-ready should be used 
as an indication, that there is new temperature and pressure data available.

Furthermore, reading the status register does NOT clear the FIFO_FULL or 
WATERMARK IRQs. Those are cleared when samples are read and actual fifo 
state changes.

> The self triggered case looks simple as it's either side of a function
> call.

This is probably the only case I thought of when writing the driver. I 
have no idea if/how people are using this driver though. Anyways, I need 
to admit I am not familiar with how things look when one is using some 
other trigger. Never worked with such setup, so it's a bit hard for me 
to picture. As a hindsight, I should probably have restricted this to 
own trigger as it was the only trigger I ever really tested.

>  For the case where we are using a different trigger I'm not sure
> why we have the status check.  Is it required to get valid data, or

My understanding is that the data, after it has been sampled, can be 
read without reading the status-register first. The data-sheet is not 
explicit on this though. Anyways, if we don't read the status, we don't 
actually know if the sampling had been done and if we had valid data in 
registers. So yes, it is kind of required.

> is it to try and ensure fresh data (which we don't guarantee at all
> if using a random trigger).

I don't know if new data is sampled if data-ready is not acked. There is 
no explicit information in data-sheet. It says that the data should be 
read using burst-read to ensure it does not get partially overwritten - 
but I don't know if this assumes the status has been read before data.

>>> 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.
> 
> This is the tricky corner that I mention in reply to the cover letter.
> I'm not sure if we should just always call iio_trigger_notify_done()
> for this style of driver (one where it is expected to be called in
> the interrupt handler).  We can't do that in general because
> there are a few drivers where that action be delayed to an entirely
> different place in the code.  A few series in my tree after this one
> comes a patch that flags those less common cases and that allows us
> to drop the need for explicit iio_trigger_notify_done() in vast majority
> of drivers (with big knock on effects on code simplicity).
> 
> To me it does feel wrong to say we are done with a trigger when we haven't
> done anything, but we do potentially end up wedged otherwise. Maybe
> we can figure out a recovery path from that wedging but it is going
> to be nasty code to handle an unlikely event.

If the bus to device is failing, then the only workaround I can think of 
is disabling the host-side IRQ. This would be duplicating the IRQ_NONE 
'safety logic' in IRQ core. Furthermore, if someone used shared IRQs, 
then individual driver doing the disabling would really be stepping on 
someone elses toes :) I'd rather kept this kind of decisions in the IRQ 
core level. But yes - you're right that in this driver, the IRQ_NONE 
should be returned from the bm1390_irq_thread_handler() !

>>
>> 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.
>>
> 
> Entirely valid questions!  This was the bit of this series I least
> liked. Ultimately we can separate IRQ_NONE from whether we call
> iio_trigger_notify_done()

To me this sounds like it could be the right thing to do. Not sure how 
that should be done though. :)

> but we do need consistency to enable
> wider cleanup.

This is something you have far better understanding :)

I have some (very simple and limited) automated test set which is 
testing the driver on a bm1390 attached to beaglebone, when new Linux 
release (or tag from next) is done. Right now I can't offer much time 
for bm1390 development - but I can at least run some basic test set on 
patched kernel if needed. Not sure how beneficial it ends up being 
though. The test set does not have anything to catch error scenarios 
like an IRQ storm, but is mostly limited to measuring 
pressure/temperature (in very constant environment) and checking the 
values look somehow sane...

I will, however, add this to my (endless) TODO-list. Just please, don't 
hold your breath waiting - we need you as the IIO maintainer (amongst 
other things), so some level of oxygen should be guaranteed XD

Yours,
	-- Matti


-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductor
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~

  reply	other threads:[~2026-12-02 16:01 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
2026-11-30 23:45     ` Jonathan Cameron
2026-12-02 16:01       ` Matti Vaittinen [this message]
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=c10586c1-bf70-42e3-91cf-151e862834d8@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 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.