From: Martin Kaiser <martin@kaiser.cx> To: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> Cc: Mark Rutland <mark.rutland@arm.com>, devicetree@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>, Pawel Moll <pawel.moll@arm.com>, Ian Campbell <ijc+devicetree@hellion.org.uk>, martin@kaiser.cx, Kumar Gala <galak@codeaurora.org>, Rob Herring <robh+dt@kernel.org>, linux-crypto@vger.kernel.org, kernel@pengutronix.de, Matt Mackall <mpm@selenic.com>, Steffen Trumtrar <s.trumtrar@pengutronix.de>, Shawn Guo <shawnguo@kernel.org>, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Date: Mon, 17 Jul 2017 23:01:44 +0200 [thread overview] Message-ID: <20170717210144.GA15429@reykholt.kaiser.cx> (raw) In-Reply-To: <56E2E7F1.6020501@mentor.com> Dear all, looking for a Freescale RNGB/C driver, I came across this old mail thread. It seems the review got stuck and the driver was never merged. This mail is the latest conversation I could find. I would like to pick up this work and prepare the RNGC driver for merging into the mailine kernel. Thus wrote Vladimir Zapolskiy (vladimir_zapolskiy@mentor.com): > > +#define RNGC_VERID_VERSION_MAJOR_MASK 0x0000ff00 > > +#define RNGC_VERID_VERSION_MAJOR_SHIFT 8 > > +#define RNGC_VERID_VERSION_MINOR_MASK 0x000000ff > > +#define RNGC_VERID_VERSION_MINOR_SHIFT 0 > All RNGC_VERID_* are not used. And actually quite many other > defined values are not used, e.g. all *_ZEROS_MASK etc. I removed unused defines. > > + struct mxc_rngc *rngc = (struct mxc_rngc *)priv; > > + int handled = IRQ_NONE; > > + > > + /* is the seed creation done? */ > > + if (__raw_readl(rngc->base + RNGC_STATUS) & RNGC_STATUS_SEED_DONE) { > > + complete(&rngc->rng_seed_done); > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > > + handled = IRQ_HANDLED; > > + } > > + > > + /* is the self test done? */ > > + if (__raw_readl(rngc->base + RNGC_STATUS) & RNGC_STATUS_ST_DONE) { > > + complete(&rngc->rng_self_testing); > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > > + handled = IRQ_HANDLED; > > + } > > + > > + /* is there any error? */ > > + if (__raw_readl(rngc->base + RNGC_STATUS) & RNGC_STATUS_ERROR) { > > + /* clear interrupt */ > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > > + handled = IRQ_HANDLED; > For the code errors seem to be harmless, is it so? Does it make > sense to inform a user about errors? Either one of the completions is triggered or we time out when we wait on a wait queue, see below. In any case, we read the error register and abort the operation if there's an error. > > + wait_for_completion(&rngc->rng_self_testing); > I would suggest to use wait_for_completion_timeout(). I fixed this. > > + > > + } while (__raw_readl(rngc->base + RNGC_ERROR) & > > + RNGC_ERROR_STATUS_ST_ERR); > Logic of running a self test until error condition is gone looks strange. Agreed. I don't see why the self test should fail in the first run and complete successfully when we retry without a reset. I changed the code to run the self test only once. > > + > > + /* clear interrupt. Is it really necessary here? */ > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > Answering the question above I believe it is not needed here. True. The irq handler clears the error status and interrupt bits. > > + wait_for_completion(&rngc->rng_seed_done); > I would suggest to use wait_for_completion_timeout(). Done. > > + > > + } while (__raw_readl(rngc->base + RNGC_ERROR) & > > + RNGC_ERROR_STATUS_STAT_ERR); > Any chance to loop forever? I exit the loop now for all errors except the "statistical error". This + the timeout on the wait queue should prevent us from looping forever. > > + if (ret) { > > + dev_err(rngc->dev, "Can't get interrupt working.\n"); > > + return -EIO; > Leaked enabled rngc->clk clock on error path. I restructured the probe function such that the clock is disabled when there's an error after it was enabled. Best regards, Martin
WARNING: multiple messages have this Message-ID (diff)
From: martin@kaiser.cx (Martin Kaiser) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/3] hwrng: mxc-fsl - add support for Freescale RNGC Date: Mon, 17 Jul 2017 23:01:44 +0200 [thread overview] Message-ID: <20170717210144.GA15429@reykholt.kaiser.cx> (raw) In-Reply-To: <56E2E7F1.6020501@mentor.com> Dear all, looking for a Freescale RNGB/C driver, I came across this old mail thread. It seems the review got stuck and the driver was never merged. This mail is the latest conversation I could find. I would like to pick up this work and prepare the RNGC driver for merging into the mailine kernel. Thus wrote Vladimir Zapolskiy (vladimir_zapolskiy at mentor.com): > > +#define RNGC_VERID_VERSION_MAJOR_MASK 0x0000ff00 > > +#define RNGC_VERID_VERSION_MAJOR_SHIFT 8 > > +#define RNGC_VERID_VERSION_MINOR_MASK 0x000000ff > > +#define RNGC_VERID_VERSION_MINOR_SHIFT 0 > All RNGC_VERID_* are not used. And actually quite many other > defined values are not used, e.g. all *_ZEROS_MASK etc. I removed unused defines. > > + struct mxc_rngc *rngc = (struct mxc_rngc *)priv; > > + int handled = IRQ_NONE; > > + > > + /* is the seed creation done? */ > > + if (__raw_readl(rngc->base + RNGC_STATUS) & RNGC_STATUS_SEED_DONE) { > > + complete(&rngc->rng_seed_done); > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > > + handled = IRQ_HANDLED; > > + } > > + > > + /* is the self test done? */ > > + if (__raw_readl(rngc->base + RNGC_STATUS) & RNGC_STATUS_ST_DONE) { > > + complete(&rngc->rng_self_testing); > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > > + handled = IRQ_HANDLED; > > + } > > + > > + /* is there any error? */ > > + if (__raw_readl(rngc->base + RNGC_STATUS) & RNGC_STATUS_ERROR) { > > + /* clear interrupt */ > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > > + handled = IRQ_HANDLED; > For the code errors seem to be harmless, is it so? Does it make > sense to inform a user about errors? Either one of the completions is triggered or we time out when we wait on a wait queue, see below. In any case, we read the error register and abort the operation if there's an error. > > + wait_for_completion(&rngc->rng_self_testing); > I would suggest to use wait_for_completion_timeout(). I fixed this. > > + > > + } while (__raw_readl(rngc->base + RNGC_ERROR) & > > + RNGC_ERROR_STATUS_ST_ERR); > Logic of running a self test until error condition is gone looks strange. Agreed. I don't see why the self test should fail in the first run and complete successfully when we retry without a reset. I changed the code to run the self test only once. > > + > > + /* clear interrupt. Is it really necessary here? */ > > + __raw_writel(RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR, > > + rngc->base + RNGC_COMMAND); > Answering the question above I believe it is not needed here. True. The irq handler clears the error status and interrupt bits. > > + wait_for_completion(&rngc->rng_seed_done); > I would suggest to use wait_for_completion_timeout(). Done. > > + > > + } while (__raw_readl(rngc->base + RNGC_ERROR) & > > + RNGC_ERROR_STATUS_STAT_ERR); > Any chance to loop forever? I exit the loop now for all errors except the "statistical error". This + the timeout on the wait queue should prevent us from looping forever. > > + if (ret) { > > + dev_err(rngc->dev, "Can't get interrupt working.\n"); > > + return -EIO; > Leaked enabled rngc->clk clock on error path. I restructured the probe function such that the clock is disabled when there's an error after it was enabled. Best regards, Martin
next prev parent reply other threads:[~2017-07-17 21:01 UTC|newest] Thread overview: 66+ 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 [this message] 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 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
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=20170717210144.GA15429@reykholt.kaiser.cx \ --to=martin@kaiser.cx \ --cc=devicetree@vger.kernel.org \ --cc=galak@codeaurora.org \ --cc=herbert@gondor.apana.org.au \ --cc=ijc+devicetree@hellion.org.uk \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-crypto@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=mpm@selenic.com \ --cc=pawel.moll@arm.com \ --cc=robh+dt@kernel.org \ --cc=s.trumtrar@pengutronix.de \ --cc=shawnguo@kernel.org \ --cc=vladimir_zapolskiy@mentor.com \ /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.