lkml.org 
[lkml]   [2012]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] hw_random: atmel-rng: fix race condition leading to repeated bits
Date
>>>>> "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.

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


\
 
 \ /
  Last update: 2012-05-25 12:41    [W:0.094 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site