From patchwork Mon Oct 19 04:37:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 7432941 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8CEDCBEEA4 for ; Mon, 19 Oct 2015 04:40:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9A8A2073B for ; Mon, 19 Oct 2015 04:40:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E232F20741 for ; Mon, 19 Oct 2015 04:40:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752752AbbJSEir (ORCPT ); Mon, 19 Oct 2015 00:38:47 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:38557 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752232AbbJSEiC (ORCPT ); Mon, 19 Oct 2015 00:38:02 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NWG00IIEA7BGN50@mailout3.w1.samsung.com>; Mon, 19 Oct 2015 05:37:59 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-89-562473a7e566 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id CD.6B.04846.7A374265; Mon, 19 Oct 2015 05:37:59 +0100 (BST) Received: from localhost.localdomain ([10.252.80.64]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NWG00GZTA6Y7Q50@eusync3.samsung.com>; Mon, 19 Oct 2015 05:37:59 +0100 (BST) From: Krzysztof Kozlowski To: Kukjin Kim , Krzysztof Kozlowski , Matt Mackall , Herbert Xu , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Cc: Heiner Kallweit Subject: [PATCH 2/4] hwrng: exynos - Add timeout for waiting on init done Date: Mon, 19 Oct 2015 13:37:40 +0900 Message-id: <1445229462-32395-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1445229462-32395-1-git-send-email-k.kozlowski@samsung.com> References: <1445229462-32395-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBLMWRmVeSWpSXmKPExsVy+t/xq7rLi1XCDPbPFLWYf+Qcq0X3KxmL Re9nsFq8fmFo0f/4NbPFpsfXWC3u3/vJZHF51xw2ixnn9zFZLNjWx+jA5bFz1l12j20HVD02 repk89i8pN6jb8sqRo++lxsYPT5vkgtgj+KySUnNySxLLdK3S+DKOHngA3vBOY6K13/CGhjn sHcxcnBICJhIvH/l18XICWSKSVy4t56ti5GLQ0hgKaPEvXczGSGc/4wSKx8+YQSpYhMwlti8 fAlYlYjAYSaJbfMOs4AkmAW0JB59nsIKYgsLeEqsWHEZLM4ioCrRcq+DCcTmFXCXWHP0HgvE OjmJk8cmg9VzCnhIzOw9wgZiCwHV3F3yl3kCI+8CRoZVjKKppckFxUnpuYZ6xYm5xaV56XrJ +bmbGCHh92UH4+JjVocYBTgYlXh4HxxRChNiTSwrrsw9xCjBwawkwpt9WDlMiDclsbIqtSg/ vqg0J7X4EKM0B4uSOO/cXe9DhATSE0tSs1NTC1KLYLJMHJxSDYzL81yq5T79PrP7+Crxl9LO G1u4+lo/ZRz+obdRrvLLgWdJInclHUv8JsTbHH3rmzO72Xf+kh3Zhup2tte6rrwSvfy0SKRe 9gePscrdXee7l+ZelrRQePDx5e/dsvqX+nnY3lefWfZEwr5Lhil63srAT5FMZ/50md+3F45n 6FvB8+NyuFG5hIQSS3FGoqEWc1FxIgAdwxLQOwIAAA== Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Driver may hang waiting indefinitely for PRNG to finish its initialization stage. Instead of stalling return -ETIMEDOUT error. Signed-off-by: Krzysztof Kozlowski --- 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);