Re: [PATCH v2] thermal: rcar_gen3: release the IRQ handlers before the zones are freed
From: Yaohan Li
Date: Sun Nov 22 2026 - 21:22:02 EST
Hi Niklas,
The explicit devm_free_irq() calls are needed because of the current devres
registration order. rcar_gen3_thermal_request_irqs() runs before the loop
that calls devm_thermal_of_zone_register(). On teardown, devres therefore
unregisters the zones before freeing the IRQ handlers. During that interval,
rcar_gen3_thermal_irq() can still call thermal_zone_device_update() through
tsc->zone, which is not cleared when the zone is unregistered.
Masking the source and freeing the IRQs in ->remove() closes that window;
free_irq() also waits for a threaded handler that is already running.
Requesting the IRQs after the zones would make the automatic release order
correct. But probe currently uses the return value of
rcar_gen3_thermal_request_irqs() to select priv->ops.set_trips before zone
registration, and rcar_gen3_thermal_init() enables the source depending on
that callback. Reordering would therefore need changes to probe setup and
failure handling, rather than just moving one call. I kept this revision
focused on teardown.
I have shortened the two comments as suggested. I will hold off on v3 until
we have agreed on the approach.
Thanks,
Yaohan