]> www.infradead.org Git - users/jedix/linux-maple.git/commit
gpio: vf610: add locking to gpio direction functions
authorJohan Korsnes <johan.korsnes@remarkable.no>
Mon, 17 Feb 2025 09:16:43 +0000 (10:16 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 17 Feb 2025 10:57:54 +0000 (11:57 +0100)
commit4e667a1968099c6deadee2313ecd648f8f0a8956
treebbbe9b59c660a57e53d287d908539a1d9be64d41
parent9d846b1aebbe488f245f1aa463802ff9c34cc078
gpio: vf610: add locking to gpio direction functions

Add locking to `vf610_gpio_direction_input|output()` functions. Without
this locking, a race condition exists between concurrent calls to these
functions, potentially leading to incorrect GPIO direction settings.

To verify the correctness of this fix, a `trylock` patch was applied,
where after a couple of reboots the race was confirmed. I.e., one user
had to wait before acquiring the lock. With this patch the race has not
been encountered. It's worth mentioning that any type of debugging
(printing, tracing, etc.) would "resolve"/hide the issue.

Fixes: 659d8a62311f ("gpio: vf610: add imx7ulp support")
Signed-off-by: Johan Korsnes <johan.korsnes@remarkable.no>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250217091643.679644-1-johan.korsnes@remarkable.no
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-vf610.c