All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/10] gpiolib: Handle immutable irq_chip structures
@ 2022-04-19 14:18 ` Marc Zyngier
  0 siblings, 0 replies; 60+ messages in thread
From: Marc Zyngier @ 2022-04-19 14:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Thierry Reding, Joey Gouly,
	Jonathan Hunter, Hector Martin, Sven Peter, Alyssa Rosenzweig,
	Bjorn Andersson, Andy Gross, Jeffrey Hugo, Thomas Gleixner,
	Basavaraj Natikar, Shyam Sundar S K, Andy Shevchenko, linux-gpio,
	linux-tegra, linux-arm-kernel, linux-arm-msm, kernel-team

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/20220223154405.54912-1-maz@kernel.org
[2] https://lore.kernel.org/r/20220405135444.199295-1-maz@kernel.org

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(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2022-05-13  8:53 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 14:18 [PATCH v3 00/10] gpiolib: Handle immutable irq_chip structures Marc Zyngier
2022-04-19 14:18 ` Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 01/10] gpio: Don't fiddle with irqchips marked as immutable Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 02/10] gpio: Expose the gpiochip_irq_re[ql]res helpers Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 03/10] gpio: Add helpers to ease the transition towards immutable irq_chip Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 04/10] gpio: tegra186: Make the irqchip immutable Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 05/10] gpio: pl061: " Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 06/10] pinctrl: apple-gpio: " Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 07/10] pinctrl: msmgpio: " Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 08/10] pinctrl: amd: " Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:29   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 09/10] gpio: Update TODO to mention immutable irq_chip structures Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:28   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-19 14:18 ` [PATCH v3 10/10] Documentation: Update the recommended pattern for GPIO irqchips Marc Zyngier
2022-04-19 14:18   ` Marc Zyngier
2022-04-19 14:28   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-04-22 21:24 ` [PATCH v3 00/10] gpiolib: Handle immutable irq_chip structures Linus Walleij
2022-04-22 21:24   ` Linus Walleij
2022-04-23 10:30   ` Marc Zyngier
2022-04-23 10:30     ` Marc Zyngier
2022-04-26 10:24     ` Andy Shevchenko
2022-04-26 10:24       ` Andy Shevchenko
2022-04-26 21:59       ` Linus Walleij
2022-04-26 21:59         ` Linus Walleij
2022-05-04 21:21     ` Linus Walleij
2022-05-04 21:21       ` Linus Walleij
2022-05-05  8:09       ` Marc Zyngier
2022-05-05  8:09         ` Marc Zyngier
2022-05-05 12:58       ` Bartosz Golaszewski
2022-05-05 12:58         ` Bartosz Golaszewski
2022-05-05 14:50         ` Linus Walleij
2022-05-05 14:50           ` Linus Walleij
2022-05-12 17:08 ` Andy Shevchenko
2022-05-12 17:08   ` Andy Shevchenko
2022-05-12 17:35   ` Andy Shevchenko
2022-05-12 17:35     ` Andy Shevchenko
2022-05-12 22:18     ` Marc Zyngier
2022-05-12 22:18       ` Marc Zyngier
2022-05-13  8:43       ` Andy Shevchenko
2022-05-13  8:43         ` Andy Shevchenko
2022-05-13  8:51         ` Marc Zyngier
2022-05-13  8:51           ` Marc Zyngier
2022-05-12 22:15   ` Marc Zyngier
2022-05-12 22:15     ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.