Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Walle <mwalle@kernel.org>
To: William Breathitt Gray <wbg@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Petar Stepanovic <pstepanovic@axiado.com>,
	SriNavmani A <srinavmani@axiado.com>,
	Prasad Bolisetty <pbolisetty@axiado.com>,
	Tzu-Hao Wei <twei@axiado.com>,
	Karthikeyan Mitran <kmitran@axiado.com>,
	Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>,
	Michael Walle <mwalle@kernel.org>, Lee Jones <lee@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Long Zhao <longzhao@ambarella.com>,
	Joseph Telaak <joseph@telaak.dev>
Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups
Date: Fri, 27 Nov 2026 15:52:17 +0100	[thread overview]
Message-ID: <20261127145232.814492-1-mwalle@kernel.org> (raw)

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



             reply	other threads:[~2026-11-27 14:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 14:52 Michael Walle [this message]
2026-11-27 14:52 ` [RFT PATCH v2 01/14] gpio: regmap: use the correct number for .ngpio_per_reg Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 02/14] gpio: regmap: remove gpiochip before tearing down irqchip Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 05/14] gpio: axiado-sgpio: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 08/14] gpio: sl28cpld: create the regmap-irq chip from the gpio-regmap callback Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 09/14] gpio: idio-16: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 10/14] gpio: pcie-idio-24: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 11/14] gpio: ws16c48: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 12/14] gpio: 104-idi-48: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 13/14] gpio: i8255: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 14/14] gpio: regmap: remove irq_domain and the regmap-irq configuration Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127145232.814492-1-mwalle@kernel.org \
    --to=mwalle@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@kernel.org \
    --cc=joseph@telaak.dev \
    --cc=kmitran@axiado.com \
    --cc=lee@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=longzhao@ambarella.com \
    --cc=mathieu.dubois-briand@bootlin.com \
    --cc=pbolisetty@axiado.com \
    --cc=pstepanovic@axiado.com \
    --cc=srinavmani@axiado.com \
    --cc=twei@axiado.com \
    --cc=wbg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox