Re: [PATCH v13 08/13] gpio: regmap: remove gpiochip before tearing down irqchip
From: Andy Shevchenko
Date: Tue Nov 03 2026 - 12:50:39 EST
On Mon, Nov 02, 2026 at 09:33:20AM +0100, Michael Walle wrote:
> On Mon Nov 2, 2026 at 7:46 AM CET, Long Zhao via B4 Relay wrote:
> >
> > gpio_regmap_unregister() currently calls regmap_del_irq_chip() before
> > gpiochip_remove(). That disposes the mapped virtual IRQs and frees the
> > irq_domain while ACPI GPIO-signaled events may still be requested and
> > while gpiod_free_irqs() still needs gc->irq.domain.
>
> Maybe Andy have an opinion here. But that deviated from the usual
> cleanup in the reverse order and at least deserves a comment in the
> code.
Yeah, this is unfortunate. I think to make it work as proposed the IRQ domain
handling in GPIOLIB should be revisited. So, at least a good comment is a must,
indeed.
> > Remove the gpio_chip first so ACPI teardown and USED_AS_IRQ cleanup run
> > against a live domain, then delete the regmap irqchip. Use the same
> > order on the registration error path, which previously leaked the
> > irqchip when gpiochip_irqchip_add_domain() failed after
> > regmap_add_irq_chip_fwnode().
>
> This should be split into a seperate patch with a Fixes: tag.
Not sure if we need a separate change here as two are coupled.
I leave it to Bart to decide.
--
With Best Regards,
Andy Shevchenko