* Re: [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction()
2025-02-19 10:27 ` [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction() Bartosz Golaszewski
@ 2025-02-19 11:16 ` Marek Szyprowski
2025-02-19 14:27 ` Mark Brown
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Marek Szyprowski @ 2025-02-19 11:16 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Stefan Wahren, Liao Chen, Chen-Yu Tsai, Mark Brown
Cc: linux-gpio, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
Bartosz Golaszewski
On 19.02.2025 11:27, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Since commit 9d846b1aebbe ("gpiolib: check the return value of
> gpio_chip::get_direction()") we check the return value of the
> get_direction() callback as per its API contract. This driver returns
> -EINVAL if the pin in question is set to one of the alternative
> (non-GPIO) functions. This isn't really an error that should be
> communicated to GPIOLIB so default to returning the "safe" value of
> INPUT in this case. The GPIO subsystem does not have the notion of
> "unknown" direction.
>
> Fixes: 9d846b1aebbe ("gpiolib: check the return value of gpio_chip::get_direction()")
> Reported-by: Mark Brown <broonie@kernel.org>
> Closes: https://lore.kernel.org/all/Z7VFB1nST6lbmBIo@finisterre.sirena.org.uk/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Closes:
https://lore.kernel.org/all/dfe03f88-407e-4ef1-ad30-42db53bbd4e4@samsung.com/
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> drivers/pinctrl/bcm/pinctrl-bcm2835.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> index cc1fe0555e19..eaeec096bc9a 100644
> --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> @@ -346,14 +346,14 @@ static int bcm2835_gpio_get_direction(struct gpio_chip *chip, unsigned int offse
> struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
> enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
>
> - /* Alternative function doesn't clearly provide a direction */
> - if (fsel > BCM2835_FSEL_GPIO_OUT)
> - return -EINVAL;
> + if (fsel == BCM2835_FSEL_GPIO_OUT)
> + return GPIO_LINE_DIRECTION_OUT;
>
> - if (fsel == BCM2835_FSEL_GPIO_IN)
> - return GPIO_LINE_DIRECTION_IN;
> -
> - return GPIO_LINE_DIRECTION_OUT;
> + /*
> + * Alternative function doesn't clearly provide a direction. Default
> + * to INPUT.
> + */
> + return GPIO_LINE_DIRECTION_IN;
> }
>
> static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction()
2025-02-19 10:27 ` [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction() Bartosz Golaszewski
2025-02-19 11:16 ` Marek Szyprowski
@ 2025-02-19 14:27 ` Mark Brown
2025-02-19 14:29 ` Bartosz Golaszewski
2025-02-19 15:46 ` Stefan Wahren
2025-03-04 7:53 ` Linus Walleij
3 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2025-02-19 14:27 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stefan Wahren, Liao Chen,
Chen-Yu Tsai, Marek Szyprowski, linux-gpio, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Bartosz Golaszewski
[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]
On Wed, Feb 19, 2025 at 11:27:50AM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Since commit 9d846b1aebbe ("gpiolib: check the return value of
> gpio_chip::get_direction()") we check the return value of the
> get_direction() callback as per its API contract. This driver returns
> -EINVAL if the pin in question is set to one of the alternative
> (non-GPIO) functions. This isn't really an error that should be
> communicated to GPIOLIB so default to returning the "safe" value of
> INPUT in this case. The GPIO subsystem does not have the notion of
> "unknown" direction.
I see this was already tested for these specific boards. I've also
found that Avenger96 is failing with bisect pointing to the same commit
this is fixing:
https://lava.sirena.org.uk/scheduler/job/1126314
as is the Libretech Potato:
https://lava.sirena.org.uk/scheduler/job/1126285
neither of which produce any output before dying, they'll not be fixed
by this change. Seems like an audit of the drivers might be in order?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction()
2025-02-19 14:27 ` Mark Brown
@ 2025-02-19 14:29 ` Bartosz Golaszewski
2025-02-27 22:53 ` Linus Walleij
0 siblings, 1 reply; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-02-19 14:29 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stefan Wahren, Liao Chen,
Chen-Yu Tsai, Marek Szyprowski, linux-gpio, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Bartosz Golaszewski
On Wed, Feb 19, 2025 at 3:27 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Wed, Feb 19, 2025 at 11:27:50AM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Since commit 9d846b1aebbe ("gpiolib: check the return value of
> > gpio_chip::get_direction()") we check the return value of the
> > get_direction() callback as per its API contract. This driver returns
> > -EINVAL if the pin in question is set to one of the alternative
> > (non-GPIO) functions. This isn't really an error that should be
> > communicated to GPIOLIB so default to returning the "safe" value of
> > INPUT in this case. The GPIO subsystem does not have the notion of
> > "unknown" direction.
>
> I see this was already tested for these specific boards. I've also
> found that Avenger96 is failing with bisect pointing to the same commit
> this is fixing:
>
> https://lava.sirena.org.uk/scheduler/job/1126314
>
> as is the Libretech Potato:
>
> https://lava.sirena.org.uk/scheduler/job/1126285
>
> neither of which produce any output before dying, they'll not be fixed
> by this change. Seems like an audit of the drivers might be in order?
Right. I don't know if they return EINVAL or some other error so let
me prepare a change that will not bail-out but simply warn on
get_direction() errors in gpiochip_add_data() instead.
This patch can still go upstream IMO.
Bart
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction()
2025-02-19 14:29 ` Bartosz Golaszewski
@ 2025-02-27 22:53 ` Linus Walleij
2025-02-28 10:47 ` Bartosz Golaszewski
0 siblings, 1 reply; 8+ messages in thread
From: Linus Walleij @ 2025-02-27 22:53 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stefan Wahren, Liao Chen,
Chen-Yu Tsai, Marek Szyprowski, linux-gpio, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Bartosz Golaszewski
On Wed, Feb 19, 2025 at 3:30 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> On Wed, Feb 19, 2025 at 3:27 PM Mark Brown <broonie@kernel.org> wrote:
> >
> > On Wed, Feb 19, 2025 at 11:27:50AM +0100, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > Since commit 9d846b1aebbe ("gpiolib: check the return value of
> > > gpio_chip::get_direction()") we check the return value of the
> > > get_direction() callback as per its API contract. This driver returns
> > > -EINVAL if the pin in question is set to one of the alternative
> > > (non-GPIO) functions. This isn't really an error that should be
> > > communicated to GPIOLIB so default to returning the "safe" value of
> > > INPUT in this case. The GPIO subsystem does not have the notion of
> > > "unknown" direction.
> >
> > I see this was already tested for these specific boards. I've also
> > found that Avenger96 is failing with bisect pointing to the same commit
> > this is fixing:
> >
> > https://lava.sirena.org.uk/scheduler/job/1126314
> >
> > as is the Libretech Potato:
> >
> > https://lava.sirena.org.uk/scheduler/job/1126285
> >
> > neither of which produce any output before dying, they'll not be fixed
> > by this change. Seems like an audit of the drivers might be in order?
>
> Right. I don't know if they return EINVAL or some other error so let
> me prepare a change that will not bail-out but simply warn on
> get_direction() errors in gpiochip_add_data() instead.
>
> This patch can still go upstream IMO.
I'm fine to apply it, maybe as non-urgent fix at this point? (for -next)
Do you want to send a non-RFC/RFT version or should I just apply it?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction()
2025-02-27 22:53 ` Linus Walleij
@ 2025-02-28 10:47 ` Bartosz Golaszewski
0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2025-02-28 10:47 UTC (permalink / raw)
To: Linus Walleij
Cc: Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stefan Wahren, Liao Chen,
Chen-Yu Tsai, Marek Szyprowski, linux-gpio, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Bartosz Golaszewski
On Thu, Feb 27, 2025 at 11:53 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Wed, Feb 19, 2025 at 3:30 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > On Wed, Feb 19, 2025 at 3:27 PM Mark Brown <broonie@kernel.org> wrote:
> > >
> > > On Wed, Feb 19, 2025 at 11:27:50AM +0100, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > >
> > > > Since commit 9d846b1aebbe ("gpiolib: check the return value of
> > > > gpio_chip::get_direction()") we check the return value of the
> > > > get_direction() callback as per its API contract. This driver returns
> > > > -EINVAL if the pin in question is set to one of the alternative
> > > > (non-GPIO) functions. This isn't really an error that should be
> > > > communicated to GPIOLIB so default to returning the "safe" value of
> > > > INPUT in this case. The GPIO subsystem does not have the notion of
> > > > "unknown" direction.
> > >
> > > I see this was already tested for these specific boards. I've also
> > > found that Avenger96 is failing with bisect pointing to the same commit
> > > this is fixing:
> > >
> > > https://lava.sirena.org.uk/scheduler/job/1126314
> > >
> > > as is the Libretech Potato:
> > >
> > > https://lava.sirena.org.uk/scheduler/job/1126285
> > >
> > > neither of which produce any output before dying, they'll not be fixed
> > > by this change. Seems like an audit of the drivers might be in order?
> >
> > Right. I don't know if they return EINVAL or some other error so let
> > me prepare a change that will not bail-out but simply warn on
> > get_direction() errors in gpiochip_add_data() instead.
> >
> > This patch can still go upstream IMO.
>
> I'm fine to apply it, maybe as non-urgent fix at this point? (for -next)
>
Yes, the offending changes in gpiolib.c were dropped so this can go in
the non-urgent way.
> Do you want to send a non-RFC/RFT version or should I just apply it?
>
You can take it as is. It got tested and reviewed, so the tags served
their purpose. :)
Bart
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction()
2025-02-19 10:27 ` [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction() Bartosz Golaszewski
2025-02-19 11:16 ` Marek Szyprowski
2025-02-19 14:27 ` Mark Brown
@ 2025-02-19 15:46 ` Stefan Wahren
2025-03-04 7:53 ` Linus Walleij
3 siblings, 0 replies; 8+ messages in thread
From: Stefan Wahren @ 2025-02-19 15:46 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list, Liao Chen,
Chen-Yu Tsai, Mark Brown, Marek Szyprowski
Cc: linux-gpio, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
Bartosz Golaszewski
Am 19.02.25 um 11:27 schrieb Bartosz Golaszewski:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Since commit 9d846b1aebbe ("gpiolib: check the return value of
> gpio_chip::get_direction()") we check the return value of the
> get_direction() callback as per its API contract. This driver returns
> -EINVAL if the pin in question is set to one of the alternative
> (non-GPIO) functions. This isn't really an error that should be
> communicated to GPIOLIB so default to returning the "safe" value of
> INPUT in this case. The GPIO subsystem does not have the notion of
> "unknown" direction.
>
> Fixes: 9d846b1aebbe ("gpiolib: check the return value of gpio_chip::get_direction()")
> Reported-by: Mark Brown <broonie@kernel.org>
> Closes: https://lore.kernel.org/all/Z7VFB1nST6lbmBIo@finisterre.sirena.org.uk/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
Thanks
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction()
2025-02-19 10:27 ` [RFC/RFT PATCH] pinctrl: bcm2835: don't -EINVAL on alternate funcs from get_direction() Bartosz Golaszewski
` (2 preceding siblings ...)
2025-02-19 15:46 ` Stefan Wahren
@ 2025-03-04 7:53 ` Linus Walleij
3 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2025-03-04 7:53 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stefan Wahren, Liao Chen,
Chen-Yu Tsai, Mark Brown, Marek Szyprowski, linux-gpio,
linux-rpi-kernel, linux-arm-kernel, linux-kernel,
Bartosz Golaszewski
On Wed, Feb 19, 2025 at 11:27 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Since commit 9d846b1aebbe ("gpiolib: check the return value of
> gpio_chip::get_direction()") we check the return value of the
> get_direction() callback as per its API contract. This driver returns
> -EINVAL if the pin in question is set to one of the alternative
> (non-GPIO) functions. This isn't really an error that should be
> communicated to GPIOLIB so default to returning the "safe" value of
> INPUT in this case. The GPIO subsystem does not have the notion of
> "unknown" direction.
>
> Fixes: 9d846b1aebbe ("gpiolib: check the return value of gpio_chip::get_direction()")
> Reported-by: Mark Brown <broonie@kernel.org>
> Closes: https://lore.kernel.org/all/Z7VFB1nST6lbmBIo@finisterre.sirena.org.uk/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Patch applied!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread