[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <877gw0a7vc.fsf@macbook.be.48ers.dk>
Date: Fri, 25 May 2012 12:10:47 +0200
From: Peter Korsgaard <jacmet@...site.dk>
To: Nicolas Ferre <nicolas.ferre@...el.com>
Cc: <herbert@...dor.apana.org.au>, <jamie@...ieiles.com>,
<linux-kernel@...r.kernel.org>, <GPontis@...com>,
<stable@...r.kernel.org>
Subject: Re: [PATCH] hw_random: atmel-rng: fix race condition leading to repeated bits
>>>>> "Nicolas" == Nicolas Ferre <nicolas.ferre@...el.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.
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.
--
Bye, Peter Korsgaard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists