Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context

On PREEMPT_RT enabled kernels unmarked hrtimers are moved into soft
interrupt expiry mode by default.

The IIO hrtimer-trigger needs to run in hard interrupt context since it
will end up calling generic_handle_irq() which has the requirement to run
in hard interrupt context.

Explicitly specify that the timer needs to run in hard interrupt context by
using the HRTIMER_MODE_REL_HARD flag.

Fixes: f5c2f0215e36 ("hrtimer: Move unmarked hrtimers to soft interrupt expiry on RT")
Reported-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20201117103751.16131-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Lars-Peter Clausen and committed by
Jonathan Cameron
0178297c 8a067200

+2 -2
+2 -2
drivers/iio/trigger/iio-trig-hrtimer.c
··· 102 102 103 103 if (state) 104 104 hrtimer_start(&trig_info->timer, trig_info->period, 105 - HRTIMER_MODE_REL); 105 + HRTIMER_MODE_REL_HARD); 106 106 else 107 107 hrtimer_cancel(&trig_info->timer); 108 108 ··· 132 132 trig_info->swt.trigger->ops = &iio_hrtimer_trigger_ops; 133 133 trig_info->swt.trigger->dev.groups = iio_hrtimer_attr_groups; 134 134 135 - hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 135 + hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 136 136 trig_info->timer.function = iio_hrtimer_trig_handler; 137 137 138 138 trig_info->sampling_frequency = HRTIMER_DEFAULT_SAMPLING_FREQUENCY;