Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6235549ybv; Wed, 12 Feb 2020 08:25:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxALbFEgiZjqbq6smMkHNAaIRZ38xDxvGO22augpij//LNGLz3xyro+NTEDpWDByZmvMiCZ X-Received: by 2002:a05:6830:22cc:: with SMTP id q12mr10262986otc.110.1581524717216; Wed, 12 Feb 2020 08:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581524717; cv=none; d=google.com; s=arc-20160816; b=O5sgks+mnZi2qxiyZdLMyR3u/baYwW0nD1O7DqdBIfNWlo1prXpJVqDpFZsyPHl1DQ 98QtRl63M0qlGqoTF7vwkfEGBLlfgiEn5GdziobF4XBzJ8U8KDGXEBSNK4gCE0/BOayc pH5VGcZEFvLJdx2Vag0eOGXeWUb/nef1b6/7kO1wSlCAFksTjzc+1E6Kj//6nPO9ABfV FdNfG/Qx6u06NStYQ+pK5/W10uunDyEBL4eWpJopSacfaKYJ2Agbi150GK97qOELzEVg zMTu9VVHFCOSgmyPbFpW/hEoEBJ7hx2Wgtk3EgcHS03QTithc5OKmgoP4o6XoxLZM7G3 PvDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zweDaFEU0USsV+JX/LUuDeDmSUEHYWtL+9GANBjwgS4=; b=NfmDu4pLzKuE07Issv4q6uPrLsQGu7L61U2y5Z15zcfrrsbwveUw/sZtdWpxh9Otpg RcyY4j2C0K5O1agFc351HMd2UBmBtyZlwt1AJYuZrtcdqjOjdvQN6KTwDt/XTGkJx8H+ Ol7YPFsJXLF23iMpYmH3JSiMbvUqWBL7Yxi4zKT2zVS8XTdUrP6lLkaEzbDbf9Vfj3C7 lsIXsY5w79GnL9UeUEc41AcifjCl+MSf41dOR6bEDcluiyQocwaERFLTaguAhVkaj997 4an2txJyRzMXZT2LA2L56i760C/qbewVXNFzDacEwLYcQVsDq6cO1OoEo+NfUanVElAA K+jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cP7Dc2Vt; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i78si3680052oib.1.2020.02.12.08.25.04; Wed, 12 Feb 2020 08:25:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cP7Dc2Vt; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727548AbgBLQZD (ORCPT + 99 others); Wed, 12 Feb 2020 11:25:03 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37238 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726728AbgBLQZC (ORCPT ); Wed, 12 Feb 2020 11:25:02 -0500 Received: by mail-pg1-f194.google.com with SMTP id z12so1479072pgl.4; Wed, 12 Feb 2020 08:25:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zweDaFEU0USsV+JX/LUuDeDmSUEHYWtL+9GANBjwgS4=; b=cP7Dc2VtOxGDgxZ6JHdE2q9Lyhmqv0k2cCO7w6iMWAwBuUc4X1hTFNxnXVCptDXT5x NkTwJ4HwJDTYlXQ/5Q7HYPa3LjvpoW91An4WuKSfHiHl1cCp/idPPX1hDnIWFfwgILph QW9+RaPIhjuK1G7zJ38FF3O6vqRsLjyTFD1u6DPY3hwHwnUAu83W+GE02P7wMvEy32l3 eXIX+9iUpxb5H7wLek1JA/nyj2rTQruJVFD7L9dgv3URdIlaLvOkvra0G4uAdd98IqUt FLJTU0BiinQI0yNZwHtYRV5wtxUSO5kAqzg2SG6UUvGIfNaKdm2lxG4iEEO/0uByivN6 2ENg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zweDaFEU0USsV+JX/LUuDeDmSUEHYWtL+9GANBjwgS4=; b=IVjO0a134bw4yJMmWAJVond4xkwVesau28rgyMA5uNt9aiRwgd5B1wBNO8w3YTcB/f UF/DwqdTuutW/dd/TWsz+Lo0gVDjDDyVCwKUzzWibX6tFnAWYjQSTMNaXueFCRonNJuO ynrakaJe8thJuOYQ8EmJc7seFIDYo/PWmSQrHvXJSsmS9Pl8g9+SmUm4REC9nKYHHrBf mJxL2Lf++Lc0JOySCvLhXZtSc0nuQr2Gn5tcMDNbFBmStRbxiUyja+BL4Nlq2wMnTDAB n+Zn9RXW03gtrws7hCYfN2VQG2jYhQxaXdjju+jLaiUv66Vt3Rlo/Wt9bSYFLudjQa/m JAlQ== X-Gm-Message-State: APjAAAUIk15enj7dsG5CJ7HXmnpjy2W4ZQZbDis2LC/I6kOQ3W+E3MlR BY8c+f70PCE+yGkT+dqrNmxiPdNO9j6DGfAqrsw= X-Received: by 2002:a63:306:: with SMTP id 6mr9363242pgd.337.1581524702320; Wed, 12 Feb 2020 08:25:02 -0800 (PST) MIME-Version: 1.0 References: <20200128110102.11522-1-martin@kaiser.cx> <20200128110102.11522-3-martin@kaiser.cx> In-Reply-To: <20200128110102.11522-3-martin@kaiser.cx> From: PrasannaKumar Muralidharan Date: Wed, 12 Feb 2020 21:54:51 +0530 Message-ID: Subject: Re: [PATCH 2/6] hwrng: imx-rngc - use automatic seeding To: Martin Kaiser Cc: Herbert Xu , NXP Linux Team , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , linux-arm-kernel@lists.infradead.org, open list Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, 28 Jan 2020 at 16:31, Martin Kaiser wrote: > > The rngc requires a new seed for its prng after generating 2^20 160-bit > words of random data. At the moment, we seed the prng only once during > initalisation. > > Set the rngc to auto seed mode so that it kicks off the internal > reseeding operation when a new seed is required. > > Keep the manual calculation of the initial seed when the device is > probed and switch to automatic seeding afterwards. > > Signed-off-by: Martin Kaiser > --- > drivers/char/hw_random/imx-rngc.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c > index 0576801944fd..903894518c8d 100644 > --- a/drivers/char/hw_random/imx-rngc.c > +++ b/drivers/char/hw_random/imx-rngc.c > @@ -31,6 +31,7 @@ > > #define RNGC_CTRL_MASK_ERROR 0x00000040 > #define RNGC_CTRL_MASK_DONE 0x00000020 > +#define RNGC_CTRL_AUTO_SEED 0x00000010 > > #define RNGC_STATUS_ERROR 0x00010000 > #define RNGC_STATUS_FIFO_LEVEL_MASK 0x00000f00 > @@ -167,7 +168,7 @@ static irqreturn_t imx_rngc_irq(int irq, void *priv) > static int imx_rngc_init(struct hwrng *rng) > { > struct imx_rngc *rngc = container_of(rng, struct imx_rngc, rng); > - u32 cmd; > + u32 cmd, ctrl; > int ret; > > /* clear error */ > @@ -192,7 +193,18 @@ static int imx_rngc_init(struct hwrng *rng) > > } while (rngc->err_reg == RNGC_ERROR_STATUS_STAT_ERR); > > - return rngc->err_reg ? -EIO : 0; > + if (rngc->err_reg) > + return -EIO; > + > + /* > + * enable automatic seeding, the rngc creates a new seed automatically > + * after serving 2^20 random 160-bit words > + */ > + ctrl = readl(rngc->base + RNGC_CONTROL); > + ctrl |= RNGC_CTRL_AUTO_SEED; > + writel(ctrl, rngc->base + RNGC_CONTROL); > + > + return 0; > } > > static int imx_rngc_probe(struct platform_device *pdev) > -- > 2.20.1 > Reviewed-by: PrasannaKumar Muralidharan