[PATCH v2 2/3] hwrng: starfive - Add TRNG driver for StarFive SoC

JiaJie Ho jiajie.ho at starfivetech.com
Sun Jan 8 18:58:14 PST 2023



> -----Original Message-----
> From: Herbert Xu <herbert at gondor.apana.org.au>
> Sent: 6 January, 2023 4:39 PM
> To: JiaJie Ho <jiajie.ho at starfivetech.com>
> Cc: Olivia Mackall <olivia at selenic.com>; Rob Herring <robh+dt at kernel.org>;
> Krzysztof Kozlowski <krzysztof.kozlowski+dt at linaro.org>; Emil Renner
> Berthing <kernel at esmil.dk>; Conor Dooley <conor.dooley at microchip.com>;
> linux-crypto at vger.kernel.org; devicetree at vger.kernel.org; linux-
> kernel at vger.kernel.org; linux-riscv at lists.infradead.org
> Subject: Re: [PATCH v2 2/3] hwrng: starfive - Add TRNG driver for StarFive
> SoC
> 
> On Wed, Dec 28, 2022 at 03:11:02PM +0800, Jia Jie Ho wrote:
> > +static int starfive_trng_read(struct hwrng *rng, void *buf, size_t
> > +max, bool wait)
> 
> You should respect the wait argument and not do polling/sleeping if it is false.
> 

Hi Herbert, 

My trng device requires sending a generate new number cmd before each read.
It then only populates the data registers with new random number and raise an interrupt when ready.
If user choose to not wait, they will always get stale bits. 
Is it okay to always return error if wait=false ?

Thanks
Jia Jie



More information about the linux-riscv mailing list