From patchwork Mon Dec 16 17:48:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181764 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp4622231och; Mon, 16 Dec 2019 09:58:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwkwgK/z8csQb2ioF+NXYbAMoKUY/0JY3q7avKv/KFm7RNUdy0jmKyscH3rBTAyjvVx8u95 X-Received: by 2002:a9d:578a:: with SMTP id q10mr31964924oth.215.1576519111080; Mon, 16 Dec 2019 09:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576519111; cv=none; d=google.com; s=arc-20160816; b=tXEk5Uw+aFxdWwzXnh/8rdVwwGrGS0uxwM1FZbDD1VFLMBQMtihMl2r4ESzGNo5sjK LEUVFp6O0XmSpA6BH4l+3mbNKbOr3ppWEu1YVIJlziJnN2SlhD8WoH2xInXxjkaYUI9L 3uapggL4G0/YI8y95mQLWvUb7YAcrsB3JzAN1XeZwoYdBZsb6cKdA+3Rz6htqkJ94yd5 ystbtcrjCnweT6SEm/53OZAHYizFQ2k77IjLsziLUzc/SNTKu00e/7fNqw0E8LOx0Nu9 IE8zR+ldqRaSjkTuQDZNmNgW4aRbG/vcbELo8EZD8R1Ntt5TPZX6M+fSAPXCJYa6YvCp K/9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RhZYkInM4/L4u9816xItFvcYX6P19603RTaOGJYRRcE=; b=QtD2UF5IJr+Z9fCUvkIUSw+mx1IzR3TdZr7eeF9A2ybhfJQ8BvMHA5sjohk/tWbt5H uB8+KrwQhQ0v8HLds1B9ejWGf8e83LEyCVxDowmw9xfhUR2W1Z/iQAtkm5OEoHR4NLf6 zGdcKwKV2QwME1mM7LiUaHw12BePNEWRYpm/T+z1Yhn/p/hkCE/g7sn+suSaKQkG24ch Qm+C7qxskLxJXq0s8l3kW5l9D9wrossLa+aeT5WnxMNQibkm8m16yMzn2Q6V+c9N9mfm SqwLYRvVfxS9AKMjHtkCRPbTwK8g7YyvQ1nKne6HxL3bM3PbM2mmUiyCUAH+F1NM99Lw Ce3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cLF3VTi7; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si11157360otq.73.2019.12.16.09.58.30; Mon, 16 Dec 2019 09:58:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@kernel.org header.s=default header.b=cLF3VTi7; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbfLPR63 (ORCPT + 14 others); Mon, 16 Dec 2019 12:58:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:58238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727862AbfLPR62 (ORCPT ); Mon, 16 Dec 2019 12:58:28 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 41B22205ED; Mon, 16 Dec 2019 17:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519107; bh=MpxtrENkNjZdHfFpgX0nTElVRVzAyCMKzMzjQ3oojsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLF3VTi71uj0PFGkCwmp4gXnw/jBA3ULbcXB/xFPLhz56XhozrgSc+qG5ANtxBKiq vxLt6oPLYJumo3juIJBfKhPDCHE8RHYpF1ij/mZNnIZB0hBcCKMXDUJoLOdu/S965o GT3/lHd5oMgId5yUbscFjWoPZiSUT99ZsWDJTGCQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , Herbert Xu Subject: [PATCH 4.14 199/267] hwrng: omap - Fix RNG wait loop timeout Date: Mon, 16 Dec 2019 18:48:45 +0100 Message-Id: <20191216174913.438567056@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174848.701533383@linuxfoundation.org> References: <20191216174848.701533383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sumit Garg commit be867f987a4e1222114dd07a01838a17c26f3fff upstream. 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 Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/char/hw_random/omap-rng.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- 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, @@ -175,7 +182,7 @@ static int omap_rng_do_read(struct hwrng 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;