Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751946AbdFTLpm (ORCPT ); Tue, 20 Jun 2017 07:45:42 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35596 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbdFTLpk (ORCPT ); Tue, 20 Jun 2017 07:45:40 -0400 Date: Tue, 20 Jun 2017 13:45:36 +0200 From: Corentin Labbe To: Maxime Ripard Cc: herbert@gondor.apana.org.au, davem@davemloft.net, wens@csie.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] crypto: sun4i-ss: support the Security System PRNG Message-ID: <20170620114536.GA4766@Red> References: <20170620085819.20114-1-clabbe.montjoie@gmail.com> <20170620095947.i3r3iym2cxz5jciw@flea.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170620095947.i3r3iym2cxz5jciw@flea.lan> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1485 Lines: 51 On Tue, Jun 20, 2017 at 11:59:47AM +0200, Maxime Ripard wrote: > Hi, > > On Tue, Jun 20, 2017 at 10:58:19AM +0200, Corentin Labbe wrote: > > The Security System have a PRNG, this patch add support for it via > > crypto_rng. > > This might be a dumb question, but is the CRYPTO_RNG code really > supposed to be used with PRNG? > Yes, see recently added drivers/crypto/exynos-rng.c [...] > > --- a/drivers/crypto/sunxi-ss/sun4i-ss.h > > +++ b/drivers/crypto/sunxi-ss/sun4i-ss.h > > @@ -32,6 +32,7 @@ > > #include > > #include > > #include > > +#include > > > > #define SS_CTL 0x00 > > #define SS_KEY0 0x04 > > @@ -127,6 +128,9 @@ > > #define SS_RXFIFO_EMP_INT_ENABLE (1 << 2) > > #define SS_TXFIFO_AVA_INT_ENABLE (1 << 0) > > > > +#define SS_SEED_LEN (192 / 8) > > +#define SS_DATA_LEN (160 / 8) > > + > > struct sun4i_ss_ctx { > > void __iomem *base; > > int irq; > > @@ -136,6 +140,7 @@ struct sun4i_ss_ctx { > > struct device *dev; > > struct resource *res; > > spinlock_t slock; /* control the use of the device */ > > + u32 seed[SS_SEED_LEN / 4]; > > Shouldn't you define SS_SEED_LEN in bits, and then use either > BITS_PER_BYTE and BITS_PER_LONG so that it's obvious what you're doing > ? > > And you could also make that variable defined based on the option, > otherwise you'll always allocate that array, even if you're not using > it. I will do that Thanks