Re: [PATCH v2] thermal/drivers/rcar_thermal: disable the work before masking the interrupt

From: Yaohan Li

Date: Thu Nov 19 2026 - 23:27:51 EST


Hi Niklas,

yes, of course. It is one module, self-contained, and it needs no device
tree or hardware setup - it builds against the tree you give it and runs on
the board you load it on.

The module exercises the three primitives the removal ordering depends on:

- a work queued after cancel_delayed_work_sync() still runs, while the same
queue attempt after disable_delayed_work_sync() is rejected and the work
never runs;
- a work that is already running re-enables the source behind a mask that
was written before the cancellation, and cannot do that when the work is
disabled first;
- on a line shared with another handler, synchronize_irq() does not stop our
handler from being invoked again (and from queueing the work), while
devm_free_irq() does, without disturbing the other user.

To run it:

make KDIR=/path/to/linux
insmod irq_semantics.ko
dmesg | tail -n 25

It needs CONFIG_MODULES and CONFIG_IRQ_SIM (the latter is a hidden symbol,
selected by CONFIG_GPIOLIB plus CONFIG_GPIO_SIM; GPIO_MOCKUP works too but is
deprecated). The last two lines of the log should be

summary: 17 passed, 0 failed
RESULT: PASS

That result is 17 assertions about the workqueue and interrupt primitives,
not about an R-Car unbind: a green run says the kernel behaves the way the
patch assumes, it does not say that rcar_thermal_remove() was exercised on
your board.

The tarball is attached; the README in it has the same instructions and a
reference log. If the list strips the attachment, tell me and I will send it
to you directly.

What the module does not do is run rcar_thermal's own ->remove(). That needs
a real platform device, MMIO and a thermal zone, and the driver's removal
would end up buried under the scaffolding. So it pins down the primitives,
not what the interrupt status registers do on your board.

For that, what I would suggest on your side is to unbind and rebind the
platform device in a loop while the zone is being read, on a KASAN kernel,
and check that no work runs after rcar_thermal_remove() returned and that the
source is not enabled again afterwards. To get real interrupts during the
unbind the overheat source has to fire at least once; on this driver that
happens when the temperature crosses the trip point it has programmed.

If you can tell me which SoC and board you have, and whether the thermal node
in its DT has an interrupt and a critical trip point, I can work out what the
smallest meaningful run is. I am also happy to reshape the module if you
want it to reproduce something else.

Thanks,
Yaohan

Attachment: rcar-thermal-test-20261120.tar.gz
Description: Unix tar archive