Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1236884pxa; Thu, 6 Aug 2020 03:04:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyET4855T5o0rwOPSS9bsEauQ5woQ/CAuUScPDOgzFGNUHKFp3eiqqO2povDg0j3LPVpUAv X-Received: by 2002:a05:6402:22c2:: with SMTP id dm2mr3232392edb.182.1596708241334; Thu, 06 Aug 2020 03:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596708241; cv=none; d=google.com; s=arc-20160816; b=NX71JBo0EjHxGI3c+VQBJl/ygaLjKr1Alc2ODx9KBaqXaf6X1LVupqe4a+Qw4imHaN FCyHpNjJ9lvI9huCyHF1BrDukOILieEK86g3t2XSNEq4tEAyOnsXisUQYDdi/SYfsof3 RaTQGEK5ToN3WKdMrznVJpPS8prw7AyYBj/Cx5KwlFrJ8B+VzgFwu1S8e5v2TvuFLiIa Cnq5peWNPkvdToGF+80L4nR/JhrbURBFMP4PKcFYcJlYsIfJg58YbM93mf4mXJRsue7g oYVYMrAqHutA4I/ngLvdtLl1w8UsCgIa4lsx129UodJQNZUgNmmwY/wQOOB8qsCOK4r4 ydUA== 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=+V7CqI/htEIIY4PnseQyLNdhHuJMGQr2hPmi29hq7rk=; b=xlswt6q1Jwn85ZtOLMyRRbyHzb7P4flpibviyEygndGedH4tXjWKh+TnXpNvAx6K4G 6NygdM0fZib5k2Wr27Fk05meof2WgKmbVB7+r4Uj8ofTJl69xAjqj7OSEIbJqhVaQuhX K4D/DyzVEtSbR7TyVdWLL4r8YK6pkrB4dDK3lkrwcXwAlw+Va4Ap3J0JV1iW2WvbNv67 QQ8LWx8bqn6ZTJ67skWDRTlHcb53oQjkHazYVKyIy8u+KU6mtCqh0iEvsvDcOKaN/bB8 0U5B0feeO8+xbcDwuVkZOJcp4tNpqNvnx5X/8WStuYJPooaK25TK6Env3JjPeqOfTdMb L2iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foundries-io.20150623.gappssmtp.com header.s=20150623 header.b=blwBIVMk; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a18si3181496ejr.262.2020.08.06.03.02.50; Thu, 06 Aug 2020 03:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foundries-io.20150623.gappssmtp.com header.s=20150623 header.b=blwBIVMk; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729266AbgHFKAj (ORCPT + 99 others); Thu, 6 Aug 2020 06:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729277AbgHFKAP (ORCPT ); Thu, 6 Aug 2020 06:00:15 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63EEEC061757 for ; Thu, 6 Aug 2020 03:00:15 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id p14so8292865wmg.1 for ; Thu, 06 Aug 2020 03:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=+V7CqI/htEIIY4PnseQyLNdhHuJMGQr2hPmi29hq7rk=; b=blwBIVMkBZZkw+M4KMDSy/63AIjjwVfHw43Oy0ACpSlXffJeTWN3CY93N5DaXkVswb 3HO9lN0cc7W/frHVpA1yzI+9QdNdtcTSbJ3U12dMbNGAMRnPXC6uourzC0TxP02RMSW0 2YZhbW77PIM3IWsGrmCnFyar1JiKYi8EC0zZ2eUfUIyLXV4zSaY/Tynm4kxpOKm0x7Tw o3yUaWgOxLx0kNiYBdmmp9itGhYWMLYKoPz53xjRL0+3b/ynmuHFvPDpqTtqpDB5wOs+ //cXcteNIqc1KkQ1WluccIM7NTYAxYVY50qpNsTStA573o5lNYOfDyRXIlEtEwixDkW/ xYeA== 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=+V7CqI/htEIIY4PnseQyLNdhHuJMGQr2hPmi29hq7rk=; b=ANd9FLrVdJTdgqHOyTLiRs/IVx8RVnOx5e4V9ZvIPjGUpHLEi4CCJqCBOQiix3W8UQ po1rOwxkLBMTsgq9yzPll2UQQ1WLGZMZHpoEBmMpqWepDwnY4jiGd0X9sXWCxhwn7nSD q9O511lNgnTz3I7G+luY2nkUdw+i3RXwDkAF/m1iSByTxudwJEgmg6CLlzsu6OdmyWRf mTjA47R7nXUfJM+jL+h7bNKJAlVbO+Gf2kM8WnI97CadykTFfvypFvlKWCwP2JDtsWXn vZezodiFn/mYmvo6LL9NWYZM8hLTzkLAWKoyIZ9cITMz/x4saVOdjKPMFGBWEMc1sJ1O WaDw== X-Gm-Message-State: AOAM5333MT7JMhoOjrfOCEgaMcYOXob5hkmSTPX5aupghJ0fJiSQPuV+ lK3VV3tknAJCna6gxI+JjzdrXg== X-Received: by 2002:a05:600c:2154:: with SMTP id v20mr7189068wml.186.1596708014190; Thu, 06 Aug 2020 03:00:14 -0700 (PDT) Received: from localhost.localdomain (239.red-83-34-184.dynamicip.rima-tde.net. [83.34.184.239]) by smtp.gmail.com with ESMTPSA id p3sm5741376wma.44.2020.08.06.03.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 03:00:13 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge@foundries.io, sumit.garg@linaro.org, jens.wiklander@linaro.org Cc: mpm@selenic.com, herbert@gondor.apana.org.au, arnd@arndb.de, ricardo@foundries.io, mike@foundries.io, gregkh@linuxfoundation.org, op-tee@lists.trustedfirmware.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCHv3 1/2] hwrng: optee: handle unlimited data rates Date: Thu, 6 Aug 2020 12:00:09 +0200 Message-Id: <20200806100010.20509-1-jorge@foundries.io> X-Mailer: git-send-email 2.17.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Data rates of MAX_UINT32 will schedule an unnecessary one jiffy timeout on the call to msleep. Avoid this scenario by using 0 as the unlimited data rate. Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Sumit Garg --- drivers/char/hw_random/optee-rng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/hw_random/optee-rng.c b/drivers/char/hw_random/optee-rng.c index 49b2e02537dd..5bc4700c4dae 100644 --- a/drivers/char/hw_random/optee-rng.c +++ b/drivers/char/hw_random/optee-rng.c @@ -128,7 +128,7 @@ static int optee_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) data += rng_size; read += rng_size; - if (wait) { + if (wait && pvt_data->data_rate) { if (timeout-- == 0) return read; msleep((1000 * (max - read)) / pvt_data->data_rate); -- 2.17.1