summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@us.ibm.com>2012-09-26 10:26:17 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-10-03 10:39:09 -0500
commit95bba8326a62aed2a870baea3802a3f4db3691f1 (patch)
tree288ac52f1cb9546c3198f7916b82f6a0fdc7476d /src/usr
parent5d70614ca826d45c1d1d3457811b55cccf482582 (diff)
downloadtalos-hostboot-95bba8326a62aed2a870baea3802a3f4db3691f1.tar.gz
talos-hostboot-95bba8326a62aed2a870baea3802a3f4db3691f1.zip
Fix intermittent ATTN PRNG failures.
Failing (repeatedly generating the same number after some number of calls to the prng) about 20% of the time. Change-Id: I2d429856ecb5c3492aa414dfd3124d73af0878c0 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1886 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/diag/attn/test/attntest.C18
-rw-r--r--src/usr/diag/attn/test/attntestmem.H6
-rw-r--r--src/usr/diag/attn/test/attntestproc.H8
3 files changed, 20 insertions, 12 deletions
diff --git a/src/usr/diag/attn/test/attntest.C b/src/usr/diag/attn/test/attntest.C
index 1be9647c6..22fc032ba 100644
--- a/src/usr/diag/attn/test/attntest.C
+++ b/src/usr/diag/attn/test/attntest.C
@@ -43,10 +43,12 @@ namespace ATTN
uint64_t randint(uint64_t i_min, uint64_t i_max)
{
static bool setup = false;
- static uint64_t hapSeed = generate_random();
+ static uint64_t seed = 0;
if(!setup)
{
+ uint64_t hapSeed = generate_random();
+
if(!hapSeed)
{
ATTN_DBG("falling back to timebase seed for PRNG");
@@ -56,19 +58,20 @@ uint64_t randint(uint64_t i_min, uint64_t i_max)
ATTN_DBG("hapseed: %d", hapSeed);
}
+ seed = hapSeed ? hapSeed : getTB() + 1;
+
setup = true;
}
- static uint64_t seed = hapSeed ? hapSeed : getTB() + 1;
-
uint64_t lo, hi;
seed = seed * seed;
lo = (seed & 0x0000ffffffff0000ull) >> 16;
hi = (seed & 0x000000000000ffffull) << 32;
hi |= (seed & 0xffff000000000000ull);
- seed = lo;
+ seed = (lo | hi) + 2;
+ static const uint64_t randMax = 0xfffffffffffffffe;
uint64_t min = i_min, max = i_max;
if(i_min > i_max)
@@ -76,7 +79,12 @@ uint64_t randint(uint64_t i_min, uint64_t i_max)
swap(min, max);
}
- return ((lo | hi) % (i_max +1 - i_min)) + i_min;
+ if(max > randMax)
+ {
+ max = randMax;
+ }
+
+ return ((lo | hi) % (max +1 - min)) + min;
}
ATTENTION_VALUE_TYPE getRandomAttentionType()
diff --git a/src/usr/diag/attn/test/attntestmem.H b/src/usr/diag/attn/test/attntestmem.H
index 38046df89..9b472761b 100644
--- a/src/usr/diag/attn/test/attntestmem.H
+++ b/src/usr/diag/attn/test/attntestmem.H
@@ -91,7 +91,7 @@ class AttnMemTest: public CxxTest::TestSuite
// put some random data in the mask register
- uint64_t randomData = randint(0, 0xffffffff);
+ uint64_t randomData = randint(0, 0xffffffffffffffffull);
uint64_t maskbits = 0;
if(!IPOLL::getCheckbits(HOST, maskbits))
@@ -202,7 +202,7 @@ class AttnMemTest: public CxxTest::TestSuite
// put some random data in the mask register
- uint64_t randomData = randint(0, 0xffffffff);
+ uint64_t randomData = randint(0, 0xffffffffffffffffull);
uint64_t maskbits = 0;
if(!IPOLL::getCheckbits(HOST, maskbits))
@@ -239,7 +239,7 @@ class AttnMemTest: public CxxTest::TestSuite
// verify that the attn was masked, and that
// other bits weren't touched
- if(!(data & ~maskbits))
+ if(!(~data & maskbits))
{
TS_FAIL("attention not unmasked");
break;
diff --git a/src/usr/diag/attn/test/attntestproc.H b/src/usr/diag/attn/test/attntestproc.H
index cb62fc0f9..a9f8001a1 100644
--- a/src/usr/diag/attn/test/attntestproc.H
+++ b/src/usr/diag/attn/test/attntestproc.H
@@ -87,7 +87,7 @@ class AttnProcTest: public CxxTest::TestSuite
// put some random data in the mask register
- uint64_t randomData = randint(0, 0xffffffff);
+ uint64_t randomData = randint(0, 0xffffffffffffffffull);
uint64_t maskbits = 0;
if(!IPOLL::getCheckbits(d.attnType, maskbits))
@@ -195,7 +195,7 @@ class AttnProcTest: public CxxTest::TestSuite
// put some random data in the mask register
- uint64_t randomData = randint(0, 0xffffffff);
+ uint64_t randomData = randint(0, 0xffffffffffffffffull);
uint64_t maskbits = 0;
if(!IPOLL::getCheckbits(d.attnType, maskbits))
@@ -229,10 +229,10 @@ class AttnProcTest: public CxxTest::TestSuite
break;
}
- // verify that the attn was masked, and that
+ // verify that the attn was unmasked, and that
// other bits weren't touched
- if(!(data & ~maskbits))
+ if(!(~data & maskbits))
{
TS_FAIL("attention not unmasked");
break;
OpenPOWER on IntegriCloud