Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Rosen Penev <rosenp@gmail.com>,
	Gregory CLEMENT <gregory.clement@bootlin.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	linux-gpio@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: [PATCH 2/2] gpio: mvebu: use a raw-locked regmap on Armada 7K/8K too
Date: Thu,  3 Dec 2026 14:58:20 -0800	[thread overview]
Message-ID: <20261203225820.83277-3-rosenp@gmail.com> (raw)
In-Reply-To: <20261203225820.83277-1-rosenp@gmail.com>

Commit 42269cdb3d3b ("gpio: mvebu: fix sleeping-while-atomic in
mvebu_gpio_level_irq_mask()") made the driver's MMIO regmaps use raw
spinlocks, because the irq_chip mask/unmask callbacks write the mask
registers while holding the generic chip's raw gc->lock.  That only
covers the regmaps the driver creates itself.  On Armada 7K/8K
("marvell,armada-8k-gpio") the GPIO block sits inside a system
controller and the driver uses the parent's syscon regmap, which syscon
creates with an ordinary spinlock.  On PREEMPT_RT that lock sleeps, so
masking or unmasking a GPIO interrupt there still sleeps in atomic
context.

The syscon regmap's lock cannot be changed from here, and nothing else
accesses the GPIO bank's registers at its offset, so the shared lock is
not protecting anything this driver needs.  Map the parent's register
range again and create a regmap of our own with the raw-locked
mvebu_gpio_regmap_config, as the non-syscon path already does.  The
mapping is not requested, as syscon does not request it either.

Fixes: b6730b20837e ("gpio: mvebu: Add support for the Armada 7K/8K SoCs")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/gpio/gpio-mvebu.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index c202b946f595..a2974515b408 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -42,8 +42,8 @@
 #include <linux/irq.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/irqdomain.h>
-#include <linux/mfd/syscon.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
@@ -1167,7 +1167,29 @@ static int mvebu_gpio_probe_raw(struct platform_device *pdev,
 static int mvebu_gpio_probe_syscon(struct platform_device *pdev,
 				   struct mvebu_gpio_chip *mvchip)
 {
-	mvchip->regs = syscon_node_to_regmap(pdev->dev.parent->of_node);
+	struct device_node *np = pdev->dev.parent->of_node;
+	void __iomem *base;
+	struct resource res;
+	int ret;
+
+	/*
+	 * The GPIO registers live inside the parent system controller, but
+	 * don't use its syscon regmap: that one is created with a normal
+	 * spinlock, which sleeps on PREEMPT_RT, and the irq_chip callbacks
+	 * write the mask registers under the raw gc->lock. This driver is
+	 * the only user of the registers at its offset, so map the parent's
+	 * range again and access it through a raw-locked regmap of our own.
+	 */
+	ret = of_address_to_resource(np, 0, &res);
+	if (ret)
+		return ret;
+
+	base = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
+	if (!base)
+		return -ENOMEM;
+
+	mvchip->regs = devm_regmap_init_mmio(&pdev->dev, base,
+					     &mvebu_gpio_regmap_config);
 	if (IS_ERR(mvchip->regs))
 		return PTR_ERR(mvchip->regs);
 
-- 
2.56.1


      parent reply	other threads:[~2026-12-03 22:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 22:58 [PATCH 0/2] gpio: mvebu: resume and PREEMPT_RT irq mask fixes Rosen Penev
2026-12-03 22:58 ` [PATCH 1/2] gpio: mvebu: restore suspend-time irq masks under gc->lock Rosen Penev
2026-12-03 22:58 ` Rosen Penev [this message]

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=20261203225820.83277-3-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=bigeasy@linutronix.de \
    --cc=brgl@kernel.org \
    --cc=clrkwllms@kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=rostedt@goodmis.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