[PATCHv2] pinctrl-bcm2835.c: fix race condition when setting gpio dir

Linus Walleij linus.walleij at linaro.org
Fri Apr 21 02:01:39 PDT 2023


On Thu, Apr 20, 2023 at 2:47 PM Hans Verkuil <hverkuil-cisco at xs4all.nl> wrote:

> In the past setting the pin direction called pinctrl_gpio_direction()
> which uses a mutex to serialize this. That was changed to set the
> direction directly in the pin controller driver, but that lost the
> serialization mechanism. Since the direction of multiple pins are in
> the same register you can have a race condition, something that was
> in fact observed with the cec-gpio driver.
>
> Add a new spinlock to serialize writing to the FSEL registers.
>
> Signed-off-by: Hans Verkuil <hverkuil-cisco at xs4all.nl>
> Fixes: 1a4541b68e25 ("pinctrl-bcm2835: don't call pinctrl_gpio_direction()")

I just applied this patch now so it can go in with the rest of the patches
for the merge window. I don't especially fancy having to immediately
start a fixes branch before I've even sent the bulk of patches to Torvalds.

Yours,
Linus Walleij



More information about the linux-rpi-kernel mailing list