From patchwork Tue Oct 6 16:12:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 7336881 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 159ED9F1D5 for ; Tue, 6 Oct 2015 16:16:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 349FA2026C for ; Tue, 6 Oct 2015 16:16:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5425920266 for ; Tue, 6 Oct 2015 16:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753109AbbJFQPX (ORCPT ); Tue, 6 Oct 2015 12:15:23 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:37551 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbbJFQPS (ORCPT ); Tue, 6 Oct 2015 12:15:18 -0400 Received: by wicfx3 with SMTP id fx3so166440539wic.0 for ; Tue, 06 Oct 2015 09:15:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cePiwLigPM5Rd+SUu5b9uTdAAE/IqZk54iKGMzSiyj0=; b=mez0eQ6qxzEnHjQba7ozSU+WJkwYWp0wJXCSwWXxWQw7rGI2x15SJNSSLxbnvo0ofa MjjqOGmCJui7AnuSWgaxmqf7xffq9/rSWWf6sO+R4PzU9YUobNHnr+btlJ7NihDVCy/O w0WbajydfkEBKpHPOmqQWnv5qWidGJc+Wd8Y6+prBVGcNriEmw3/E+w1VmD4D546XA42 G4O+2h2zwg5Rr0jVHVC0bCatsFALZm0bwQE2wevEmnct5xZELHBf11LzGcVD39/T05WH 8pZ4Y3DKoT3CVC19ljJWJqcEabde9IF2xwMJd7DtvE3Eq7B+1KpbrTFL8xRSw6IDK6xz XOyA== X-Gm-Message-State: ALoCoQmLUBuiDdNjeL71cZIcssy0QnxiWkFTAKPRSWgttc10RZwNISGNWcazpMcnmKGmhdjrktyP X-Received: by 10.194.179.137 with SMTP id dg9mr37297224wjc.55.1444148116878; Tue, 06 Oct 2015 09:15:16 -0700 (PDT) Received: from localhost.localdomain (host81-129-171-83.range81-129.btcentralplus.com. [81.129.171.83]) by smtp.gmail.com with ESMTPSA id ki7sm33447912wjc.28.2015.10.06.09.15.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Oct 2015 09:15:16 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, peter@korsgaard.com, festevam@gmail.com, pankaj.dev@st.com, daniel.thompson@linaro.org, Lee Jones Subject: [RESEND 3/3] hwrng: st: Report correct FIFO size Date: Tue, 6 Oct 2015 17:12:51 +0100 Message-Id: <1444147971-25778-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444147971-25778-1-git-send-email-lee.jones@linaro.org> References: <1444147971-25778-1-git-send-email-lee.jones@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The values supplied to the 'read random data from FIFO' arithmetic are not correct. The value fed in to initialise the iterator describes the FIFO depth, but then the iterator is treated in Bytes and subsequently increased by 2 in value for every read word. This means only 4 of the 8 available values are being read during each invocation of .read(). This change increased the device bandwidth by a factor of 2. Reported-by: Daniel Thompson Reviewed-by: Daniel Thompson Signed-off-by: Lee Jones --- drivers/char/hw_random/st-rng.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/st-rng.c b/drivers/char/hw_random/st-rng.c index a1ff080..3b1432c 100644 --- a/drivers/char/hw_random/st-rng.c +++ b/drivers/char/hw_random/st-rng.c @@ -29,8 +29,9 @@ #define ST_RNG_STATUS_BAD_ALTERNANCE BIT(1) #define ST_RNG_STATUS_FIFO_FULL BIT(5) -#define ST_RNG_FIFO_SIZE 8 #define ST_RNG_SAMPLE_SIZE 2 /* 2 Byte (16bit) samples */ +#define ST_RNG_FIFO_DEPTH 8 +#define ST_RNG_FIFO_SIZE (ST_RNG_FIFO_DEPTH * ST_RNG_SAMPLE_SIZE) /* * Samples are documented to be available every 0.667us, so in theory