[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220223154405.54912-1-maz@kernel.org>
Date: Wed, 23 Feb 2022 15:44:00 +0000
From: Marc Zyngier <maz@...nel.org>
To: linux-kernel@...r.kernel.org
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Thierry Reding <thierry.reding@...il.com>,
Joey Gouly <joey.gouly@....com>,
Jonathan Hunter <jonathanh@...dia.com>,
Hector Martin <marcan@...can.st>,
Sven Peter <sven@...npeter.dev>,
Alyssa Rosenzweig <alyssa@...enzweig.io>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Andy Gross <agross@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-gpio@...r.kernel.org, linux-tegra@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-arm-msm@...r.kernel.org, kernel-team@...roid.com
Subject: [PATCH 0/5] gpiolib: Handle immutable irq_chip structures
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 there.
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.
3 drivers are updated to this new model: M1, QC and Tegra, as I
actively use them (though Tegra is hosed at the moment), 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.
Another approach was to let gpiolib provide its own irq_chip structure
and stack it, but:
- only a few drivers are hierarchy aware
- the diversity of interrupt flows makes it impractical
I'd welcome comments on the approach. If deemed acceptable, there are
another 300+ drivers to update! Not to mention the documentation. I
appreciate that this is a lot of potential changes, but the current
situation is messy.
Note that these patches are on top of irqchip-next, which contains
more constifying work.
M.
Marc Zyngier (5):
gpio: Don't fiddle with irqchips marked as immutable
gpio: Expose the gpiochip_irq_re[ql]res helpers
pinctrl: apple-gpio: Make the irqchip immutable
pinctrl: msmgpio: Make the irqchip immutable
gpio: tegra186: Make the irqchip immutable
drivers/gpio/gpio-tegra186.c | 33 ++++++++++++-----
drivers/gpio/gpiolib.c | 13 +++++--
drivers/pinctrl/pinctrl-apple-gpio.c | 30 +++++++++-------
drivers/pinctrl/qcom/pinctrl-msm.c | 53 +++++++++++++++++-----------
include/linux/gpio/driver.h | 4 +++
include/linux/irq.h | 2 ++
kernel/irq/debugfs.c | 1 +
7 files changed, 91 insertions(+), 45 deletions(-)
--
2.30.2
Powered by blists - more mailing lists