From: Martin Kaiser <martin@kaiser.cx> To: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>, Shawn Guo <shawnguo@kernel.org>, Herbert Xu <herbert@gondor.apana.org.au>, Mark Rutland <mark.rutland@arm.com>, devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>, linux-crypto@vger.kernel.org, kernel@pengutronix.de, Fabio Estevam <festevam@gmail.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Date: Wed, 19 Jul 2017 23:22:53 +0200 [thread overview] Message-ID: <20170719212253.GA13879@botnar.kaiser.cx> (raw) In-Reply-To: <CANc+2y7icNR3hJS0wCFd_-90X6bXkJYMEO6m53HDG8SBM0FZ2g@mail.gmail.com> Hi PrasannaKumar, thanks for taking the time to review my submission. Thus wrote PrasannaKumar Muralidharan (prasannatsmkumar@gmail.com): > Please combine above 2 comments. ok, I'll do this. > > + > > +/* > > + * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) > > [...] > I feel this comment is because of copy paste. If that's the case please remove. A couple of files in drivers/char/hw_random have the same copyright statement. So it looks like copy&paste. I'll remove it. > > + > > + while (max > sizeof(u32)) { > Should the condition be max >= sizeof(u32)? You're right. I'll fix this. > > + status = __raw_readl(rngc->base + RNGC_STATUS); > Is there any specific reason for using __raw_readl? Why not just readl? > If there is no specific reason for using __raw_readl please use readl > in all the places. That looks like mxc-rnga.c was taken as a starting point. I'll change __raw_read() to readl and __raw_writel to writel. > > + /* how many random numbers are in FIFO? [0-16] */ > > + level = (status & RNGC_STATUS_FIFO_LEVEL_MASK) >> > > + RNGC_STATUS_FIFO_LEVEL_SHIFT; > > + > > + /* is there some error while reading this random number? */ > > + if (status & RNGC_STATUS_ERROR) > > + break; > Before calculating level error check can be done. Ok, I'll move the check right after reading the status register. > > + if (__raw_readl(rngc->base + RNGC_ERROR) & > > + RNGC_ERROR_STATUS_BAD_KEY) { > > + dev_err(rngc->dev, "Can't start, Bad Keys.\n"); > > + return -EIO; > > + } > > + } > What keys? What is the purpose of this check? At this point only clk > is enabled for RNGC so I am wondering why this check is required? The "key" is probably the internal state of the PRNG, which uses the mechanism described in FIPS 186-2. No idea why Freescale added this check before the self test. I guess that we can safely run the self test and check for errors afterwards. I'll remove the check. Interestingly, this "bad key" error status is one of the few differences between RNGB and RNGC, both of which should work with this driver... > > + > > + /* mask all interrupts, will be unmasked soon */ > > + ctrl = __raw_readl(rngc->base + RNGC_CONTROL); > > + __raw_writel(ctrl | RNGC_CTRL_MASK_DONE | RNGC_CTRL_MASK_ERROR, > > + rngc->base + RNGC_CONTROL); > > + > > + /* verify if oscillator is working */ > > + osc = __raw_readl(rngc->base + RNGC_ERROR); > > + if (osc & RNGC_ERROR_STATUS_OSC_ERR) { > > + dev_err(rngc->dev, "RNGC Oscillator is dead!\n"); > > + return -EIO; > > + } > Is this check useful? If clock is initialised properly I do not think > this case will happen. May be I am missing something. Please add a > comment if this check is valid. Agreed. Switching the clock on should be sufficient to get the oscillator to run. And if not, we should see an error after the self test. > RNG core can call init every time this rng device is selected as > current random number provider. Is self test required on every RNG > init? I'd say the self test should be run once when the driver is loaded. I'll try to move the self test to the probe function. > By default self test need not be run, a module parameter can be added > for enabling self test. Ok. > > + rngc->rng.name = pdev->name; > > + rngc->rng.init = mxc_rngc_init; > > + rngc->rng.read = mxc_rngc_read; > Assiging a quality would be great. That will help in deciding which > rng device to use if there are mulitple rng devices. I doubt that I have enough info to set the quality. I'll see what I can dig up. I'll try to upload v4 as soon as possible. Thanks, Martin
WARNING: multiple messages have this Message-ID (diff)
From: martin@kaiser.cx (Martin Kaiser) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Date: Wed, 19 Jul 2017 23:22:53 +0200 [thread overview] Message-ID: <20170719212253.GA13879@botnar.kaiser.cx> (raw) In-Reply-To: <CANc+2y7icNR3hJS0wCFd_-90X6bXkJYMEO6m53HDG8SBM0FZ2g@mail.gmail.com> Hi PrasannaKumar, thanks for taking the time to review my submission. Thus wrote PrasannaKumar Muralidharan (prasannatsmkumar at gmail.com): > Please combine above 2 comments. ok, I'll do this. > > + > > +/* > > + * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) > > [...] > I feel this comment is because of copy paste. If that's the case please remove. A couple of files in drivers/char/hw_random have the same copyright statement. So it looks like copy&paste. I'll remove it. > > + > > + while (max > sizeof(u32)) { > Should the condition be max >= sizeof(u32)? You're right. I'll fix this. > > + status = __raw_readl(rngc->base + RNGC_STATUS); > Is there any specific reason for using __raw_readl? Why not just readl? > If there is no specific reason for using __raw_readl please use readl > in all the places. That looks like mxc-rnga.c was taken as a starting point. I'll change __raw_read() to readl and __raw_writel to writel. > > + /* how many random numbers are in FIFO? [0-16] */ > > + level = (status & RNGC_STATUS_FIFO_LEVEL_MASK) >> > > + RNGC_STATUS_FIFO_LEVEL_SHIFT; > > + > > + /* is there some error while reading this random number? */ > > + if (status & RNGC_STATUS_ERROR) > > + break; > Before calculating level error check can be done. Ok, I'll move the check right after reading the status register. > > + if (__raw_readl(rngc->base + RNGC_ERROR) & > > + RNGC_ERROR_STATUS_BAD_KEY) { > > + dev_err(rngc->dev, "Can't start, Bad Keys.\n"); > > + return -EIO; > > + } > > + } > What keys? What is the purpose of this check? At this point only clk > is enabled for RNGC so I am wondering why this check is required? The "key" is probably the internal state of the PRNG, which uses the mechanism described in FIPS 186-2. No idea why Freescale added this check before the self test. I guess that we can safely run the self test and check for errors afterwards. I'll remove the check. Interestingly, this "bad key" error status is one of the few differences between RNGB and RNGC, both of which should work with this driver... > > + > > + /* mask all interrupts, will be unmasked soon */ > > + ctrl = __raw_readl(rngc->base + RNGC_CONTROL); > > + __raw_writel(ctrl | RNGC_CTRL_MASK_DONE | RNGC_CTRL_MASK_ERROR, > > + rngc->base + RNGC_CONTROL); > > + > > + /* verify if oscillator is working */ > > + osc = __raw_readl(rngc->base + RNGC_ERROR); > > + if (osc & RNGC_ERROR_STATUS_OSC_ERR) { > > + dev_err(rngc->dev, "RNGC Oscillator is dead!\n"); > > + return -EIO; > > + } > Is this check useful? If clock is initialised properly I do not think > this case will happen. May be I am missing something. Please add a > comment if this check is valid. Agreed. Switching the clock on should be sufficient to get the oscillator to run. And if not, we should see an error after the self test. > RNG core can call init every time this rng device is selected as > current random number provider. Is self test required on every RNG > init? I'd say the self test should be run once when the driver is loaded. I'll try to move the self test to the probe function. > By default self test need not be run, a module parameter can be added > for enabling self test. Ok. > > + rngc->rng.name = pdev->name; > > + rngc->rng.init = mxc_rngc_init; > > + rngc->rng.read = mxc_rngc_read; > Assiging a quality would be great. That will help in deciding which > rng device to use if there are mulitple rng devices. I doubt that I have enough info to set the quality. I'll see what I can dig up. I'll try to upload v4 as soon as possible. Thanks, Martin
next prev parent reply other threads:[~2017-07-19 21:22 UTC|newest] Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-03-11 14:06 [PATCH v2 1/3] Documentation: devicetree: add Freescale RNGC binding Steffen Trumtrar 2016-03-11 14:06 ` Steffen Trumtrar 2016-03-11 14:06 ` [PATCH v2 2/3] ARM: i.MX25: add RNGC node to dtsi Steffen Trumtrar 2016-03-11 14:06 ` Steffen Trumtrar [not found] ` <1457705200-16951-2-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2016-04-01 8:52 ` Shawn Guo 2016-04-01 8:52 ` Shawn Guo 2017-07-17 21:05 ` Martin Kaiser 2017-07-17 21:05 ` Martin Kaiser 2016-03-11 14:06 ` [PATCH v2 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Steffen Trumtrar 2016-03-11 14:06 ` Steffen Trumtrar 2016-03-11 15:44 ` Vladimir Zapolskiy 2016-03-11 15:44 ` Vladimir Zapolskiy 2016-03-11 15:44 ` Vladimir Zapolskiy 2017-07-17 21:01 ` Martin Kaiser 2017-07-17 21:01 ` Martin Kaiser 2016-03-18 19:42 ` [PATCH v2 1/3] Documentation: devicetree: add Freescale RNGC binding Rob Herring 2016-03-18 19:42 ` Rob Herring 2017-07-17 21:04 ` Martin Kaiser 2017-07-17 21:04 ` Martin Kaiser [not found] ` <1457705200-16951-1-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2017-07-17 21:16 ` [PATCH v3 " Martin Kaiser 2017-07-17 21:16 ` Martin Kaiser 2017-07-17 21:16 ` Martin Kaiser 2017-07-17 21:16 ` [PATCH v3 2/3] ARM: i.MX25: add RNGC node to dtsi Martin Kaiser 2017-07-17 21:16 ` Martin Kaiser [not found] ` <1500326163-4556-1-git-send-email-martin-XxZfDwE/svGeZLLa646FqQ@public.gmane.org> 2017-07-17 21:16 ` [PATCH 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Martin Kaiser 2017-07-17 21:16 ` Martin Kaiser 2017-07-17 21:16 ` Martin Kaiser 2017-07-18 5:49 ` PrasannaKumar Muralidharan 2017-07-18 5:49 ` PrasannaKumar Muralidharan 2017-07-19 21:22 ` Martin Kaiser [this message] 2017-07-19 21:22 ` Martin Kaiser 2017-07-20 20:27 ` [PATCH v5 1/3] Documentation: devicetree: add Freescale RNGC binding Martin Kaiser 2017-07-20 20:27 ` Martin Kaiser 2017-07-20 20:27 ` Martin Kaiser 2017-07-20 20:27 ` [PATCH v5 2/3] ARM: i.MX25: add RNGC node to dtsi Martin Kaiser 2017-07-20 20:27 ` Martin Kaiser 2017-07-20 20:27 ` [PATCH v5 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Martin Kaiser 2017-07-20 20:27 ` Martin Kaiser 2017-07-20 21:34 ` [PATCH v5 1/3] Documentation: devicetree: add Freescale RNGC binding Rob Herring 2017-07-20 21:34 ` Rob Herring 2017-07-20 21:34 ` Rob Herring 2017-07-20 10:27 ` [PATCH v4 " Martin Kaiser 2017-07-20 10:27 ` Martin Kaiser 2017-07-20 10:27 ` [PATCH v4 2/3] ARM: i.MX25: add RNGC node to dtsi Martin Kaiser 2017-07-20 10:27 ` Martin Kaiser 2017-07-20 10:27 ` [PATCH v4 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Martin Kaiser 2017-07-20 10:27 ` Martin Kaiser [not found] ` <1500546435-29905-3-git-send-email-martin-XxZfDwE/svGeZLLa646FqQ@public.gmane.org> 2017-07-20 13:10 ` PrasannaKumar Muralidharan 2017-07-20 13:10 ` PrasannaKumar Muralidharan 2017-07-20 13:10 ` PrasannaKumar Muralidharan 2017-07-23 17:49 ` [PATCH v6 1/3] Documentation: devicetree: add Freescale RNGC binding Martin Kaiser 2017-07-23 17:49 ` Martin Kaiser 2017-07-23 17:49 ` [PATCH v6 2/3] ARM: i.MX25: add RNGB node to dtsi Martin Kaiser 2017-07-23 17:49 ` Martin Kaiser 2017-08-05 1:23 ` Shawn Guo 2017-08-05 1:23 ` Shawn Guo 2017-07-23 17:49 ` [PATCH v6 3/3] hwrng: add a driver for Freescale RNGC Martin Kaiser 2017-07-23 17:49 ` Martin Kaiser 2017-08-03 6:26 ` Herbert Xu 2017-08-03 6:26 ` Herbert Xu [not found] ` <1500832146-8660-1-git-send-email-martin-XxZfDwE/svGeZLLa646FqQ@public.gmane.org> 2017-07-26 22:55 ` [PATCH v6 1/3] Documentation: devicetree: add Freescale RNGC binding Rob Herring 2017-07-26 22:55 ` Rob Herring 2017-07-26 22:55 ` Rob Herring 2017-08-03 6:25 ` Herbert Xu 2017-08-03 6:25 ` Herbert Xu 2017-08-03 6:25 ` Herbert Xu -- strict thread matches above, loose matches on Subject: below -- 2016-02-29 15:52 [PATCH " Steffen Trumtrar 2016-02-29 15:52 ` [PATCH 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Steffen Trumtrar 2016-02-29 15:52 ` Steffen Trumtrar 2016-02-29 21:16 ` Fabio Estevam 2016-02-29 21:16 ` Fabio Estevam 2016-02-29 21:38 ` Uwe Kleine-König 2016-02-29 21:38 ` Uwe Kleine-König [not found] ` <20160229213850.GS2613-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2016-02-29 23:54 ` Fabio Estevam 2016-02-29 23:54 ` Fabio Estevam 2016-03-01 7:49 ` Uwe Kleine-König 2016-03-01 7:49 ` Uwe Kleine-König 2016-03-07 13:03 ` Steffen Trumtrar 2016-03-07 13:03 ` Steffen Trumtrar
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170719212253.GA13879@botnar.kaiser.cx \ --to=martin@kaiser.cx \ --cc=devicetree@vger.kernel.org \ --cc=festevam@gmail.com \ --cc=herbert@gondor.apana.org.au \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-crypto@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=prasannatsmkumar@gmail.com \ --cc=robh+dt@kernel.org \ --cc=s.trumtrar@pengutronix.de \ --cc=shawnguo@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.