Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gpio-fsm race condition #5596

Merged
merged 2 commits into from
Sep 8, 2023
Merged

Conversation

pelwell
Copy link
Contributor

@pelwell pelwell commented Sep 8, 2023

Under certain circumstances (building the gpio-fsm module into the kernel seems to be a factor), it is possible for a gpio-fsm soft GPIO to be driven before the FSM has entered its start state, causing a crash. Partition the code more carefully into that which can sleep (non-atomic) and that which can't (atomic), avoiding using the workqueue unless trying to drive GPIOs from atomic code. With this done, it becomes clear that the probe function can just call the non-atomic gpio_fsm_enter_state directly.

Move some functions into a more logical ordering. This change causes
no functional change and is essentially cosmetic.

Signed-off-by: Phil Elwell <[email protected]>
Partition the code to separate atomic and non-atomic methods so that
none of them have to handle both cases. The result avoids using deferred
work unless necessary, and should be easier to understand.

Signed-off-by: Phil Elwell <[email protected]>
@pelwell pelwell merged commit f0061ff into raspberrypi:rpi-6.1.y Sep 8, 2023
11 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Sep 8, 2023
kernel: Fix gpio-fsm race condition
See: raspberrypi/linux#5596
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Sep 8, 2023
kernel: Fix gpio-fsm race condition
See: raspberrypi/linux#5596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant