Skip to content

gpiolib: Handle immutable irq_chip structures

Marc Zyngier linux-arm-kernel linux-arm-msm linux-gpio linux-tegra lkml 3 versions – Applied

Status from this message: The following commit has been merged into the irq/irqchip-next branch of irqchip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest10 patches 14 repliesApplied
  2. v210 patches 5 repliesSuperseded
  3. v15 patches 10 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/10gpio: Don't fiddle with irqchips marked as immutabledrivers/gpio/gpiolib.c include/linux/irq.h kernel/irq/debugfs.c+9 -10 replies
2/10gpio: Expose the gpiochip_irq_re[ql]res helpersdrivers/gpio/gpiolib.c include/linux/gpio/driver.h+8 -20 replies
3/10gpio: Add helpers to ease the transition towards immutable irq_chipinclude/linux/gpio/driver.h+12 -00 replies
4/10gpio: tegra186: Make the irqchip immutabledrivers/gpio/gpio-tegra186.c+23 -90 replies
5/10gpio: pl061: Make the irqchip immutabledrivers/gpio/gpio-pl061.c+23 -90 replies
6/10pinctrl: apple-gpio: Make the irqchip immutabledrivers/pinctrl/pinctrl-apple-gpio.c+16 -130 replies
7/10pinctrl: msmgpio: Make the irqchip immutabledrivers/pinctrl/qcom/pinctrl-msm.c+33 -200 replies
8/10pinctrl: amd: Make the irqchip immutabledrivers/pinctrl/pinctrl-amd.c+8 -30 replies
9/10gpio: Update TODO to mention immutable irq_chip structuresdrivers/gpio/TODO+19 -00 replies
10/10Documentation: Update the recommended pattern for GPIO irqchipsDocumentation/driver-api/gpio/driver.rst+142 -330 replies

Reviews trailers per patch

7 of 10 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAndy ShevchenkoBartosz GolaszewskiThierry RedingLinus Walleij
SeriesA-b
1/10R-b R-b
2/10R-b R-b
3/10R-b R-b
4/10R-b A-b
5/10R-b
6/10
7/10
8/10
9/10R-b R-b
10/10R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/10] gpiolib: Handle immutable irq_chip structures

This is a followup from [2].

I recently realised that the gpiolib play ugly tricks on the unsuspecting irq_chip structures by patching the callbacks.

Not only this breaks when an irq_chip structure is made const (which really should be the default case), but it also forces this structure to be copied at nauseam for each instance of the GPIO block, which is a waste of memory.

My current approach is to add a new irq_chip flag (IRQCHIP_IMMUTABLE) which does what it says on the tin: don't you dare writing to them. Gpiolib is further updated not to install its own callbacks, and it becomes the responsibility of the driver to call into the gpiolib when required. This is similar to what we do for other subsystems such as PCI-MSI.

5 drivers are updated to this new model: M1, QC, Tegra, pl061 and AMD (as I actively use them) keeping a single irq_chip structure, marking it const, and exposing the new flag.

Nothing breaks, the volume of change is small, the memory usage goes down and we have fewer callbacks that can be used as attack vectors. What's not to love?

Since there wasn't any objection in the previous round of review, I'm going to take this series into -next to see if anything breaks at scale.

Thanks,

	M.

* From v2 [2]:
- Fixed documentation
- Collected RBs, with thanks

* From v1 [1]:
- pl061 and AMD drivers converted
- New helpers to keep the changes small
- New warning for non-converted drivers
- Documentation and TODO updates

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]

Marc Zyngier (10):
gpio: Don't fiddle with irqchips marked as immutable
gpio: Expose the gpiochip_irq_re[ql]res helpers
gpio: Add helpers to ease the transition towards immutable irq_chip
gpio: tegra186: Make the irqchip immutable
gpio: pl061: Make the irqchip immutable
pinctrl: apple-gpio: Make the irqchip immutable
pinctrl: msmgpio: Make the irqchip immutable
pinctrl: amd: Make the irqchip immutable
gpio: Update TODO to mention immutable irq_chip structures
Documentation: Update the recommended pattern for GPIO irqchips

 Documentation/driver-api/gpio/driver.rst | 175 ++++++++++++++++++-----
 drivers/gpio/TODO                        |  19 +++
 drivers/gpio/gpio-pl061.c                |  32 +++--
 drivers/gpio/gpio-tegra186.c             |  32 +++--
 drivers/gpio/gpiolib.c                   |  13 +-
 drivers/pinctrl/pinctrl-amd.c            |  11 +-
 drivers/pinctrl/pinctrl-apple-gpio.c     |  29 ++--
 drivers/pinctrl/qcom/pinctrl-msm.c       |  53 ++++---
 include/linux/gpio/driver.h              |  16 +++
 include/linux/irq.h                      |   2 +
 kernel/irq/debugfs.c                     |   1 +
 11 files changed, 293 insertions(+), 90 deletions(-)
Signature · 1 line
2.34.1