Re: [PATCH v2 07/18] gpiolib: cdev: support edge detection for uAPI v2

From: Bartosz Golaszewski
Date: Tue Aug 04 2020 - 15:28:19 EST


On Sat, Jul 25, 2020 at 6:21 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:
>
> Add support for edge detection to lines requested using
> GPIO_GET_LINE_IOCTL.
>
> Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx>
> ---

[snip!]

> +
> +static irqreturn_t edge_irq_thread(int irq, void *p)
> +{
> + struct edge_detector *edet = p;
> + struct line *line = edet->line;
> + struct gpio_desc *desc = edge_detector_desc(edet);
> + struct gpioline_event le;
> + int ret;
> +
> + /* Do not leak kernel stack to userspace */
> + memset(&le, 0, sizeof(le));
> +
> + /*
> + * We may be running from a nested threaded interrupt in which case
> + * we didn't get the timestamp from edge_irq_handler().
> + */
> + if (!edet->timestamp) {
> + le.timestamp = ktime_get_ns();

IIRC Marc suggested using smp_rmw() here before reading the timestamp.
Do we still need it or something changed?

Bartosz