Re: [PATCH v2] thermal: rcar_gen3: release the IRQ handlers before the zones are freed

From: Niklas Söderlund

Date: Mon Nov 23 2026 - 01:47:53 EST


Hi Yaohan,

On 2026-11-23 10:21:46 +0800, Yaohan Li wrote:
> 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.

Ahh I see, thanks for explaining it. Will that window not also exist
during probe? Would not a better solution be to rework the order in
probe to eliminate the issue completely?

>
> 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

--
Kind Regards,
Niklas Söderlund