Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4457331ybp; Mon, 14 Oct 2019 05:05:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqQZGPQ7YnFLGoscnubLsMVso7Veg7KDumSzg0UnYIaapmSBJFpPeEeor2TORHtPkBGeKV X-Received: by 2002:a50:ed0b:: with SMTP id j11mr28139725eds.50.1571054758873; Mon, 14 Oct 2019 05:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571054758; cv=none; d=google.com; s=arc-20160816; b=fuGgnoxYApe8KSSBoWY/HhBaBDN+Gzzetga/RSTsmEPVMXhONXptW9sMel048sZrlJ bfaM1MDblH/7PEP8sUt99WHS+mt/WfsPnRrkLO+2sk7JIKyWlaXRZANSgOByBDO5TXgG /fXThSYcPdE+iyf+7eyeZKUGyYcYeL3nZ2Y4PXwfAKkDl8LoThBntshsAc8CYV7ladjF 1lvCi9jMzRW7CZw2a+FnA1zs3RR2h4nX8+9Ob/1FpCpyUhOElN5XEYRzdbLN6eye420x 0cfsw71GPM3b38Mc7M2J0PIltvv4xSmTsTaOFZKSl2N+EMZjO6wE5cHq0HU/b2b8NGiG MBLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=1Ew6nvp+lIVXOTGUH+6CvvZJUmcbSc2ZNxvYMIXew0A=; b=yCF9mWlubiqtkNq3grNkM1mWGHkZj4FD+iSksIxWjN9ENah/5o3Ha6bCH1gWVl3Eyy 10qHUZssOC0zc4443P8E6yO4nmJiypybGoZ0PD7P2VUqiJWR0OrTmRtaKwq1wlEo3xOs XUsvV+PjJA8rVhye9/xO5IswB2BQzfGPWfKZ1cr2Thzzf6YKfe8OGLw/BSbDvPEBNfxR 62dwJL65OfWC0/9+8PY5s/2fA0Vth8ZvnKow19TmXJ6kreAEpIVpWWMdh/rd+wnP1Fwo 2Ij6ET9k4lY5GldtLNt11U45Q+dY1OiCsNb+hbISNeIltk6B8BpkphSC47GBcM1TIujD oKvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gbq/HeQV"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si10566673ejc.337.2019.10.14.05.05.29; Mon, 14 Oct 2019 05:05:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gbq/HeQV"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731261AbfJNMDd (ORCPT + 99 others); Mon, 14 Oct 2019 08:03:33 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33510 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731371AbfJNMDd (ORCPT ); Mon, 14 Oct 2019 08:03:33 -0400 Received: by mail-pl1-f194.google.com with SMTP id d22so7948322pls.0 for ; Mon, 14 Oct 2019 05:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=1Ew6nvp+lIVXOTGUH+6CvvZJUmcbSc2ZNxvYMIXew0A=; b=gbq/HeQVGZN31YpkwxiGgPCoN0r2zdogqzMJXRrbQizFzp3Zvjk+eG3xHT2HVWlyy0 yKoQjLIHCe0qcE5FvLMZysmpRQsx69QVdXF/tddh5HohWl0Q9NIf38blfmC7Fq1sjSB4 Ak3m4KZd93vrdGL9HYEPKodz4Ztok0bUTTyZm+wZxQM50eY0SRrOTJ5y8sjU5rTa4x8b qjI0w9oaCrHmxwIQkCSGQ6VHgMZD1WhwXAtIPeAJ2dgILuIA5LDlGwYbcYJvI4X1XSxW Xja2s77OedE10WM4nb/YkRJYfY0zsnU21WFEINy2Vx9ymomKtOMPof4G46/fvr3Sr1tc Hmrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1Ew6nvp+lIVXOTGUH+6CvvZJUmcbSc2ZNxvYMIXew0A=; b=GFXjmUujKxO8uNpHznN/al7FTKBSSkvCcAD0jBoYFsPt0wTTLGr7wxKjK8kRu09aot wVUREN4dVsnQSdMAFuZ708+c5tvyHUefb9UNCJb1wx0ih9QRgMmuMK7SBet/T6FPWQNi 224Y3WVPpED2vmNkb9q3siqkDdMtTzIxOwtsgyYbRcQ+Q4DXDE8z6Bn0RIdHYBb2Kh/2 P6otx/7VNQUaCIKnt6+fQpotw8Zl6GEZoC3z+JjBB49A9NVubjycN3A5UjGlPjW1E0pA CeNI4biUTT5jxhZiXoHS7/TZKQIJXJ7v7CtTrJWGCVXgotCv+xPvtx676gOK7RfOUegT pmAg== X-Gm-Message-State: APjAAAUi3f5iZVJwlwLhjdAk27OVeLQ7CZascw6ZosYSt7nOoftAw5jp Ot2b9prJEUwBMyyTPHlRsLxS34Tvaz8= X-Received: by 2002:a17:902:9306:: with SMTP id bc6mr30065583plb.133.1571054611544; Mon, 14 Oct 2019 05:03:31 -0700 (PDT) Received: from localhost.localdomain ([117.252.65.194]) by smtp.gmail.com with ESMTPSA id q6sm25026813pgn.44.2019.10.14.05.03.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Oct 2019 05:03:30 -0700 (PDT) From: Sumit Garg To: linux-crypto@vger.kernel.org Cc: dsaxena@plexity.net, herbert@gondor.apana.org.au, mpm@selenic.com, romain.perier@free-electrons.com, arnd@arndb.de, gregkh@linuxfoundation.org, daniel.thompson@linaro.org, ralph.siemsen@linaro.org, milan.stevanovic@se.com, ryan.harkin@linaro.org, linux-kernel@vger.kernel.org, Sumit Garg , stable@vger.kernel.org Subject: [PATCH] hwrng: omap - Fix RNG wait loop timeout Date: Mon, 14 Oct 2019 17:32:45 +0530 Message-Id: <1571054565-6991-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Existing RNG data read timeout is 200us but it doesn't cover EIP76 RNG data rate which takes approx. 700us to produce 16 bytes of output data as per testing results. So configure the timeout as 1000us to also take account of lack of udelay()'s reliability. Fixes: 383212425c92 ("hwrng: omap - Add device variant for SafeXcel IP-76 found in Armada 8K") Cc: Signed-off-by: Sumit Garg --- drivers/char/hw_random/omap-rng.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c index b27f396..e329f82 100644 --- a/drivers/char/hw_random/omap-rng.c +++ b/drivers/char/hw_random/omap-rng.c @@ -66,6 +66,13 @@ #define OMAP4_RNG_OUTPUT_SIZE 0x8 #define EIP76_RNG_OUTPUT_SIZE 0x10 +/* + * EIP76 RNG takes approx. 700us to produce 16 bytes of output data + * as per testing results. And to account for the lack of udelay()'s + * reliability, we keep the timeout as 1000us. + */ +#define RNG_DATA_FILL_TIMEOUT 100 + enum { RNG_OUTPUT_0_REG = 0, RNG_OUTPUT_1_REG, @@ -176,7 +183,7 @@ static int omap_rng_do_read(struct hwrng *rng, void *data, size_t max, if (max < priv->pdata->data_size) return 0; - for (i = 0; i < 20; i++) { + for (i = 0; i < RNG_DATA_FILL_TIMEOUT; i++) { present = priv->pdata->data_present(priv); if (present || !wait) break; -- 2.7.4