Skip to content

stm32: Detach GPIO IRQ callbacks upon clearing "setevent" - #19520

Open
Javinator9889 wants to merge 2 commits into
apache:masterfrom
Javinator9889:bugfix/stm32_detach_callbacks_upon_gpio_clearing
Open

stm32: Detach GPIO IRQ callbacks upon clearing "setevent"#19520
Javinator9889 wants to merge 2 commits into
apache:masterfrom
Javinator9889:bugfix/stm32_detach_callbacks_upon_gpio_clearing

Conversation

@Javinator9889

Copy link
Copy Markdown
Contributor

Summary

When the interrupts get disabled, the callback(s) are still attached. That structure is never cleared, causing several calls to attach/detach to eventually fail as the callback queue gets full.

When the error occurs, the registration fails with error 12 (ENOMEM). By detaching the IRQ and clearing the callbacks, this error doesn't happen again

Impact

Calling stm32_gpiosetevent several times enabling and disabling the event ends up fulling the callback's queue, causing future calls to fail with ENOMEM without recovering from the error.

Testing

This has been tested thoroughly by attaching/detaching the events several times in a row. The behavior is now deterministic and one can add and remove GPIO events as much as wanted

@Javinator9889
Javinator9889 force-pushed the bugfix/stm32_detach_callbacks_upon_gpio_clearing branch from d6efcec to be784d2 Compare July 24, 2026 10:31
@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Size: XS The size of the change in this PR is very small labels Jul 24, 2026
When the interrupts get disabled, the callback(s) are still attached.
That structure is never cleared, causing several calls to attach/detach
to eventually fail as the callback queue gets full.

When the error occurs, the registration fails with error 12 (ENOMEM).
By detaching the IRQ and clearing the callbacks, this error doesn't
happen again

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
@Javinator9889
Javinator9889 force-pushed the bugfix/stm32_detach_callbacks_upon_gpio_clearing branch from be784d2 to 577bf5a Compare July 24, 2026 10:39
@github-actions github-actions Bot added Size: S The size of the change in this PR is small and removed Size: XS The size of the change in this PR is very small labels Jul 24, 2026
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

hifive1-revb

Comment thread arch/arm/src/common/stm32/stm32_exti_gpio_m0_v1.c
@Javinator9889
Javinator9889 force-pushed the bugfix/stm32_detach_callbacks_upon_gpio_clearing branch 2 times, most recently from 33d7af4 to 6624967 Compare July 29, 2026 08:51
@acassis

acassis commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Hi @Javinator9889 please fix these issues reported in the CI test:

https://github.com/apache/nuttx/actions/runs/30437203902/job/90559277045?pr=19520

@Javinator9889

Copy link
Copy Markdown
Contributor Author

Hi @Javinator9889 please fix these issues reported in the CI test:

https://github.com/apache/nuttx/actions/runs/30437203902/job/90559277045?pr=19520

Yes, I'm on it. I already fixed one issue but I'm still looking to address the new ones

@Javinator9889
Javinator9889 force-pushed the bugfix/stm32_detach_callbacks_upon_gpio_clearing branch from 6624967 to 7cd0423 Compare July 29, 2026 16:08
The fix was ported from the STM32G0 to all the STM32 platforms,
as the code is mostly the same hence presents the same failure

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
@Javinator9889
Javinator9889 force-pushed the bugfix/stm32_detach_callbacks_upon_gpio_clearing branch from 7cd0423 to b54cca3 Compare July 29, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants