]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
pinctrl-bcm2835.c: fix race condition when setting gpio dir
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 20 Apr 2023 12:47:05 +0000 (14:47 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 Jul 2023 10:17:11 +0000 (12:17 +0200)
commit95e93a75f6efe465bafee9763337b83785ae851c
tree247706dfacb58accf4e2f430ec1b3a079f0c5f6d
parente16192e827f504079a571fc5e8ab2352b51aaca9
pinctrl-bcm2835.c: fix race condition when setting gpio dir

BugLink: https://bugs.launchpad.net/bugs/2025067
[ Upstream commit b7badd752de05312fdb1aeb388480f706d0c087f ]

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@xs4all.nl>
Fixes: 1a4541b68e25 ("pinctrl-bcm2835: don't call pinctrl_gpio_direction()")
Link: https://lore.kernel.org/r/4302b66b-ca20-0f19-d2aa-ee8661118863@xs4all.nl
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/pinctrl/bcm/pinctrl-bcm2835.c