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 cc32xx gpio driver to prevent spurious interrupts in gpio_basic_api test #22850

Merged
merged 2 commits into from
Feb 18, 2020

Conversation

vanti
Copy link
Collaborator

@vanti vanti commented Feb 15, 2020

Analyzing #22847 has shown that spurious interrupts are observed when invoking test_callback for level-based interrupt type. The test hangs due to interrupts being repeatedly fired. This is fixed by performing the following:

  • Avoid unnecessarily disabling gpio interrupts when firing registered callbacks. This is an issue because gpio_basic_api's test_deprecated test case attempts to disable interrupts on a pin under certain conditions by invoking gpio_pin_configure(), which has no effect given they get re-enabled as soon as the callbacks are done firing.

  • Disable gpio interrupts prior to changing the interrupt type in gpio_cc32xx_pin_interrupt_configure(), in case interrupts were already enabled by previous test cases.

In the gpio isr, gpio interrupts are disabled when invoking the
registered callbacks. This is unnecessary, and causes a problem if the
callback attempts to disable gpio interrupts by reconfiguring the pin
as in the test gpio_basic_api.

Fixes zephyrproject-rtos#22847

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good.

It does highlight that we didn't really take into account interaction between existing callbacks and changing the interrupt configuration. Or at least document the state machine that should model the desired behavior across platforms.

drivers/gpio/gpio_cc32xx.c Outdated Show resolved Hide resolved
@mnkp mnkp added area: GPIO bug The issue is a bug, or the PR is fixing a bug area: Drivers labels Feb 15, 2020
@mnkp mnkp linked an issue Feb 15, 2020 that may be closed by this pull request
@carlescufi carlescufi added this to the v2.2.0 milestone Feb 15, 2020
Disabling gpio interrupts on the pin prior to changing its interrupt
type to level-based helps prevent spurious interrupts that would be
otherwise observed, if gpio interrupts were originally enabled when
gpio_cc32xx_pin_interrupt_configure() is invoked.

Fixes zephyrproject-rtos#22847

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
@galak galak merged commit a9bfd28 into zephyrproject-rtos:master Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Drivers area: GPIO bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test gpio_basic_api hangs on cc3220sf_launchxl
5 participants