mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpiolib: Remove big fat warning in gpiochip_get_direction()
@ 2026-06-02 11:30 Christophe Leroy (CS GROUP)
  2026-06-02 16:13 ` Bartosz Golaszewski
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-06-02 11:30 UTC (permalink / raw)
  To: PRAT Maximilien, Linus Walleij, Dmitry Torokhov, Bartosz Golaszewski
  Cc: Christophe Leroy (CS GROUP), linux-gpio, linux-kernel

Since kernel v6.15 the following big fat warning is encountered when
reading /sys/kernel/debug/gpio, leading to kernel latency while
emiting the warning, and panicing on systems configured to panic on
warnings.

  ------------[ cut here ]------------
  WARNING: drivers/gpio/gpiolib.c:423 at gpiochip_get_direction+0x3c/0x48, CPU#0: cat/12531
  CPU: 0 UID: 0 PID: 12531 Comm: cat Tainted: G        W           7.0.10-gitc72c39~-01802-g28c351659258 #27 PREEMPT
  Tainted: [W]=WARN
  Hardware name: MIAE 8xx 0x500000 CMPC885
  NIP:  c043c2f8 LR: c043d740 CTR: 00000000
  REGS: ca89bc20 TRAP: 0700   Tainted: G        W            (7.0.10-gitc72c39~-01802-g28c351659258)
  MSR:  00029032 <EE,ME,IR,DR,RI>  CR: 24004884  XER: 00000302

  GPR00: c043f3f0 ca89bce0 c3278000 c20b5f20 0000000d 00000002 00000000 c0a76208
  GPR08: 00000001 00000000 cccccccd c313d830 84004884 100d815e c0a76208 c0a761f8
  GPR16: c0a761f4 c0a76278 1048834c 10488350 c21c0b04 c21c0d93 c0a5fb74 c313d848
  GPR24: c20b5f20 c21c0d94 00000000 00000000 c21c0d94 00000000 c21c0c00 c21c0b04
  NIP [c043c2f8] gpiochip_get_direction+0x3c/0x48
  LR [c043d740] gpiod_get_direction+0xa0/0x170
  Call Trace:
  [ca89bce0] [c28157e8] 0xc28157e8 (unreliable)
  [ca89bd10] [c043f3f0] gpiolib_seq_show+0x370/0x524
  [ca89bd90] [c021dd1c] seq_read_iter+0x174/0x618
  [ca89bdd0] [c021e260] seq_read+0xa0/0xd0
  [ca89be40] [c031063c] full_proxy_read+0x80/0xc4
  [ca89be70] [c01df3e0] vfs_read+0xb4/0x35c
  [ca89bee0] [c01e0180] ksys_read+0x8c/0x15c
  [ca89bf10] [c000dc94] system_call_exception+0x88/0x154
  [ca89bf30] [c00110a8] ret_from_syscall+0x0/0x28
  ---- interrupt: c00 at 0xfc629e8
  NIP:  0fc629e8 LR: 0fc62a34 CTR: 00000000
  REGS: ca89bf40 TRAP: 0c00   Tainted: G        W            (7.0.10-gitc72c39~-01802-g28c351659258)
  MSR:  0000d032 <EE,PR,ME,IR,DR,RI>  CR: 28004884  XER: 00000302

  GPR00: 00000003 7f8df6a0 77e37540 00000003 7f8df6e8 00001000 00000000 00000000
  GPR08: 00000000 7f8e3efc 00000000 7f8e06f0 7f8e3efc 100d815e 7fe70e10 100d0000
  GPR16: 100d0000 00000001 1048834c 10488350 22000882 77e3fe68 1000596c 77e40b28
  GPR24: 00000000 28004884 01000000 00001000 7f8df6e8 00000003 0fde36a0 00000000
  NIP [0fc629e8] 0xfc629e8
  LR [0fc62a34] 0xfc62a34
  ---- interrupt: c00
  Code: 9421fff0 7c0802a6 90010014 7d2903a6 4e800421 2c030001 40810008 3860ffcc 80010014 38210010 7c0803a6 4e800020 <0fe00000> 3860ffa1 4e800020 81230020
  ---[ end trace 0000000000000000 ]---

This is due to a WARN_ON() added by commit ec2cceadfae7 ("gpiolib:
normalize the return value of gc->get() on behalf of buggy drivers")
when the gpiochip doesn't implement get_direction() function. But
according to the documentation in <linux/gpio/driver.h> implementing
get_direction() is only a recommendation, not a requirement. And
regarless, WARN_ON() has no added value here, dumping all CPU
registers doesn't give any useful information for that case.

Lower it to a simple warn_on_once() message.

Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
---
 drivers/gpio/gpiolib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 1e6dce430dca..6c0a5db443cb 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -426,8 +426,10 @@ static int gpiochip_get_direction(struct gpio_chip *gc, unsigned int offset)
 
 	lockdep_assert_held(&gc->gpiodev->srcu);
 
-	if (WARN_ON(!gc->get_direction))
+	if (!gc->get_direction) {
+		pr_warn_once("%s: GPIO %s has no get_direction()\n", __func__, gc->label);
 		return -EOPNOTSUPP;
+	}
 
 	ret = gc->get_direction(gc, offset);
 	if (ret < 0)
-- 
2.54.0


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

end of thread, other threads:[~2026-06-03  8:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-02 11:30 [PATCH] gpiolib: Remove big fat warning in gpiochip_get_direction() Christophe Leroy (CS GROUP)
2026-06-02 16:13 ` Bartosz Golaszewski
2026-06-02 21:40   ` Christophe Leroy (CS GROUP)
2026-06-03  8:11     ` Bartosz Golaszewski
2026-06-03  8:23       ` Christophe Leroy (CS GROUP)
2026-06-03  8:33         ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome