linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bharat Bhushan <bbhushan2@marvell.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "olivia@selenic.com" <olivia@selenic.com>,
	"Jason@zx2c4.com" <Jason@zx2c4.com>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Sunil Kovvuri Goutham <sgoutham@marvell.com>
Subject: RE: [EXT] Re: [PATCH] hwrng: cn10k: Add extended trng register support
Date: Wed, 24 May 2023 11:56:16 +0000	[thread overview]
Message-ID: <DM5PR1801MB188333F8A818A5F887AC5440E3419@DM5PR1801MB1883.namprd18.prod.outlook.com> (raw)
In-Reply-To: <ZG3fNmNfUHeWIsNZ@gondor.apana.org.au>



> -----Original Message-----
> From: Herbert Xu <herbert@gondor.apana.org.au>
> Sent: Wednesday, May 24, 2023 3:26 PM
> To: Bharat Bhushan <bbhushan2@marvell.com>
> Cc: olivia@selenic.com; Jason@zx2c4.com; linux-crypto@vger.kernel.org; linux-
> kernel@vger.kernel.org; Sunil Kovvuri Goutham <sgoutham@marvell.com>
> Subject: [EXT] Re: [PATCH] hwrng: cn10k: Add extended trng register support
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Thu, May 18, 2023 at 12:17:34PM +0530, Bharat Bhushan wrote:
> >
> > -static void cn10k_read_trng(struct cn10k_rng *rng, u64 *value)
> > +static size_t cn10k_read_trng(struct cn10k_rng *rng, u64 *value)
> 
> Since the return value is either 0 or 8, why did you pick size_t as the return value?

This function returns number of valid bytes available in "value". 0 means no valid data. size_t is definitely wrong.
I think I will make this function to return bool, true when data is valid and false when data is not valid.

Thanks
-Bharat

> 
> >  {
> > +	u16 retry_count = 0;
> >  	u64 upper, lower;
> > +	u64 status;
> > +
> > +	if (rng->extended_trng_regs) {
> > +		do {
> > +			*value = readq(rng->reg_base + RNM_PF_TRNG_DAT);
> > +			if (*value)
> > +				return 8;
> > +			status = readq(rng->reg_base + RNM_PF_TRNG_RES);
> > +			if (!status && (retry_count++ > 0x1000))
> > +				return 0;
> > +		} while (!status);
> > +	}
> >
> >  	*value = readq(rng->reg_base + RNM_PF_RANDOM);
> >
> > @@ -82,6 +130,7 @@ static void cn10k_read_trng(struct cn10k_rng *rng,
> > u64 *value)
> >
> >  		*value = (upper & 0xFFFFFFFF00000000) | (lower & 0xFFFFFFFF);
> >  	}
> > +	return 8;
> >  }
> >
> >  static int cn10k_rng_read(struct hwrng *hwrng, void *data, @@ -100,7
> > +149,9 @@ static int cn10k_rng_read(struct hwrng *hwrng, void *data,
> >  	size = max;
> >
> >  	while (size >= 8) {
> > -		cn10k_read_trng(rng, &value);
> > +		err = cn10k_read_trng(rng, &value);
> > +		if (!err)
> > +			goto out;
> 
> It appears that err is either 8 or 0, so it's not really an error.
> Could you plesae use a more meaningful name for this variable?
> 
> Cheers,
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__gondor.apana.org.au_-
> 7Eherbert_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=PAAlWswPe7d8gHlGb
> CLmy2YezyK7O3Hv_t2heGnouBw&m=Ya8SJ6OhypttG2itpa39dd7kXwEXGgbUOJ2
> Hqi95w7MetfxqRKKFX7aluHaLZpoc&s=pnRAp3oSzsNrbEAHZdLM6Eb9M4tDMxEd
> WLzANKejHwU&e=
> PGP Key: https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__gondor.apana.org.au_-
> 7Eherbert_pubkey.txt&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=PAAlWswP
> e7d8gHlGbCLmy2YezyK7O3Hv_t2heGnouBw&m=Ya8SJ6OhypttG2itpa39dd7kXwE
> XGgbUOJ2Hqi95w7MetfxqRKKFX7aluHaLZpoc&s=pLpT-
> xdKvVvCI4sp5r8r5qYoKeEx537Gnlkq1dpTrYY&e=

      reply	other threads:[~2023-05-24 11:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18  6:47 [PATCH] hwrng: cn10k: Add extended trng register support Bharat Bhushan
2023-05-24  9:56 ` Herbert Xu
2023-05-24 11:56   ` Bharat Bhushan [this message]

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=DM5PR1801MB188333F8A818A5F887AC5440E3419@DM5PR1801MB1883.namprd18.prod.outlook.com \
    --to=bbhushan2@marvell.com \
    --cc=Jason@zx2c4.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olivia@selenic.com \
    --cc=sgoutham@marvell.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).