-
Notifications
You must be signed in to change notification settings - Fork 8.1k
drivers: entropy: Fix non-stop RNG ISR firing for STM32WB09 #98151
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,12 @@ | |||||
| #define STM32_CONDRST_SUPPORT | ||||||
| #endif | ||||||
|
|
||||||
| #if IRQLESS_TRNG | ||||||
| #define MAX_AVAIL_RND_NUM 1 | ||||||
| #else | ||||||
| #define MAX_AVAIL_RND_NUM 4 /* Internal four-word FIFO */ | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When an error is triggered only 3 samples are to be removed from the 4-word FIFO. That said, the change shows something that was not update by commit d65f8e3: indeed value 12 should have been updated to 3 at that time and no-FIFO instance addressed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't really matter, reading empty FIFO will just return 0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And FWIW other IPs do also have a FIFO but no corresponding "FIFO full" interrupt so I'm not sure that lowering this value is "correct" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think lowering the value will fix anything. Just a matter of consistency. |
||||||
| #endif /* IRQLESS_TRNG */ | ||||||
|
|
||||||
| /* | ||||||
| * This driver need to take into account all STM32 family: | ||||||
| * - simple rng without hardware fifo and no DMA. | ||||||
|
|
@@ -327,10 +333,16 @@ static int recover_seed_error(RNG_TypeDef *rng) | |||||
| { | ||||||
| ll_rng_clear_seis(rng); | ||||||
|
|
||||||
| for (int i = 0; i < 12; ++i) { | ||||||
| for (int i = 0; i < MAX_AVAIL_RND_NUM; ++i) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be replaced with:
Suggested change
to be more solid |
||||||
| (void)ll_rng_read_rand_data(rng); | ||||||
| } | ||||||
|
|
||||||
| #if defined(CONFIG_SOC_STM32WB09XX) | ||||||
| if (LL_RNG_GetErrorIrq(rng)) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 on Etienne's comment: unless there's a reason for it, let's not bother checking for the flags. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean clearing a flag without checking if it is raised? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Per RefMan, this should have no effect |
||||||
| SET_BIT(rng->IRQ_SR, RNG_IRQ_SR_ERROR_IRQ); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The flag should have already been cleared by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @etienne-lms , There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake. Indeed it is an error, we should clear that bit. I think we need to revisit a bit WB09xx sequences in this driver. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use new bits handling functions: #97329 |
||||||
| } | ||||||
| #endif /* CONFIG_SOC_STM32WB09XX */ | ||||||
|
|
||||||
| if (ll_rng_is_active_seis(rng) != 0) { | ||||||
| return -EIO; | ||||||
| } | ||||||
|
|
@@ -445,7 +457,7 @@ static uint16_t generate_from_isr(uint8_t *buf, uint16_t len) | |||||
| ret = random_sample_get(&rnd_sample); | ||||||
| #if !IRQLESS_TRNG | ||||||
| NVIC_ClearPendingIRQ(IRQN); | ||||||
| #endif /* IRQLESS_TRNG */ | ||||||
| #endif /* !IRQLESS_TRNG */ | ||||||
|
|
||||||
| if (ret < 0) { | ||||||
| continue; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,9 @@ static inline rng_sample_t ll_rng_read_rand_data(RNG_TypeDef *RNGx) | |
| * Raw register access is performed because STM32CubeWB0 v1.0.0 | ||
| * package is lacking the LL function to clear IRQ flags. | ||
| */ | ||
| WRITE_REG(RNG->IRQ_SR, RNG_IRQ_SR_FF_FULL_IRQ); | ||
| if (LL_RNG_GetFfFullIrq(RNGx)) { | ||
| SET_BIT(RNGx->IRQ_SR, RNG_IRQ_SR_FF_FULL_IRQ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What you're saying is the opposite. As the name suggests,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know what the macros do. If Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I understand, thanks for the clarification. |
||
| } | ||
|
|
||
| return rnd; | ||
| #elif defined(CONFIG_SOC_SERIES_STM32WB0X) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,9 @@ endif # STM32WB0_RADIO_TIMER | |||||||||
|
|
||||||||||
| if BT | ||||||||||
|
|
||||||||||
| config SYSTEM_WORKQUEUE_STACK_SIZE | ||||||||||
| default 1152 | ||||||||||
|
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| config BT_AUTO_PHY_UPDATE | ||||||||||
| default n | ||||||||||
|
|
||||||||||
|
|
||||||||||

Uh oh!
There was an error while loading. Please reload this page.