[PATCH v3 2/3] PCI: dw-rockchip: Make the INTx irq setup devm-managed

Niklas Cassel cassel at kernel.org
Tue Sep 22 02:58:00 PDT 2026


On Tue, Sep 22, 2026 at 10:37:01AM +0800, Shawn Lin wrote:
> The irq domain and the chained handler set up by the previous commit
> are resources owned by the device, but nothing releases them if probing
> ever fails after they are set up, and they are not tied to the device
> lifetime in any other way either.
> 
> Tie their lifetime to the device with devres: create the irq domain
> with devm_irq_domain_instantiate() and uninstall the chained handler
> through the rockchip_pcie_intx_chained_release() devres action. The
> driver is builtin and cannot be unbound (suppress_bind_attrs), so probe
> failure is the only path that ever needs this cleanup, and devres takes
> care of it without sprinkling it over every error path.
> 
> Since the irq setup is the last step of rockchip_pcie_configure_rc(),
> the only failure point left after the chained handler is installed is
> devm_add_action_or_reset() itself, whose failure mode runs the action,
> so the handler can never run against the devm-freed rockchip structure.
> devres also unwinds in reverse registration order, so the handler is
> always uninstalled before the domain is removed. There is no devm API
> for chained handlers, hence the small devres action wrapper.
> 
> While at it, drop the now unused rockchip variable from
> rockchip_pcie_host_init().
> 
> Suggested-by: Niklas Cassel <cassel at kernel.org>

Thank you for giving me credit :)

Unfortunately, I don't think that I was the one who suggested this change.
I think you came up with the idea :)


Kind regards,
Niklas



More information about the Linux-rockchip mailing list