-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/stm32/gpio: fix IRQ handler #16272
Conversation
34d1bc0
to
43f83a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense.
@jue89 was this recently introduced or has this bug been forever present? |
In any case I think this should be backported no? |
Thanks for your review and responses!
I've used the STM32F103RCT (which doesn't seem to be affected by this race condition even though the same pattern is used in the gpio_f1.c implementation) before I switched to the STM32F030CCT. So this seems to be a bug that has been introduced in 2016: df99604 So which releases should receive a backport? Nevertheless - can this PR be merged? Is one ACK enough? |
Yes one ACK is enough. |
Thanks for merging! I came to the conclusion that we should port this patch to the |
Contribution description
I've found a race condition in the GPIO IRQ handling. Without this patch, there is a small probability to get caught in an endless loop since the related Pending Request bit is never cleared.
What happend:
IMR
bit is enabledPR
bit is setIMR
bit is cleared by the programisr_exti()
is calledisr_exti()
reads thePR
bits and masks out the bit that caused its execution. Thus, thePR
bit is never cleared andisr_exti()
is called again aftercortexm_isr_end()
.Testing procedure
The DOSE driver uses the GPIO IRQ to detect start bits of Ethernet frames. This IRQ is then disabled during transmission and enabled after the whole frame has been received. Without this patch I was able to trigger the race condition within a few hours by creating some heavy bus traffic. After applying this patch, I was able to run this driver for days (tests are still ongoing).
To verify the mechanics (i.e. the PR bit must be cleared even if the corresponding IMR bit is unset) please see RM0360 Page 173 Figure 21
Issues/PRs references
none