[RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups
Michael Walle
mwalle at kernel.org
Fri Nov 27 06:52:17 PST 2026
The gpio-regmap provides two different variants to attach an IRQ
domain to the gpio-regmap instance, either via .irq_domain or via
.regmap_irq_chip. The former even has a small window where a
consumer requesting an interrupt leads to a NULL pointer
dereference. This also came up during sashiko reviews [1].
It turns out, that it is impossible to create an external IRQ domain
without a race while the gpio-regmap instance isn't created yet.
That is because it will already use the gpio-regmap provided
callbacks. Thus, with this patch series, gpio-regmap will now
provide a callback for the individual drivers used to create an IRQ
domain when all necessary fields are filled.
To move even further and cover the most common use case of having a
regmap-irq domain, gpio-regmap now provides helpers that can be
used in the .create_irq_domain() callback.
We need Long Zhao's patch [2] not only for ACPI but also for the
regmap-irq handling. If the IRQ domain is removed before the
gpio_chip, gpiochip_remove() would use the already freed domain to
free the remaining interrupts.
All the users of regmap-irq are switched over to this new helper.
Finally, the last patch removes the old variants.
There is one change in behavior: sl28cpld, ws16c48 and 104-idi-48
now lock their interrupt lines and cannot switch to output while
they are locked. The remaining ones already used the locking or now
use the _nolock() variant and retain their current behavior.
Also, resource management is hard. I didn't find a good/simple way
to have a correct ordering for releasing the resources. So we now
mandate that there must not be any device resource managed
functions/allocations in the .create_irq_domain(). It has to be
undone manually using the .remove_irq_domain() callback.
Furthermore, rtd1625 and axiado didn't dispose their mappings;
that's fixed, too.
This was mostly only compile-time tested. So please test. I've done
a quick smoke test on the sl28 board.
[1] https://lore.kernel.org/r/20261123040142.48880-1-joseph@telaak.dev
[2] https://lore.kernel.org/r/20261118-cv75-gpio-v15-3-e3c563673fe1@ambarella.com
Changes in v2:
- new patch "gpio: regmap: use the correct number for .ngpio_per_reg"
- add a .remove_irq_domain() callback and use it for rtd1625 and
axiado-sgpio. reported by sashiko
- rtd1625: split interrupt setup into fetching the info in probe
and setting it up in the callback. reported by sashiko
- max7360: make the callback look nice and keep the irq lookup and
the regmap_irq_chip setup in probe.
- add Fixes tags
- new gpio_regmap_add_irq_chip_nolock() for devices where
hwirq != gpio offset, use it for idio-16, pcie-idio-24 and
104-dio-48e
- collected any tags. Andy, due to some major changes, I threw some
away.
v1: https://lore.kernel.org/r/20261126153600.299724-1-mwalle@kernel.org
Long Zhao (1):
gpio: regmap: remove gpiochip before tearing down irqchip
Michael Walle (13):
gpio: regmap: use the correct number for .ngpio_per_reg
gpio: regmap: add callbacks to handle IRQ domains
gpio: rtd1625: create the IRQ domain from the gpio-regmap callback
gpio: axiado-sgpio: create the IRQ domain from the gpio-regmap
callback
gpio: regmap: add helpers to add a regmap-irq chip
gpio: max7360: create the regmap-irq chip from the gpio-regmap
callback
gpio: sl28cpld: create the regmap-irq chip from the gpio-regmap
callback
gpio: idio-16: create the regmap-irq chip from the gpio-regmap
callback
gpio: pcie-idio-24: create the regmap-irq chip from the gpio-regmap
callback
gpio: ws16c48: create the regmap-irq chip from the gpio-regmap
callback
gpio: 104-idi-48: create the regmap-irq chip from the gpio-regmap
callback
gpio: i8255: create the regmap-irq chip from the gpio-regmap callback
gpio: regmap: remove irq_domain and the regmap-irq configuration
drivers/gpio/gpio-104-dio-48e.c | 31 ++++++--
drivers/gpio/gpio-104-idi-48.c | 38 +++++++---
drivers/gpio/gpio-axiado-sgpio.c | 75 ++++++++++++-------
drivers/gpio/gpio-i8255.c | 3 +-
drivers/gpio/gpio-i8255.h | 8 +-
drivers/gpio/gpio-idio-16.c | 28 +++++--
drivers/gpio/gpio-max7360.c | 35 +++++++--
drivers/gpio/gpio-pcie-idio-24.c | 36 ++++++---
drivers/gpio/gpio-regmap.c | 121 ++++++++++++++++++++++++++-----
drivers/gpio/gpio-rtd1625.c | 91 +++++++++++++++--------
drivers/gpio/gpio-sl28cpld.c | 34 ++++++---
drivers/gpio/gpio-ws16c48.c | 36 ++++++---
include/linux/gpio/regmap.h | 49 +++++++++----
13 files changed, 424 insertions(+), 161 deletions(-)
--
2.47.3
More information about the linux-arm-kernel
mailing list