Re: [PATCH v2 1/1] gpio-f7188x: fix base values conflicts with other gpio pins

From: xingtong.wu
Date: Thu Aug 31 2023 - 03:29:43 EST


On 2023/5/29 21:02, Linus Walleij wrote:
> On Mon, May 29, 2023 at 4:55 AM <xingtong_wu@xxxxxxx> wrote:
>
>> From: "xingtong.wu" <xingtong.wu@xxxxxxxxxxx>
>>
>> switch pin base from static to automatic allocation to
>> avoid conflicts and align with other gpio chip drivers
>>
>> Signed-off-by: xingtong.wu <xingtong.wu@xxxxxxxxxxx>
>
> Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
>
> If this platform does not have a ton of userspace using the obsolete
> sysfs this should be fine to apply. I say let's apply and see what happens.
>
> Yours,
> Linus Walleij

Hi

Seems the issue happened again, the module "gpio-f7188x" register
gpio_chip failed because of the base value conflict. I hope the patch
can be merged soon, I'm afraid that you forgot it...

The log is below:
[ 6.872049] gpio-f7188x: Unsupported Fintek device 0x0303
[ 6.872137] gpio-f7188x: Found nct6126d at 0x4e
[ 6.899965] gpiochip_find_base: cannot find free range
[ 6.899967] gpiochip_add_data_with_key: GPIOs 0..7 (gpio-f7188x-6) failed to register, -28
[ 6.899970] gpio-f7188x gpio-f7188x: Failed to register gpiochip 6: -28
[ 6.903329] simatic_ipc_batt simatic_ipc_batt: cannot find GPIO chip gpio-f7188x-6, deferring

There is a gpio_chip created by "pinctrl-tigerlake":
/sys/class/gpio/gpiochip49# ls -l
total 0
-r--r--r--. 1 root root 4096 Aug 31 06:40 base
lrwxrwxrwx. 1 root root 0 Aug 31 06:40 device -> ../../../INT34C6:00
-r--r--r--. 1 root root 4096 Aug 31 06:40 label
-r--r--r--. 1 root root 4096 Aug 31 06:40 ngpio
drwxr-xr-x. 2 root root 0 Aug 31 06:40 power
lrwxrwxrwx. 1 root root 0 Aug 31 06:38 subsystem -> ../../../../../class/gpio
-rw-r--r--. 1 root root 4096 Aug 31 06:38 uevent

The base value is 49, label = INT34C6:00, ngpio = 463

The issue arose by chance, because the driver "pinctrl-tigerlake" apply gpio_chip->base
randomly, this time it apply the base value 49, so it have conflict to here:
https://github.com/torvalds/linux/blob/master/drivers/gpio/gpio-f7188x.c#L283

But sometime it apply other base values, so the issue do not happen.

BRs,
Xing Tong Wu