drivers: entropy: stm32 rng driver should not block if Seed error occurs
When a Seed error occurs during the random nb generation, the driver tries to recover and exit without providing a random data This avoids looping endlessly on the DRDY bit of the RNG status reg because it remains 0 in case of error. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
parent
ea3f3dac50
commit
8e99151937
1 changed files with 12 additions and 0 deletions
|
@ -361,6 +361,18 @@ static int entropy_stm32_rng_get_entropy_isr(const struct device *dev,
|
||||||
irq_disable(IRQN);
|
irq_disable(IRQN);
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
|
|
||||||
|
/* do not proceed if a Seed error occurred */
|
||||||
|
if (LL_RNG_IsActiveFlag_SECS(entropy_stm32_rng_data.rng) ||
|
||||||
|
LL_RNG_IsActiveFlag_SEIS(entropy_stm32_rng_data.rng)) {
|
||||||
|
|
||||||
|
(void)random_byte_get(); /* this will recover the error */
|
||||||
|
/* restore irq as we enter */
|
||||||
|
if (irq_enabled) {
|
||||||
|
irq_enable(IRQN);
|
||||||
|
}
|
||||||
|
return 0; /* return cnt is null : no random data available */
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear NVIC pending bit. This ensures that a subsequent
|
/* Clear NVIC pending bit. This ensures that a subsequent
|
||||||
* RNG event will set the Cortex-M single-bit event register
|
* RNG event will set the Cortex-M single-bit event register
|
||||||
* to 1 (the bit is set when NVIC pending IRQ status is
|
* to 1 (the bit is set when NVIC pending IRQ status is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue