From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Christian Eggers <ceggers@arri.de>,
linux-iio@vger.kernel.org, tglx@linutronix.de
Subject: Re: [PATCH 1/2] iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context
Date: Thu, 13 Aug 2020 13:27:41 +0200 [thread overview]
Message-ID: <20200813112741.grdytusuwrlskpwa@linutronix.de> (raw)
In-Reply-To: <930e6dc4-df6f-416b-0df3-dab7177af974@metafoo.de>
On 2020-08-13 11:46:30 [+0200], Lars-Peter Clausen wrote:
>
> It should not affect the IRQ handlers of individual drivers. The hrtimer
> triggers acts like an IRQ chip and will call generic_handle_irq() to
> multiplex the interrupt handling onto all consumers. As far as I understand
> it there is a requirement that generic_handle_irq() is called in hard irq
> context, even with PREEMT_RT=y.
That is correct.
> If you are running with forced IRQ threads the only thing that will then
> happen in the actual hard IRQ context is the launching of the IRQ threads.
> Th e IRQ handler of the device driver will run in a threaded IRQ.
So if it is really just the wakeup of the IRQ-thread then it should be
okay.
One thing: iio_trigger_poll() may invoke iio_trigger_notify_done(). This
would invoke trig->ops->try_reenable callback if available.
I grepped and found
- bma180_trig_try_reen()
It appears to perform i2c_smbus_read_byte_data() and smbus sounds
sleeping. I don't know if it attempts to acquire any spinlock_t but it
will be wrong on RT.
- bmc150_accel_trig_try_reen()
This one has mutex_lock() which is wrong even on !RT in this context
(unless the previous `if' saves us).
- mxc4005_trigger_try_reen()
This one uses regmap_write(). regmap internally uses a lock and the
config does not disable / provide a lock. This means
regmap_lock_mutex() is used (or regmap_lock_spinlock() in case of
bus->fast_io but I doubt it with i2c).
Am I looking somehow wrong at this or did just nobody try the
combination of one of the three drivers here together with the hrtimer
trigger?
> >
> > Has this change (including the second patch in thread) been tested on RT
> > in terms of locking and latency?
>
> It has not been tested in terms of latency. But like I said if you are
> running with forced IRQ threads the effect should be minimal.
>
> Without this patch there is an correctness issue when PREEMT_RT=y since
> generic_handle_irq() runs with interrupts on which breaks its internal
> assumptions.
I'm trying to understand the scope of the change. As I said above, if it
is just wakeup of the thread, then it is fine. I have memory of people
running iio drivers (or triggers) in hardirq-context for $reason and try
avoid something like this.
Sebastian
next prev parent reply other threads:[~2020-08-13 11:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 7:53 [PATCH 1/2] iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context Lars-Peter Clausen
2020-08-13 7:53 ` [PATCH 2/2] iio: sysfs-trigger: Mark irq_work to expire in hardirq context Lars-Peter Clausen
2020-08-13 9:11 ` [PATCH 1/2] iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context Sebastian Andrzej Siewior
2020-08-13 9:46 ` Lars-Peter Clausen
2020-08-13 11:27 ` Sebastian Andrzej Siewior [this message]
2020-08-13 12:19 ` Thomas Gleixner
2020-08-13 14:55 ` Jonathan Cameron
2020-08-14 5:24 ` Lars-Peter Clausen
2020-08-14 10:30 ` Jonathan Cameron
2020-09-20 18:15 ` Jonathan Cameron
2020-09-21 7:17 ` Christian Eggers
2020-09-21 9:57 ` Jonathan Cameron
2020-09-21 12:27 ` Sebastian Andrzej Siewior
2020-09-21 13:32 ` Jonathan Cameron
2020-09-22 2:51 ` Andy Duan
2020-09-24 6:41 ` Sanchayan Maity
2020-09-24 8:54 ` Stefan Agner
2020-09-25 12:42 ` Jonathan Cameron
2020-10-02 14:10 ` Christian Eggers
2020-10-10 13:23 ` 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=20200813112741.grdytusuwrlskpwa@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=ceggers@arri.de \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--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;
as well as URLs for NNTP newsgroup(s).