Re: [PATCH] gpiolib: Remove big fat warning in gpiochip_get_direction()
From: Bartosz Golaszewski
Date: Wed Jun 03 2026 - 04:56:01 EST
On Wed, 3 Jun 2026 10:23:08 +0200, "Christophe Leroy (CS GROUP)"
<chleroy@xxxxxxxxxx> said:
>
>
> Le 03/06/2026 à 10:11, Bartosz Golaszewski a écrit :
>> On Tue, 2 Jun 2026 23:40:22 +0200, "Christophe Leroy (CS GROUP)"
>> <chleroy@xxxxxxxxxx> said:
>>>
>>>
>>> Le 02/06/2026 à 18:13, Bartosz Golaszewski a écrit :
>>>> On Tue, Jun 2, 2026 at 1:31 PM Christophe Leroy (CS GROUP)
>>>> <chleroy@xxxxxxxxxx> wrote:
>>>>>
>>>>> 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@xxxxxxxxxx>
>>>>> ---
>>>>
>>>> Please use scripts/get_maintainers.pl.
>>>
>>> That's what I did, what is the problem ?
>>>
>>> $ ./scripts/get_maintainer.pl --nom --nor --nomultiline --norolestats
>>> --nogit --nogit-fallback
>>> tmp/0001-gpiolib-Remove-big-fat-warning-in-gpiochip_get_direc.patch
>>> Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>, Linus Walleij
>>> <linusw@xxxxxxxxxx>, Bartosz Golaszewski
>>> <bartosz.golaszewski@xxxxxxxxxxxxxxxx>, linux-gpio@xxxxxxxxxxxxxxx,
>>> linux-kernel@xxxxxxxxxxxxxxx
>>>
>>
>> I would expect my brgl@xxxxxxxxxx address to show up, the -nom option removes
>> it.
>
> Ah .. I see. Thanks for the notice.
>
> Indeed I use two calls, first one to populate the To:
>
> ./scripts/get_maintainer.pl --nol --nomultiline --norolestats --nogit
> --nogit-fallback
>
> then second one to populate the Cc:
>
> ./scripts/get_maintainer.pl --nom --nor --nomultiline --norolestats
> --nogit --nogit-fallback
>
> Then I saw same names appearing in second result in addition to mailing
> lists so I took only the second result, overlooking that your adress was
> different between the two results.
>
> Indeed the second result was initially supposed to only provide the
> mailing lists, but since some time now it also provides names and I have
> to manually compare the two results to avoid duplicates. I need to look
> into that more deeply.
>
May I interest you in b4 - the de-facto standard tool for managing kernel
patches? :)
Bart
>
>>
>>>>
>>>> What driver are you using?
>>>
>>> I have the following ones declared in the device tree:
>>>
>>> CPM1_PIO_A: gpio-controller@950 {
>>> #gpio-cells = <2>;
>>> compatible = "fsl,cpm1-pario-bank-a";
>>> reg = <0x950 0x10>;
>>> gpio-controller;
>>> };
>>
>> I'll send a patch shortly implementing get_direction() for it.
>
> Thanks
>
> Christophe
>