From patchwork Mon Dec 16 17:48:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181786 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4675745ile; Mon, 16 Dec 2019 10:25:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyLC2rvaoaqX0Z18r8km58LTVhv52NEnhVVAvG/K76R1xI5X9edh+9itpS5Sxeuis0M8K3F X-Received: by 2002:aca:4712:: with SMTP id u18mr222476oia.93.1576520749897; Mon, 16 Dec 2019 10:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576520749; cv=none; d=google.com; s=arc-20160816; b=PxJQMc+SUsHPRCUQrNTwdJbh+kWiBu1AksVUsKI8aVhqa3XcT5eLBKCQA8KT8Af7Hx 3VQesRQgXbHcWQWXNZHmtTtBTBWbBLN2EHMwEPp2ztzuKUZTlCdBoNFghHyhJXZF8WiC IfAUUgS3aQSKIHtwxIvf2iV7in5KLGhSJ1NYj1XS93E6Jgs0dlBnxJSB6/U3ICbF757b 3qrJsZr6JouYc6Z9qhHjnpbrUfm+dbdT4EX9G+G0EJU71sKz7g42lwSi4MERks53ylMw io0afYRq9rbh3+JDUgct5cLBOdvpSGOKfjs0AsytlsSNUXq27qBJKmtycqmvI5UiVSm9 dGyQ== 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=MZf+Xw64B9aCTBHLkgJQHu3FWLkjCSyCcecHZ6GD+dk=; b=a8bteXVYdICgmwM1HrDmwS/Pk0AEWnTyi5FSVU7+YLkllYFEmJqlhV6BsuY6TpQVUK qIm4kD6yH/DMKr7hVUav/E5MlFn0fHNmiH6uK1/u5Ai7YF4KL8gJK+TLHsNSqC0pWYSi 04o9CBoKhJLWTdbBcCd3RdSyOVDA8neraEXV+/4QRqj+g9PMUPTJOFCAU7nt0Gk6Uw0V DAr2I5KKdLceNTYym/MLDTB6shTuB6y6AvRT7FxBcoZ29pHHEhIw6TavssNJHC82QiwM VUrSxunFQhxLvAp7WLEJDIxzwrw7Z3NpigO9WUjiPlOB15hQiR7wzrkQp63YUc3mAKT3 HOHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lmom3sP4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 w16si10939311oih.154.2019.12.16.10.25.49; Mon, 16 Dec 2019 10:25:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=Lmom3sP4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731892AbfLPSZs (ORCPT + 27 others); Mon, 16 Dec 2019 13:25:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:42278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731496AbfLPSRr (ORCPT ); Mon, 16 Dec 2019 13:17:47 -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 54E5C207FF; Mon, 16 Dec 2019 18:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520266; bh=QBrHzF/bDur2YZKXK3pZ0+nH4CtHkNb06QOzdb7jU/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lmom3sP440Gbbom3/8CzNIhDsJnvRBLhePANfqaxSOx3dVQBPek8OB9TcFhMz9Olc OyyVoMUtRkVl+Gru7oNK8nYs0uNY6xtYHS5ExFHJoKEB+BxrrzVhQB2EYnDvWKUXeL Tyu3HTXpw2vmi8jiY4WfUGSxakEIVauPmQb8X0v0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , Herbert Xu Subject: [PATCH 5.4 082/177] hwrng: omap - Fix RNG wait loop timeout Date: Mon, 16 Dec 2019 18:48:58 +0100 Message-Id: <20191216174837.647919779@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174811.158424118@linuxfoundation.org> References: <20191216174811.158424118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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, @@ -176,7 +183,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;