From patchwork Sat Aug 26 11:28:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13366584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52FC8C83F11 for ; Sat, 26 Aug 2023 11:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eZJroIld6CsMmyV/C7UIuUqIdcJaSn6YqlQROYuf6ys=; b=bmJg9+LPJiSa0+ qG9dgAPkVDNmsseg08lLgtsxySbTbwyR80ra/9kf/Dijb3+g0x/8pil+DabXL4e3B/pNn8gTzlEGz MSAGsFgFDsxN402nTYgU8aaUgpCOPGgs8nnGUUZ7VgFZD7UPivUAsRyurttxxQmxDl0IrJ4EoDd8s PLioGB12IWLsRiKCTD5FcwDojN56N/MTQFDoe3sY2rtfMM/RMbzSM3El/0bqXXq7SACVZNNgTzoox i853kddlDky4umdfXw6rZtXF8qEecJn644HRmLCWkJOjI9/GPqUf8z2FZJhjf8W6jm0XljW9zMsMx xxo8tOAF/AsAKxxQZd8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qZrTn-006qGo-2r; Sat, 26 Aug 2023 11:29:23 +0000 Received: from mout.gmx.net ([212.227.17.20]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qZrTk-006qFY-0d for linux-arm-kernel@lists.infradead.org; Sat, 26 Aug 2023 11:29:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1693049347; x=1693654147; i=wahrenst@gmx.net; bh=rPNVIq+eiEBeeUY1NCey4A6+NK7K5p71Kf2k0g5gw+M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=RleJzVedYE3/dHrDI1xRjqYhRiktqLwYExai6EmsnTrwoE99FX7BkWCTuX/mU1Dx/Hsx8+J vRXgY0MLMSQKe2LWGBMidX4Q86r+H4L1M5OYikVXaJoROq7+kPX0kGxWcwyx3s8wG7/MlebiX A0fxk/oWFLWu39DTN11yYt38sI81gwwLWkXe+90oswHpPRs6i3t4OX/h7HKUTeQFq9iHr04Js W4yQXYBjVqW7DkWv/yoJX+TPC1IhIg3wFRfQZfzQRzPQZ+DAkNZ8JyNgTkZYRHeGhvv9YaTC9 R5NP2tWA01eQSNNQ7x5LtywWJqFpupRWtrs+Nls/KvUnTUXLNCdA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MqJqN-1pwNs00U55-00nUXT; Sat, 26 Aug 2023 13:29:07 +0200 From: Stefan Wahren To: Olivia Mackall , Herbert Xu , Florian Fainelli , Ray Jui , Scott Branden Cc: "Jason A. Donenfeld" , Mark Brown , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Stefan Wahren Subject: [PATCH] hwrng: bcm2835: Fix hwrng throughput regression Date: Sat, 26 Aug 2023 13:28:28 +0200 Message-Id: <20230826112828.58046-1-wahrenst@gmx.net> X-Mailer: git-send-email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EdCcJakdIfh5i78x/BH0OPn6E9WfT5Q7iBoIWTGE3ibY/Xnkr s3hdQwv76ew1aO4RSPx5SpnBG/mVs6n6HWhf+IoS3ytocpU+FC00s6znjPtKV12p5+qDiL7e4 DsZ5DBKMmAq1Aw5qnDP+VhScfLLBTnybS5k/5Qwlegn55nGxKMr6NONAQy4KX/85HYmnnf4GI Nk2UdQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230826_042920_763808_8262AAAA X-CRM114-Status: GOOD ( 10.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The recent RCU stall fix caused a massive throughput regression of the hwrng on Raspberry Pi 0 - 3. So try to restore a similiar throughput as before the RCU stall fix. Some performance measurements on Raspberry Pi 3B+ (arm64/defconfig): sudo dd if=/dev/hwrng of=/dev/null count=1 bs=10000 cpu_relax ~138025 Bytes / sec hwrng_msleep(1000) ~13 Bytes / sec usleep_range(100,200) ~92141 Bytes / sec Fixes: 96cb9d055445 ("hwrng: bcm2835 - use hwrng_msleep() instead of cpu_relax()") Link: https://lore.kernel.org/linux-arm-kernel/bc97ece5-44a3-4c4e-77da-2db3eb66b128@gmx.net/ Signed-off-by: Stefan Wahren --- drivers/char/hw_random/bcm2835-rng.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c index e98fcac578d6..3f1b6aaa98ee 100644 --- a/drivers/char/hw_random/bcm2835-rng.c +++ b/drivers/char/hw_random/bcm2835-rng.c @@ -14,6 +14,7 @@ #include #include #include +#include #define RNG_CTRL 0x0 #define RNG_STATUS 0x4 @@ -71,7 +72,7 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max, while ((rng_readl(priv, RNG_STATUS) >> 24) == 0) { if (!wait) return 0; - hwrng_msleep(rng, 1000); + usleep_range(100, 200); } num_words = rng_readl(priv, RNG_STATUS) >> 24;