From: Tomer Maimon <tmaimon77@gmail.com> To: mpm@selenic.com, herbert@gondor.apana.org.au, arnd@arndb.de, gregkh@linuxfoundation.org, avifishman70@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, joel@jms.id.au Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, tmaimon77@gmail.com Subject: [PATCH v1] hw_random: npcm: modify readl to readb Date: Thu, 24 Sep 2020 00:23:05 +0300 [thread overview] Message-ID: <20200923212305.198485-1-tmaimon77@gmail.com> (raw) Modify the read size to the correct HW random registers size, 8bit. The incorrect read size caused and faulty HW random value. Signed-off-by: Tomer Maimon <tmaimon77@gmail.com> --- drivers/char/hw_random/npcm-rng.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c index 5d0d13f891b7..1ec5f267a656 100644 --- a/drivers/char/hw_random/npcm-rng.c +++ b/drivers/char/hw_random/npcm-rng.c @@ -58,24 +58,24 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) pm_runtime_get_sync((struct device *)priv->rng.priv); - while (max >= sizeof(u32)) { + while (max) { if (wait) { - if (readl_poll_timeout(priv->base + NPCM_RNGCS_REG, + if (readb_poll_timeout(priv->base + NPCM_RNGCS_REG, ready, ready & NPCM_RNG_DATA_VALID, NPCM_RNG_POLL_USEC, NPCM_RNG_TIMEOUT_USEC)) break; } else { - if ((readl(priv->base + NPCM_RNGCS_REG) & + if ((readb(priv->base + NPCM_RNGCS_REG) & NPCM_RNG_DATA_VALID) == 0) break; } - *(u32 *)buf = readl(priv->base + NPCM_RNGD_REG); - retval += sizeof(u32); - buf += sizeof(u32); - max -= sizeof(u32); + *(u8 *)buf = readb(priv->base + NPCM_RNGD_REG); + retval++; + buf++; + max--; } pm_runtime_mark_last_busy((struct device *)priv->rng.priv); -- 2.22.0
WARNING: multiple messages have this Message-ID (diff)
From: Tomer Maimon <tmaimon77@gmail.com> To: mpm@selenic.com, herbert@gondor.apana.org.au, arnd@arndb.de, gregkh@linuxfoundation.org, avifishman70@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, joel@jms.id.au Cc: openbmc@lists.ozlabs.org, tmaimon77@gmail.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] hw_random: npcm: modify readl to readb Date: Thu, 24 Sep 2020 00:23:05 +0300 [thread overview] Message-ID: <20200923212305.198485-1-tmaimon77@gmail.com> (raw) Modify the read size to the correct HW random registers size, 8bit. The incorrect read size caused and faulty HW random value. Signed-off-by: Tomer Maimon <tmaimon77@gmail.com> --- drivers/char/hw_random/npcm-rng.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c index 5d0d13f891b7..1ec5f267a656 100644 --- a/drivers/char/hw_random/npcm-rng.c +++ b/drivers/char/hw_random/npcm-rng.c @@ -58,24 +58,24 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) pm_runtime_get_sync((struct device *)priv->rng.priv); - while (max >= sizeof(u32)) { + while (max) { if (wait) { - if (readl_poll_timeout(priv->base + NPCM_RNGCS_REG, + if (readb_poll_timeout(priv->base + NPCM_RNGCS_REG, ready, ready & NPCM_RNG_DATA_VALID, NPCM_RNG_POLL_USEC, NPCM_RNG_TIMEOUT_USEC)) break; } else { - if ((readl(priv->base + NPCM_RNGCS_REG) & + if ((readb(priv->base + NPCM_RNGCS_REG) & NPCM_RNG_DATA_VALID) == 0) break; } - *(u32 *)buf = readl(priv->base + NPCM_RNGD_REG); - retval += sizeof(u32); - buf += sizeof(u32); - max -= sizeof(u32); + *(u8 *)buf = readb(priv->base + NPCM_RNGD_REG); + retval++; + buf++; + max--; } pm_runtime_mark_last_busy((struct device *)priv->rng.priv); -- 2.22.0
next reply other threads:[~2020-09-23 22:08 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-23 21:23 Tomer Maimon [this message] 2020-09-23 21:23 ` [PATCH v1] hw_random: npcm: modify readl to readb Tomer Maimon 2020-10-02 11:54 ` Herbert Xu 2020-10-02 11:54 ` 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=20200923212305.198485-1-tmaimon77@gmail.com \ --to=tmaimon77@gmail.com \ --cc=arnd@arndb.de \ --cc=avifishman70@gmail.com \ --cc=benjaminfair@google.com \ --cc=gregkh@linuxfoundation.org \ --cc=herbert@gondor.apana.org.au \ --cc=joel@jms.id.au \ --cc=linux-crypto@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mpm@selenic.com \ --cc=openbmc@lists.ozlabs.org \ --cc=tali.perry1@gmail.com \ --cc=venture@google.com \ --cc=yuenn@google.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.