[PATCH] gpio: cdev: don't report GPIOs requested as interrupts as used

Bartosz Golaszewski posted 1 patch 3 weeks, 3 days ago
drivers/gpio/gpiolib-cdev.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] gpio: cdev: don't report GPIOs requested as interrupts as used
Posted by Bartosz Golaszewski 3 weeks, 3 days ago
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

GPIOs used as shared irqs can still be requested by user-space (or
kernel drivers for that matter) yet we report them as used over the
chardev ABI. Drop the test for FLAG_USED_AS_IRQ from
gpio_desc_to_lineinfo().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpiolib-cdev.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index 0ec162b0ea04..629e9372fd57 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -2275,7 +2275,6 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
 	 */
 	if (test_bit(FLAG_REQUESTED, &dflags) ||
 	    test_bit(FLAG_IS_HOGGED, &dflags) ||
-	    test_bit(FLAG_USED_AS_IRQ, &dflags) ||
 	    test_bit(FLAG_EXPORT, &dflags) ||
 	    test_bit(FLAG_SYSFS, &dflags) ||
 	    !gpiochip_line_is_valid(guard.gc, info->offset)) {
-- 
2.45.2
Re: [PATCH] gpio: cdev: don't report GPIOs requested as interrupts as used
Posted by Bartosz Golaszewski 2 weeks, 6 days ago
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Thu, 31 Oct 2024 21:08:41 +0100, Bartosz Golaszewski wrote:
> GPIOs used as shared irqs can still be requested by user-space (or
> kernel drivers for that matter) yet we report them as used over the
> chardev ABI. Drop the test for FLAG_USED_AS_IRQ from
> gpio_desc_to_lineinfo().
> 
> 

Applied, thanks!

[1/1] gpio: cdev: don't report GPIOs requested as interrupts as used
      commit: dae01ec714fbbf3a71947668cb61cee4cc320647

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Re: [PATCH] gpio: cdev: don't report GPIOs requested as interrupts as used
Posted by Linus Walleij 3 weeks, 2 days ago
On Thu, Oct 31, 2024 at 9:08 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> GPIOs used as shared irqs can still be requested by user-space (or
> kernel drivers for that matter) yet we report them as used over the
> chardev ABI. Drop the test for FLAG_USED_AS_IRQ from
> gpio_desc_to_lineinfo().
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

I think at the time this was added to not let userspace meddle with
such GPIO lines since they were used for "something" in the kernel.
(Userspace as second-class citizen.)

But I guess this is fine:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Re: [PATCH] gpio: cdev: don't report GPIOs requested as interrupts as used
Posted by Bartosz Golaszewski 3 weeks, 2 days ago
On Fri, Nov 1, 2024 at 11:35 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Oct 31, 2024 at 9:08 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > GPIOs used as shared irqs can still be requested by user-space (or
> > kernel drivers for that matter) yet we report them as used over the
> > chardev ABI. Drop the test for FLAG_USED_AS_IRQ from
> > gpio_desc_to_lineinfo().
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> I think at the time this was added to not let userspace meddle with
> such GPIO lines since they were used for "something" in the kernel.
> (Userspace as second-class citizen.)
>

Well, it wouldn't prohibit it. It would just report it misleadingly.
Since we'll guard the fixed input direction, I think we should be
fine.

Bartosz

> But I guess this is fine:
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> Yours,
> Linus Walleij
Re: [PATCH] gpio: cdev: don't report GPIOs requested as interrupts as used
Posted by Kent Gibson 3 weeks, 2 days ago
On Thu, Oct 31, 2024 at 09:08:41PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> GPIOs used as shared irqs can still be requested by user-space (or
> kernel drivers for that matter) yet we report them as used over the
> chardev ABI. Drop the test for FLAG_USED_AS_IRQ from
> gpio_desc_to_lineinfo().
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Reviewed-by: Kent Gibson <warthog618@gmail.com>

> ---
>  drivers/gpio/gpiolib-cdev.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index 0ec162b0ea04..629e9372fd57 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -2275,7 +2275,6 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
>  	 */
>  	if (test_bit(FLAG_REQUESTED, &dflags) ||
>  	    test_bit(FLAG_IS_HOGGED, &dflags) ||
> -	    test_bit(FLAG_USED_AS_IRQ, &dflags) ||
>  	    test_bit(FLAG_EXPORT, &dflags) ||
>  	    test_bit(FLAG_SYSFS, &dflags) ||
>  	    !gpiochip_line_is_valid(guard.gc, info->offset)) {
> --
> 2.45.2
>