Commit da62ed5c authored by Marek Vasut's avatar Marek Vasut Committed by Herbert Xu

hwrng: stm32 - put IP into RPM suspend on failure

In case of an irrecoverable failure, put the IP into RPM suspend
to avoid RPM imbalance. I did not trigger this case, but it seems
it should be done based on reading the code.

Fixes: b17bc6eb ("hwrng: stm32 - rework error handling in stm32_rng_read()")
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 31b57788
...@@ -220,7 +220,8 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) ...@@ -220,7 +220,8 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
if (err && i > RNG_NB_RECOVER_TRIES) { if (err && i > RNG_NB_RECOVER_TRIES) {
dev_err((struct device *)priv->rng.priv, dev_err((struct device *)priv->rng.priv,
"Couldn't recover from seed error\n"); "Couldn't recover from seed error\n");
return -ENOTRECOVERABLE; retval = -ENOTRECOVERABLE;
goto exit_rpm;
} }
continue; continue;
...@@ -238,7 +239,8 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) ...@@ -238,7 +239,8 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
if (err && i > RNG_NB_RECOVER_TRIES) { if (err && i > RNG_NB_RECOVER_TRIES) {
dev_err((struct device *)priv->rng.priv, dev_err((struct device *)priv->rng.priv,
"Couldn't recover from seed error"); "Couldn't recover from seed error");
return -ENOTRECOVERABLE; retval = -ENOTRECOVERABLE;
goto exit_rpm;
} }
continue; continue;
...@@ -250,6 +252,7 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) ...@@ -250,6 +252,7 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
max -= sizeof(u32); max -= sizeof(u32);
} }
exit_rpm:
pm_runtime_mark_last_busy((struct device *) priv->rng.priv); pm_runtime_mark_last_busy((struct device *) priv->rng.priv);
pm_runtime_put_sync_autosuspend((struct device *) priv->rng.priv); pm_runtime_put_sync_autosuspend((struct device *) priv->rng.priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment