Comment 152 for bug 1887190

Revision history for this message
wangjun (biggerchina) wrote :

according to the above analysis, error is happen with the direction is : in

i found the function to set the direction of gpio pin to in: amd_gpio_direction_input,

and add some pr_err and dump_stack() to the function ,

then dmesg out put like :

[ 1.545190] amd_gpio_set_config gpio_chip->label:AMDI0030:00,offset:130,config:278
[ 1.545191] amd_gpio_direction_input gpio_chip->label:AMDI0030:00,offset:130

=============================amd_gpio_direction_input dump_stack()=====
[ 1.545194] CPU: 12 PID: 264 Comm: kworker/12:4 Not tainted 5.8.13-303.fc33.x86_64 #1
[ 1.545194] Hardware name: LENOVO 82B6/LNVNB161216, BIOS EUCN26WW 08/19/2020
[ 1.545197] Workqueue: events deferred_probe_work_func
[ 1.545198] Call Trace:
[ 1.545203] dump_stack+0x6b/0x88
[ 1.545205] amd_gpio_direction_input+0x57/0x60 [pinctrl_amd]
[ 1.545206] gpiod_direction_input+0x5b/0x170
[ 1.545208] acpi_dev_gpio_irq_get+0x111/0x1b6
[ 1.545209] ? i2c_acpi_find_adapter_by_handle+0x30/0x30
[ 1.545210] i2c_acpi_get_irq+0x81/0x90
[ 1.545212] i2c_device_probe+0x24a/0x280
[ 1.545213] really_probe+0x160/0x400
[ 1.545214] driver_probe_device+0xe1/0x150
[ 1.545215] ? driver_allows_async_probing+0x50/0x50
[ 1.545216] bus_for_each_drv+0x6a/0xa0
[ 1.545217] __device_attach+0xb4/0x1b0
[ 1.545218] bus_probe_device+0x8e/0xa0
[ 1.545219] deferred_probe_work_func+0x77/0xc0
[ 1.545220] process_one_work+0x1b4/0x370
[ 1.545221] worker_thread+0x53/0x3e0
[ 1.545222] ? process_one_work+0x370/0x370
[ 1.545223] kthread+0x11b/0x140
[ 1.545224] ? __kthread_bind_mask+0x60/0x60
[ 1.545226] ret_from_fork+0x22/0x30
============================================================================

then i found the functions

acpi_dev_gpio_irq_get

in in file : drivers/gpio/gpiolib-acpi.c, line 927 (as a function)

and it's comment say:
```
/**
 * acpi_dev_gpio_irq_get() - Find GpioInt and translate it to Linux IRQ number
 * @adev: pointer to a ACPI device to get IRQ from
 * @index: index of GpioInt resource (starting from %0)
 *
 * If the device has one or more GpioInt resources, this function can be
 * used to translate from the GPIO offset in the resource to the Linux IRQ
 * number.
 *
 * The function is idempotent, though each time it runs it will configure GPIO
 * pin direction according to the flags in GpioInt resource.
 *
 * Return: Linux IRQ number (> %0) on success, negative errno on failure.
 */
int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
{
```

each time it runs it will configure GPIO pin direction according to the flags in GpioInt resource.

in it's body ,by call function gpiod_configure_flags (in /drivers/gpio/gpiolib.c)
it call the function gpiod_direction_input.
so the direction become to :input or in

the problem may be in two places:
1. lenovo 's default value in bios or dsdt is : input or in,or missing . but on windows ,it's ok,so ,may be not here.
2. in linux kernel,the default value of the type for gpio pin 's direction ,is :input or in