From patchwork Mon Dec 16 17:48:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 181768 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp4630111och; Mon, 16 Dec 2019 10:04:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwn1d8CNf7AxHCvdBIBn68EKrlXFZs8QPBVKdqZ7NIXB6IprzIZqm6AlJpt0YxAhELfRVPH X-Received: by 2002:a9d:7094:: with SMTP id l20mr33678692otj.190.1576519472513; Mon, 16 Dec 2019 10:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576519472; cv=none; d=google.com; s=arc-20160816; b=SPrV1iJh/nY2z5Dvtk2wU/jHFxXs+2b3cZlEbih+48d0sVm4ADmd4UW/3/rDYLvgAY UMcdeK3FxzQPGSw6Cf1ZHz9h4FE3BZBY/HmStIDiPTbovVzv1pfpGCyc5eg+AH1F0lF8 LVs/jiAyWETVJ3je/R0LvTC+wmAjImBPkQCbZuEzhnmzmQtX2mwTaKP1k2LsC/2dyq5o hyNSCJN+nqMbOViE2xgJxlAVmMzR2PUAs1s9r7F+kyI0TfelSu2j22YX+/HnKA3X8sxr PY5fm4f6qUYkfZWJ3eo77IBnXilIKvGjVjlH/BN1tdQvH5I/mXzkQMxz6/lxmQxWNf92 3qBA== 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=YwkIGYRausAHKAHUEt7SmWTDd1IoPB6f2bU4sWf0jcaYLhitSoG+ZigLnyoM0CRwdC v2+z4xXYoH6SAmySbVxilDicyQlgLw3kJCFboJHk8ONONwqGrH8ZZlu7Qi5vDMEvF01K 3awJtnFC96hSa1EcdUxk+VmHm4niTKHlBvte51h0CMTiqaPWU/J0wc1P8VlZq21twW4x Y4gCZoFH8SsthLNy99gs2mwY2K8akTrNvkio7B7v4NK5trU9dt1VdHFQjz9ybLqLVt6C scoKKUzPw/PDaU9EI8OuSPga37M8AwFYP5skXdk3lPay3P8zNxsirnr22I7/cZ6O99VP FOdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LhTxaiFe; 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 d8si11612943otf.32.2019.12.16.10.04.32; Mon, 16 Dec 2019 10:04:32 -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=LhTxaiFe; 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 S1729244AbfLPSEa (ORCPT + 27 others); Mon, 16 Dec 2019 13:04:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:41720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729647AbfLPSE0 (ORCPT ); Mon, 16 Dec 2019 13:04:26 -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 2877B20700; Mon, 16 Dec 2019 18:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519465; bh=QBrHzF/bDur2YZKXK3pZ0+nH4CtHkNb06QOzdb7jU/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LhTxaiFez0aTjhncBod7a+3i3s4Koyc3B5SXAPBaOTZebf5u5fNeazRODa32P5WT/ ExU0rEq/ejk5NUuJs+c4wXgCN8qd8DVBsN/HWfzPJohJJ+O1tJkweyyU68yxh536pc q8/2L2XlVj6Qf6mse8u3mW139U+6WX1uiby5tw4I= 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.19 050/140] hwrng: omap - Fix RNG wait loop timeout Date: Mon, 16 Dec 2019 18:48:38 +0100 Message-Id: <20191216174802.353047701@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174747.111154704@linuxfoundation.org> References: <20191216174747.111154704@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;