mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
To: Linus Walleij <linusw@kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	Horatiu Vultur <horatiu.vultur@microchip.com>,
	Colin Foster <colin.foster@in-advantage.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Lee Jones <lee@kernel.org>,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rt-devel@lists.linux.dev,
	"Jens Emil Schulz Østergaard"
	<jensemil.schulzostergaard@microchip.com>
Subject: [PATCH 1/2] pinctrl: ocelot: use a raw spinlock for the GPIO regmap
Date: Mon, 9 Nov 2026 14:50:41 +0100	[thread overview]
Message-ID: <20261109-ocelot-pinctrl-irqchip-fixes-v1-1-9d2d8fcd58f5@microchip.com> (raw)
In-Reply-To: <20261109-ocelot-pinctrl-irqchip-fixes-v1-0-9d2d8fcd58f5@microchip.com>

The irq_chip callbacks .irq_mask, .irq_unmask and .irq_ack access the
GPIO regmap. genirq calls them with the raw spinlock irq_desc::lock
held, for example from irq_startup() in __setup_irq(). The regmap is
created with devm_regmap_init_mmio() and guarded by a spinlock_t, which
is a sleeping lock on PREEMPT_RT and must not be taken under a raw
spinlock.

Make the GPIO regmap use a raw spinlock. Its accesses are short MMIO
reads and writes. The other regmaps of the driver are not used from the
irq_chip callbacks and are left unchanged.

The issue was found with CONFIG_PROVE_RAW_LOCK_NESTING on a lan9668
board (pcb8385), when a level low interrupt on one of its GPIOs is
requested, and was seen on lan969x when a PHY interrupt on a GPIO is
requested:

  =============================
  [ BUG: Invalid wait context ]
  -----------------------------
  swapper/0/1 is trying to lock:
  c3046c10 (pinctrl_ocelot:34:(config)->lock){....}-{3:3}, at: regmap_lock_spinlock+0xc/0x40
  other info that might help us debug this:
  context-{5:5}
  locks held by swapper/0/1: 6, last CPU#0:
   ...
   #4: c3200b5c (request_class){+.+.}-{4:4}, at: __setup_irq+0x140/0x840
   #5: c3200a7c (lock_class){....}-{2:2}, at: __setup_irq+0x168/0x840
  stack backtrace:
  ...
   _raw_spin_lock_irqsave from regmap_lock_spinlock+0xc/0x40
   regmap_lock_spinlock from regmap_read+0x2c/0x80
   regmap_read from ocelot_irq_unmask_level+0x6c/0x240
   ocelot_irq_unmask_level from irq_enable+0x38/0xc0
   irq_enable from __irq_startup+0x70/0xc0
   __irq_startup from irq_startup+0xb8/0x180
   irq_startup from __setup_irq+0x4d0/0x840
   __setup_irq from request_threaded_irq+0xbc/0x180
   request_threaded_irq from devm_request_threaded_irq+0x70/0x140

With the fix the report is gone on the lan9668 board.

Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
Signed-off-by: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
---
 drivers/pinctrl/pinctrl-ocelot.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
index 58d3cde9f964..06dd49782d74 100644
--- a/drivers/pinctrl/pinctrl-ocelot.c
+++ b/drivers/pinctrl/pinctrl-ocelot.c
@@ -2440,6 +2440,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
 		.reg_bits = 32,
 		.val_bits = 32,
 		.reg_stride = 4,
+		.use_raw_spinlock = true,
 	};
 
 	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);

-- 
2.52.0


  reply	other threads:[~2026-11-09 13:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 13:50 [PATCH 0/2] pinctrl: ocelot: fix the GPIO irqchip context handling Jens Emil Schulz Østergaard
2026-11-09 13:50 ` Jens Emil Schulz Østergaard [this message]
2026-11-09 13:50 ` [PATCH 2/2] pinctrl: ocelot: do not use the chained irqchip behind a sleeping bus Jens Emil Schulz Østergaard

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=20261109-ocelot-pinctrl-irqchip-fixes-v1-1-9d2d8fcd58f5@microchip.com \
    --to=jensemil.schulzostergaard@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=colin.foster@in-advantage.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=lee@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=vladimir.oltean@nxp.com \
    /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

all inboxes | Powered by JetHome®