[PATCH 0/5] gpiolib: improve concurrent access to the flags field of struct gpio_desc
From: Bartosz Golaszewski
Date: Wed Nov 04 2026 - 10:43:42 EST
This is a follow-up to our discussion[1] about desc->flags and possible
races with users who don't/can't synchronize with other means.
It's an attempt to use try_cmpxchg() to update only the required flags
atomically where needed + minor fixes using atomic variants of bitops
where it makes sense.
[1] https://lore.kernel.org/all/20261015153714.GA105746@rigel/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
---
Bartosz Golaszewski (5):
gpiolib: don't overwrite the entire flags field in gpiod_get_direction()
gpio: shared: use atomic set_bit() for descriptor flags
gpiolib: provide gpiod_update_flags()
gpiolib: don't overwrite the entire flags field in gpiod_free_commit()
gpio: cdev: don't overwrite the whole flags field when configuring lines
drivers/gpio/gpiolib-cdev.c | 118 +++++++++++++++++++++++-------------------
drivers/gpio/gpiolib-shared.c | 6 +--
drivers/gpio/gpiolib.c | 29 +++++------
drivers/gpio/gpiolib.h | 21 ++++++++
4 files changed, 103 insertions(+), 71 deletions(-)
---
base-commit: f1fa734d14164cddc063dbf2138c2feb38baab42
change-id: 20261104-gpio-desc-flags-atomic-cc963a1ccfd0
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>