Skip to content

Conversation

@jbr-ia
Copy link
Contributor

@jbr-ia jbr-ia commented Sep 19, 2024

The driver enables the clock of a gpio-port if any of the pins use the port. This is done by calling pm_device_runtime_get when a pin is used and pm_device_runtime_put when the pin is not used anymore.
These calls needs to be balanced. But if a single pin was configured as GPIO_DISCONNECTED multiple times, every time pm_device_runtime_put was called.
This caused the clock of the port to be stopped and therefore also other pins on the same port stopped working.

This commit fixes this by keeping track of which pin on a port has requested the clock and only call pm_device_runtime_get or pm_device_runtime_put when the clock-request for the specific pin changes.

Fixes #77698

@github-actions
Copy link

Hello @jbr-ia, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this clarification would be useful.

Suggested change
/* Release clock only if pin is disconnected */
/* Decrement GPIO usage count only if pin is now disconnected after being connected */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that is indeed a better comment. The pull-request is updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/* keep track of pins that have enabled the clock*/
/* keep track of pins that are connected & need GPIO clock to be enabled */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I have updated the pull-request.

The driver enables the clock of a gpio-port if any of the
pins use the port. This is done by calling pm_device_runtime_get
when a pin is used and pm_device_runtime_put when the pin is not
used anymore.
These calls needs to be balanced. But if a single pin was configured
as GPIO_DISCONNECTED multiple times, every time pm_device_runtime_put
was called.
This caused the clock of the port to be stopped and therefore also
other pins on the same port stopped working.

This commit fixes this by keeping track of which pin on a port
has requested the clock and only call pm_device_runtime_get or
pm_device_runtime_put when the clock-request for the specific pin
changes.

Fixes zephyrproject-rtos#77698

Signed-off-by: Jeroen Broersen <jbroersen@interact.nl>
@jbr-ia jbr-ia force-pushed the gpio_allow_multiple_disconnect branch from 40e788f to 2a4f467 Compare September 20, 2024 07:29
@mmahadevan108 mmahadevan108 merged commit cf837dd into zephyrproject-rtos:main Sep 23, 2024
@github-actions
Copy link

Hi @jbr-ia!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuring gpio pin multiple times as disconnected can stop other pins to react on stm32

7 participants