Re: [PATCH v4 8/8] gpiolib: notify user-space about in-kernel line state changes

From: Kent Gibson
Date: Thu Oct 17 2024 - 08:54:07 EST


On Thu, Oct 17, 2024 at 10:14:16AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> @@ -1447,8 +1450,6 @@ static long linereq_set_config(struct linereq *lr, void __user *ip)
> }
>
> WRITE_ONCE(line->edflags, edflags);
> -
> - gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_CONFIG);
> }
> return 0;
> }

I still get errors from this when reconfiguring lines with debounce.
You should leave this notify in place and use _nonotify when setting the
direction.
i.e.

@@ -1436,11 +1432,11 @@ static long linereq_set_config(struct linereq *lr, void __user *ip)
int val = gpio_v2_line_config_output_value(&lc, i);

edge_detector_stop(line);
- ret = gpiod_direction_output(desc, val);
+ ret = gpiod_direction_output_nonotify(desc, val);
if (ret)
return ret;
} else {
- ret = gpiod_direction_input(desc);
+ ret = gpiod_direction_input_nonotify(desc);
if (ret)
return ret;

@@ -1450,6 +1446,8 @@ static long linereq_set_config(struct linereq *lr, void __user *ip)
}

WRITE_ONCE(line->edflags, edflags);
+
+ gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_CONFIG);
}
return 0;
}

Given that, all my current tests are passing.

Cheers,
Kent.