Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1250327
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/4] hwrng: exynos - Add timeout for waiting on init done |
| Date | 2015-10-19 06:50 +0200 |
| Message-ID | <qlayt-2bl-1@gated-at.bofh.it> (permalink) |
| References | <qlaoO-20i-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Driver may hang waiting indefinitely for PRNG to finish its initialization stage. Instead of stalling return -ETIMEDOUT error. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> --- drivers/char/hw_random/exynos-rng.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c index dc4701fd814f..dfaaaafb8ddd 100644 --- a/drivers/char/hw_random/exynos-rng.c +++ b/drivers/char/hw_random/exynos-rng.c @@ -81,14 +81,17 @@ static int exynos_read(struct hwrng *rng, void *buf, struct exynos_rng *exynos_rng = container_of(rng, struct exynos_rng, rng); u32 *data = buf; + int retry = 100; pm_runtime_get_sync(exynos_rng->dev); exynos_rng_writel(exynos_rng, PRNG_START, 0); while (!(exynos_rng_readl(exynos_rng, - EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE)) + EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry) cpu_relax(); + if (!retry) + return -ETIMEDOUT; exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2015-10-19 06:40 +0200 [PATCH 1/4] dt-bindings: rng: Describe Exynos4 PRNG bindings Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2015-10-19 06:40 +0200 [PATCH 4/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2015-10-19 06:40 +0200 [PATCH 2/4] hwrng: exynos - Add timeout for waiting on init done Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2015-10-19 06:50 +0200 Re: [PATCH 0/4] hwrng: exynos - Add Device Tree support Herbert Xu <herbert@gondor.apana.org.au> - 2015-10-20 16:30 +0200
csiph-web