Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1827473pxb; Fri, 5 Mar 2021 00:09:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyusYV/b5GWMYAsxyvtYY7v0c0Vc5xCILxxpRfUPU0i5dEsD5/BY1vT4HcCGJRMlIEtyzd/ X-Received: by 2002:a17:906:72d1:: with SMTP id m17mr1260119ejl.118.1614931745050; Fri, 05 Mar 2021 00:09:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614931745; cv=none; d=google.com; s=arc-20160816; b=IkJ2z/RR9mNOKLn3eNIJL6MjgFCE26MAY251Xjqp3iRfv6gSjZsCY7dvNcdfCNPHis j5hJlOh5Zvw85tR9Q+F5kO+eBnYB7vmyA8n8O2+S+TA2qLRbA+6Sapk9+lUeO5su05oV xZi/dMPNxPrkDr1lKnrQseHEliU3OvGsKH8gN6O2OJjK16yhr3VjDvhBDwWs+4Df3Sm7 k4Aeb/um83rQYpIaOcHjZ0jR8jUm38uh/hVmuN6/Gtn5ga7Mhyf5HkOj/Hj9wQUGizgh Fp1XYRoSIOpGIbHje/BIdPDGJY4GQe86inBAp7sRAnMzMGQo2jKQmSQsN7XCnVCZJByL qhIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id; bh=hlEtXi2CRo0aqpTMdrWTXY84WJQYyVTJkUTRYItsiFM=; b=GWIXTxxCvv2Hbf99RSV4kixhksHN0g9xkrjV3rbfONwS3rXic70MpahfU1A7RJd+a0 f75bmM/LjDMQFBbNWu9iZQRWntyFFiVvZUeZWcRA6ghgB7ypG/7WDYkRr7UuJ+KV9zCd kfESq4WH4yCRUwB0zhcKAqNmJ9Dj/mJTjbDBZRx8+n1nHKBdb0oWBMherlwjlQF+PUYu /8ZG1MQIKKT50gnl2U5eX1XbDG6cSoH2ABWdKnc9yoZgCw+cxrDwNqC82PMn+8gKTV6G 3WygE4sZTi3HPVyuf1Evmqjw2zy9Px1X+O88dDzBHBFqXgV6LFFiEMdTOp7HAc8IOaG9 SJkQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v10si999880ejq.299.2021.03.05.00.08.35; Fri, 05 Mar 2021 00:09:05 -0800 (PST) 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; 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 S229517AbhCEIIL convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Mar 2021 03:08:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbhCEIIG (ORCPT ); Fri, 5 Mar 2021 03:08:06 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9517C061574 for ; Fri, 5 Mar 2021 00:08:06 -0800 (PST) Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lI5Ux-0004nt-Hu; Fri, 05 Mar 2021 09:07:47 +0100 Received: from pza by lupine with local (Exim 4.92) (envelope-from ) id 1lI5Uj-0003Ld-FI; Fri, 05 Mar 2021 09:07:33 +0100 Message-ID: <22817e0d7f266ebf2d8e6b28495736cdb9c6d6f3.camel@pengutronix.de> Subject: Re: [PATCH v6 3/3] hwrng: bcm2835: add reset support From: Philipp Zabel To: =?ISO-8859-1?Q?=C1lvaro_Fern=E1ndez?= Rojas , Matt Mackall , Herbert Xu , Rob Herring , Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Lee Jones , Bjorn Andersson , Alexandru Ardelean , Rikard Falkeborn , Tian Tao , Stefan Wahren , linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 05 Mar 2021 09:07:33 +0100 In-Reply-To: <20210305070132.2986-4-noltari@gmail.com> References: <20210305070132.2986-1-noltari@gmail.com> <20210305070132.2986-4-noltari@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-crypto@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, 2021-03-05 at 08:01 +0100, Álvaro Fernández Rojas wrote: > BCM6368 devices need to reset the IPSEC controller in order to generate true > random numbers. > > This is what BCM6368 produces without a reset: > root@OpenWrt:/# cat /dev/hwrng | rngtest -c 1000 > rngtest 6.10 > Copyright (c) 2004 by Henrique de Moraes Holschuh > This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > rngtest: starting FIPS tests... > rngtest: bits received from input: 20000032 > rngtest: FIPS 140-2 successes: 0 > rngtest: FIPS 140-2 failures: 1000 > rngtest: FIPS 140-2(2001-10-10) Monobit: 2 > rngtest: FIPS 140-2(2001-10-10) Poker: 1000 > rngtest: FIPS 140-2(2001-10-10) Runs: 1000 > rngtest: FIPS 140-2(2001-10-10) Long run: 30 > rngtest: FIPS 140-2(2001-10-10) Continuous run: 0 > rngtest: input channel speed: (min=37.253; avg=320.827; max=635.783)Mibits/s > rngtest: FIPS tests speed: (min=12.141; avg=15.034; max=16.428)Mibits/s > rngtest: Program run time: 1336176 microseconds > > Signed-off-by: Álvaro Fernández Rojas Reviewed-by: Philipp Zabel regards Philipp > --- > v6: fix commit description. > v5: remove reset_control_rearm(). > v4: add reset_control_rearm(). > v3: no changes. > v2: no changes. > > drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c > index be5be395b341..e7dd457e9b22 100644 > --- a/drivers/char/hw_random/bcm2835-rng.c > +++ b/drivers/char/hw_random/bcm2835-rng.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > #define RNG_CTRL 0x0 > #define RNG_STATUS 0x4 > @@ -32,6 +33,7 @@ struct bcm2835_rng_priv { > void __iomem *base; > bool mask_interrupts; > struct clk *clk; > + struct reset_control *reset; > }; > > static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng) > @@ -92,6 +94,10 @@ static int bcm2835_rng_init(struct hwrng *rng) > if (ret) > return ret; > > + ret = reset_control_reset(priv->reset); > + if (ret) > + return ret; > + > if (priv->mask_interrupts) { > /* mask the interrupt */ > val = rng_readl(priv, RNG_INT_MASK); > @@ -156,6 +162,10 @@ static int bcm2835_rng_probe(struct platform_device *pdev) > if (IS_ERR(priv->clk)) > return PTR_ERR(priv->clk); > > + priv->reset = devm_reset_control_get_optional_exclusive(dev, NULL); > + if (IS_ERR(priv->reset)) > + return PTR_ERR(priv->reset); > + > priv->rng.name = pdev->name; > priv->rng.init = bcm2835_rng_init; > priv->rng.read = bcm2835_rng_read;