lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5DB475451BAA174CB158B5E897FC1525920E9FD0@MBS-6F-DAG.vivotek.tw>
Date:   Fri, 5 Jul 2019 10:35:52 +0000
From:   <Michael.Wu@...ics.com>
To:     <bgolaszewski@...libre.com>
CC:     <linus.walleij@...aro.org>, <linux-gpio@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <mvp.kutali@...il.com>
Subject: RE: [PATCH] gpiolib: fix incorrect IRQ requesting of an active-low
 lineevent

Hi Bartosz,

For example, there is a button which drives level to be low when it is pushed, and drivers level to be high when it is released.
We want to catch the event when the button is pushed.

In user space we configure a line event with the following code:

req.handleflags = GPIOHANDLE_REQUEST_INPUT;
req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE;

and we hope to get "falling" events by reading the device node:

while (1) {
	read(fd, &dat,sizeof(dat));
	if (dat.id == 0) {
		printf("button pushed\n");
	}
}

Run the same logic on another board which the polarity of the button is inverted. The button drives level to be high when it is pushed.
For the inverted level case, we have to add flag GPIOHANDLE_REQUEST_ACTIVE_LOW:

req.handleflags = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_ACTIVE_LOW;
req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE;

At the result, there are no any events been caught when the button is pushed.
By the way, button releasing will emit a "falling" event.


Sincerely,

Michael Wu 


-----Original Message-----
From: Bartosz Golaszewski [mailto:bgolaszewski@...libre.com] 
Sent: Friday, July 05, 2019 5:33 PM
To: Michael.Wu(吳忠益)
Cc: Linus Walleij; linux-gpio; LKML; mvp.kutali@...il.com
Subject: Re: [PATCH] gpiolib: fix incorrect IRQ requesting of an active-low lineevent

pt., 5 lip 2019 o 11:30 Michael Wu <michael.wu@...ics.com> napisał(a):
>
> When a pin is active-low, logical trigger edge should be inverted
> to match the same interrupt opportunity.
>
> For example, a button pushed trigger falling edge in ACTIVE_HIGH
> case; in ACTIVE_LOW case, the button pushed trigger rising edge.
> For user space the IRQ requesting doesn't need to do any
> modification except to configuring GPIOHANDLE_REQUEST_ACTIVE_LOW.
>
> Signed-off-by: Michael Wu <michael.wu@...ics.com>
> ---
>  drivers/gpio/gpiolib.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index e013d417a936..b98466a05091 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -956,9 +956,11 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
>         }
>
>         if (eflags & GPIOEVENT_REQUEST_RISING_EDGE)
> -               irqflags |= IRQF_TRIGGER_RISING;
> +               irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ?
> +                       IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
>         if (eflags & GPIOEVENT_REQUEST_FALLING_EDGE)
> -               irqflags |= IRQF_TRIGGER_FALLING;
> +               irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ?
> +                       IRQ_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
>         irqflags |= IRQF_ONESHOT;
>
>         INIT_KFIFO(le->events);
> --
> 2.17.1
>

Is this something that causes a bug in user-space? Any scenario to reproduce it?

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ