[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMRc=MdNnJZBd=eCa5ggATmqH4EwsGW3K6OgcF=oQrkEj_5S_g@mail.gmail.com>
Date: Mon, 24 Feb 2025 03:51:03 -0500
From: brgl@...ev.pl
To: Paul Menzel <pmenzel@...gen.mpg.de>
Cc: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
Linus Walleij <linus.walleij@...aro.org>, linux-gpio@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>, linux-pci@...r.kernel.org,
regressions@...ts.linux.dev, Bartosz Golaszewski <brgl@...ev.pl>
Subject: Re: Linux logs new warning `gpio gpiochip0: gpiochip_add_data_with_key:
get_direction failed: -22`
On Sun, 23 Feb 2025 23:04:05 +0100, Paul Menzel <pmenzel@...gen.mpg.de> said:
> Dear Bortosz,
>
>
> Am 23.02.25 um 21:54 schrieb Bartosz Golaszewski:
>> On Fri, Feb 21, 2025 at 10:02 PM Paul Menzel <pmenzel@...gen.mpg.de> wrote:
>>>
>>>> What GPIO driver is it using? It's likely that it's not using the
>>>> provider API correctly and this change uncovered it, I'd like to take
>>>> a look at it and fix it.
>>>
>>> How do I find out? The commands below do not return anything.
>>>
>>> $ lsmod | grep gpio
>>> $ lspci -nn | grep -i gpio
>>> $ sudo dmesg | grep gpio
>>> [ 5.150955] gpio gpiochip0: gpiochip_add_data_with_key: get_direction failed: -22
>>> [Just these lines match.]
>
>> If you have libgpiod-tools installed, you can post the output of
>> gpiodetect here.
>
> $ sudo gpiodetect
> gpiochip0 [INT344B:00] (152 lines)
>
So it's pinctrl-intel, specifically this function in
drivers/pinctrl/intel/pinctrl-intel.c:
static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{
struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
void __iomem *reg;
u32 padcfg0;
int pin;
pin = intel_gpio_to_pin(pctrl, offset, NULL, NULL);
if (pin < 0)
return -EINVAL;
reg = intel_get_padcfg(pctrl, pin, PADCFG0);
if (!reg)
return -EINVAL;
scoped_guard(raw_spinlock_irqsave, &pctrl->lock)
padcfg0 = readl(reg);
if (padcfg0 & PADCFG0_PMODE_MASK)
return -EINVAL;
if (__intel_gpio_get_direction(padcfg0) & PAD_CONNECT_OUTPUT)
return GPIO_LINE_DIRECTION_OUT;
return GPIO_LINE_DIRECTION_IN;
}
Can you add some logs and see which -EINVAL is returned here specifically?
In any case: Linus: what should be our policy here? There are some pinctrl
drivers which return EINVAL if the pin in question is not in GPIO mode. I don't
think this is an error. Returning errors should be reserved for read failures
and so on. Are you fine with changing the logic here to explicitly default to
INPUT as until recently all errors would be interpreted as such anyway?
Bart
Powered by blists - more mailing lists