Re: [PATCH v2] thermal/drivers/rcar_thermal: disable the work before masking the interrupt
From: Yaohan Li
Date: Thu Nov 19 2026 - 06:18:47 EST
Hi Niklas,
thanks for the review. The code changes you asked for are in my tree, and I
would like to check the testing question with you before posting a v3.
The delayed work is now disabled before the interrupt source is masked, so
the handler cannot queue new work after the cancellation, and a work that is
already running cannot re-enable the source behind the mask. The shared
interrupt is unregistered with devm_free_irq() rather than waited for with
synchronize_irq(): the line stays registered for its other users, and they
can raise it again after synchronize_irq() returns. The RCAR_THERMAL_MAX_IRQ
comment, the loop variable and the two comments in rcar_thermal_remove() are
as you suggested, and the shutdown flag is gone.
On testing: there is no R-Car hardware here, so what I have is a controlled
ordering test on a KASAN kernel, 17 checks, all passing. It uses the real
delayed work, workqueue, wait and signal machinery and a simulated interrupt
line shared by two handlers. It shows that a work queued after
cancel_delayed_work_sync() still runs while the same queue attempt after
disable_delayed_work_sync() is rejected, that a running work undoes a mask
written before the cancellation, and that after synchronize_irq() another
user of the line can invoke our handler again while devm_free_irq() ends
that.
What the test does not do is run rcar_thermal's own ->remove(). It
re-implements the removal ordering, because exercising the driver would need
a real platform device, MMIO and a thermal zone, so the behaviour of the
interrupt status registers on real hardware remains unverified.
I can send the v3 with these changes if that is useful; if you would rather
see a different shape for the removal sequence, I will rework that first.
Thanks,
Yaohan