Re: [PATCH] gpiolib: clear the event clock flags when a line is released
From: Bartosz Golaszewski
Date: Fri Oct 16 2026 - 05:13:29 EST
On Fri, 16 Oct 2026 09:46:57 +0200, Adrian Ambrozewicz
<aambrozewicz@xxxxxxxxxx> said:
> On Mon, Oct 12, 2026 at 02:05:49PM +0000, sashiko-bot@xxxxxxxxxx wrote:
>> In gpiod_free_commit(), the ownership synchronization token
>> (GPIOD_FLAG_REQUESTED) is cleared in desc->flags via a WRITE_ONCE() before
>> the function finishes cleaning up ancillary state (debounce_period_us) and
>> emitting the GPIO_V2_LINE_CHANGED_RELEASED notification:
>
> This is real, and older than this patch: once the cleared
> GPIOD_FLAG_REQUESTED is visible, a new request can set
> desc->debounce_period_us in edge_detector_setup() before the old one
> resets it to 0, and the debounce code reads the period from there.
>
> I'll send a fix with v2 of the chip-removal series, which touches the
> same function: reset the period first, then write the flags with
> release ordering, pairing with the test_and_set_bit() in
> gpiod_request_commit(), so that a new owner sees the reset. The
> RELEASED notification can still arrive after the new request's
> REQUESTED one. Moving it before the flags update would report the line
> as still requested in the RELEASED event, so the fix will describe
> that rather than reorder it.
>
Will you resend this together with that v2? Or should I take it independently?
Bartosz