"gpiolib: remove redundant callback check" causes regression when gpio_chip.get_direction callback is not implemented
From: Frank Wunderlich
Date: Sat Apr 04 2026 - 08:14:45 EST
Hi
i stumbled over your commit 471e998c0e31 "gpiolib: remove redundant callback check" in
kernel 7.0 (6.19-rc6+ should be affected) because i get some traces on my mt7988 board
when calling "cat /sys/kernel/debug/gpio":
[ 33.903162] gpio-chip: pinctrl_moore base: 200 offset: 0
[ 33.908489] ------------[ cut here ]------------
[ 33.913095] WARNING: drivers/gpio/gpiolib.c:424 at gpiochip_get_direction+0x60/0x78, CPU#0: cat/3421
[ 33.922216] Modules linked in:
[ 33.925262] CPU: 0 UID: 0 PID: 3421 Comm: cat Tainted: G W 7.0.0-rc6-bpi-r4-rc6 #9 PREEMPTLAZY
[ 33.935423] Tainted: [W]=WARN
[ 33.938380] Hardware name: Bananapi BPI-R4 Pro 8X (DT)
[ 33.943506] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 33.950454] pc : gpiochip_get_direction+0x60/0x78
[ 33.955148] lr : gpiochip_get_direction+0x30/0x78
[ 33.959841] sp : ffffffc088463ae0
[ 33.963145] x29: ffffffc088463ae0 x28: ffffff80c02e1c17 x27: ffffff80c01073f0
[ 33.970271] x26: ffffffc08123e448 x25: ffffff80c02e1c18 x24: ffffff80c01682a0
[ 33.977397] x23: 0000000000000000 x22: ffffff80c02e1c18 x21: ffffff80c02e1800
[ 33.984523] x20: 0000000000000015 x19: ffffff80c01682a0 x18: 00000000ffffffff
[ 33.991649] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000006
[ 33.998774] x14: 00000000ffffffea x13: ffffffc088463858 x12: ffffffc081979ce8
[ 34.005901] x11: 0000000000000001 x10: 0000000000000001 x9 : 0000000000017fe8
[ 34.013027] x8 : ffffffc081921c70 x7 : c0000000ffffefff x6 : 0000000000057fa8
[ 34.020154] x5 : ffffff80ff746688 x4 : 0000000000000000 x3 : 0000000000000000
[ 34.027280] x2 : 0000000000000000 x1 : ffffff80c908c880 x0 : 000000000000002c
[ 34.034405] Call trace:
[ 34.036841] gpiochip_get_direction+0x60/0x78 (P)
[ 34.041536] gpiod_get_direction+0x90/0x188
[ 34.045710] gpiolib_seq_show+0x2b4/0x414
[ 34.049710] seq_read_iter+0xe0/0x498
[ 34.053362] seq_read+0xe8/0x128
[ 34.056580] full_proxy_read+0x6c/0xa8
[ 34.060320] vfs_read+0xa4/0x300
[ 34.063539] ksys_read+0x6c/0x104
[ 34.066846] __arm64_sys_read+0x1c/0x28
[ 34.070673] invoke_syscall+0x48/0x10c
[ 34.074413] el0_svc_common.constprop.0+0x40/0xe0
[ 34.079106] do_el0_svc+0x1c/0x28
[ 34.082411] el0_svc+0x34/0x108
[ 34.085545] el0t_64_sync_handler+0xa0/0xe4
[ 34.089720] el0t_64_sync+0x19c/0x1a0
[ 34.093373] ---[ end trace 0000000000000000 ]---
with e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()") you introduced a new helper
which calls WARN_ON if the callback is not defined, and with removing the pre-check this WARN is now printed on
every gpio-controller which does not implement the gpio_chip.get_direction callback.
as you see in my debug (first line) it affects pinctrl_moore driver which contructs the gpiochip callbacks here:
https://elixir.bootlin.com/linux/v7.0-rc6/source/drivers/pinctrl/mediatek/pinctrl-moore.c#L562
please let me know if this is now invalid and need to be fixed in drive, but imho the WARN_ON here is wrong (optional
callback) beause direction of pins is correctly printed like this after the traces:
gpiochip0: 84 GPIOs, parent: platform/1001f000.pinctrl, pinctrl_moore:
gpio-0 ( |tx-disable ) in lo
gpio-1 ( |mod-def0 ) in hi IRQ ACTIVE LOW
gpio-2 ( |los ) in hi IRQ
gpio-12 ( |cd ) in lo IRQ ACTIVE LOW
gpio-13 ( |reset ) in hi IRQ ACTIVE LOW
gpio-14 ( |WPS ) in hi IRQ ACTIVE LOW
gpio-21 ( |tx-disable ) out hi
gpio-63 ( |pcie-3-hog ) out hi
gpio-69 ( |mod-def0 ) in lo IRQ ACTIVE LOW
gpio-70 ( |los ) in hi IRQ
gpio-79 ( |pcie-2-hog ) out hi
gpio-82 ( |PHY reset ) out hi ACTIVE LOW
gpio-83 ( |PHY reset ) out hi ACTIVE LOW
regards Frank