Re: [PATCH v2 2/3] gpiolib: release the chip's own lines before numbing it on removal
From: Andy Shevchenko
Date: Fri Nov 27 2026 - 06:46:45 EST
On Fri, Nov 27, 2026 at 09:49:26AM +0200, Adrian Ambrozewicz wrote:
> Commit 5018ada69a04 ("gpio: Move freeing of GPIO hogs before numbing of
> the device") made gpiochip_remove() free the hogs before it clears
> gdev->chip, so that gpiod_free_commit() still calls ->free() for them.
> ACPI event lines, ACPI OpRegion connections and shared lines are still
> released after that: ->free() is skipped for them, and the ACPI event
> IRQs, already freed by gpiochip_free_remaining_irqs(), are freed again.
>
> Release all lines the chip requested for itself, the hogs included,
> after the chip has left the device list, so no new lookup finds the
> chip, and before the numbing. Move the numbing into a helper for the
> next patch.
>
> Reproduced with a test-only ACPI-style event on gpio-sim ("Trying to
> free already-free IRQ" on removal) and a shared gpio-sim line on arm64
> (->free() skipped); with this change, neither.
>
> This depends on "gpiolib: shared: remove the proxies before releasing
> the shared line".
...
> gpiochip_irqchip_remove(gc);
> - acpi_gpiochip_remove(gc);
> of_gpiochip_remove(gc);
I need to look closer for ACPI bits, but above doesn't sound right. Why
of_gpiochip_remove() is not associated with ACPI counterpart? Wouldn't it bring
a completely different experience on the same platform depending on the
firmware in use (DT or ACPI)?
...
> * gpiochip_irqchip_remove() - removes an irqchip added to a gpiochip
> * @gc: the gpiochip to remove the irqchip from
> *
> - * This is called only from gpiochip_remove()
> + * acpi_gpiochip_free_interrupts() below finds nothing once
> + * gpiochip_free_own_lines() has run; it is for the error paths before that.
This doesn't sound right either. Why the common method of freeing ACPI event
interrupts can't be shut down here and this one called when we need to remove
the IRQ chip altogether?
--
With Best Regards,
Andy Shevchenko