From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Peter Korsgaard <jacmet@sunsite.dk>
Cc: <herbert@gondor.apana.org.au>, <jamie@jamieiles.com>,
<linux-kernel@vger.kernel.org>, <GPontis@z9.com>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] hw_random: atmel-rng: fix race condition leading to repeated bits
Date: Sun, 27 May 2012 13:49:57 +0200 [thread overview]
Message-ID: <4FC214E5.1010007@atmel.com> (raw)
In-Reply-To: <877gw0a7vc.fsf@macbook.be.48ers.dk>
On 05/25/2012 12:10 PM, Peter Korsgaard :
>>>>>> "Nicolas" == Nicolas Ferre <nicolas.ferre@atmel.com> writes:
>
> Hi,
>
> Nicolas> What about a single read to ISR like this:
>
> Nicolas> tmp = readl(trng->base + TRNG_ODATA);
> Nicolas> if (readl(trng->base + TRNG_ISR) & 1) {
> Nicolas> *data = tmp;
> Nicolas> return 4;
> Nicolas> } else {
> Nicolas> return 0;
> Nicolas> }
>
> No, that won't work as you then have another race. Data might not be
> ready when you read ODATA, but then become ready just in time for when
> you read ISR, so you end up using stale data.
Yes, sure.
> It all would have been easier if the ready bit would get cleared on
> reads from ODATA instead of/as well as from ISR, but that's
> unfortunately not the case.
I will talk about that idea to my friends designers and see if we can
improve things, in the future...
Thanks, bye,
--
Nicolas Ferre
next prev parent reply other threads:[~2012-05-27 11:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-25 9:12 [PATCH] hw_random: atmel-rng: fix race condition leading to repeated bits Peter Korsgaard
2012-05-25 10:04 ` Nicolas Ferre
2012-05-25 10:10 ` Peter Korsgaard
2012-05-27 11:49 ` Nicolas Ferre [this message]
2012-05-27 11:51 ` Nicolas Ferre
2012-05-31 10: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=4FC214E5.1010007@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=GPontis@z9.com \
--cc=herbert@gondor.apana.org.au \
--cc=jacmet@sunsite.dk \
--cc=jamie@jamieiles.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.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: 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).