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

drivers: entropy: stm32 entropy driver add semaphore protection #72882

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

FRASTM
Copy link
Collaborator

@FRASTM FRASTM commented May 16, 2024

When the PM is going to suspend mode, this change is adding a semaphore to protect the access to the RNG peripheral

Fixes #72640

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Issue is that in release_rng following is done:

	entropy_stm32_suspend();
#if defined(CONFIG_SOC_SERIES_STM32WBX) || defined(CONFIG_STM32H7_DUAL_CORE)
	z_stm32_hsem_unlock(CFG_HW_RNG_SEMID);
#endif /* CONFIG_SOC_SERIES_STM32WBX || CONFIG_STM32H7_DUAL_CORE */

So current implementation will end up with 2 consecutive z_stm32_hsem_unlock.

To take this into account, what about:
Calling release_rng instead of entropy_stm32_suspend and call lock semaphore before calls in entropy_stm32_rng_pm_action.

(maybe some function renaming would be required in the end to make all this more clear)

@FRASTM
Copy link
Collaborator Author

FRASTM commented Jun 3, 2024

change as suggested
Note that unlocking twice does not disturb the system (This is writing HSEM register)

@FRASTM FRASTM closed this Jun 3, 2024
@FRASTM FRASTM reopened this Jun 3, 2024
@FRASTM FRASTM force-pushed the issue72640 branch 2 times, most recently from 72e27e2 to 5945746 Compare June 3, 2024 15:19
@FRASTM FRASTM requested a review from erwango June 3, 2024 15:29
Add a semaphore to protect the disable access to the RNG peripheral
when the PM is going to suspend mode.
The change does not affect other stm32 than CONFIG_SOC_SERIES_STM32WBX
or CONFIG_STM32H7_DUAL_CORE

Signed-off-by: Francois Ramu <francois.ramu@st.com>
@aescolar aescolar merged commit 447bdea into zephyrproject-rtos:main Jun 4, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems with low power and entropy on STM32WB55
5 participants