Re: [PATCH 1/2] iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context

Christian Eggers
2020-10-02T14:10:44Z

Hi Jonathan,

On Monday, 21 September 2020, 11:57:03 CEST, Jonathan Cameron wrote:
> On Mon, 21 Sep 2020 09:17:26 +0200
>
> Christian Eggers <ceggers@arri.de> wrote:
> > Tested together with
> >
> > - iio: Fix: Do not poll the driver again if try_reenable() callback
> > returns non 0. and
> > - iio:trigger: rename try_reenable() to reenable() plus return void
> >
> > on latest mainline (without PREEMPT_RT). The original WARN_ONCE() in
> > kernel/irq/handle.c:159 was not raised anymore. But even without the
> > current patches, this warning is not shown (as this problem only applies
> > to -RT).
> >
> > Currently I haven't ported a RT kernel > 5.4 for my board, so I cannot
> > check with current RT. On 5.4. there the patches seem not to work fully
> > as kernel/timer/hrtimer.c is not up to date enough.
> >
> > Sorry for being not very helpful...
>
> Thanks for at least trying!

I've just ported my BSP to v5.9-rc7-rt10. It looks like your patch misses one
additional change in iio_trig_hrtimer_set_state():

- hrtimer_start(&trig_info->timer, trig_info->period,
- HRTIMER_MODE_REL);
+ hrtimer_start(&trig_info->timer, trig_info->period,
+ HRTIMER_MODE_REL_HARD);

Without this, WARN_ON_ONCE() in kernel/time/hrtimer.c:1133 will be hit:

WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard);

So the mode HRTIMER_MODE_REL_HARD is required for hrtimer_init() (will be
stored in timer->is_hard) and for hrtimer_start().

Best regards
Christian