cmd: memtester: fix dram bandwidth to 32bit

For all rk chip, bandwidth is 32bit. Fix to 32bit to improve test
effect.

Change-Id: I4b7f2f3722d6c820886bec46179badc73719496a
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
This commit is contained in:
Tang Yun ping 2018-12-19 09:39:51 +08:00 committed by Kever Yang
parent 3decc73706
commit 614eb1970c
5 changed files with 136 additions and 146 deletions

View File

@ -62,7 +62,7 @@ static int do_memtester(cmd_tbl_t *cmdtp, int flag, int argc,
ul loop, i, j;
ul buf_start;
ul start_adr[2], length[2];
ulv * bufa[2], *bufb[2];
u32v * bufa[2], *bufb[2];
ul count[2];
ul bufsize = 0;
ul loops = 0;
@ -117,14 +117,14 @@ static int do_memtester(cmd_tbl_t *cmdtp, int flag, int argc,
if (!bufsize) {
/* test all memory */
for (i = 0; i < 2; i++) {
bufa[i] = (ulv *)start_adr[i];
bufb[i] = (ulv *)(start_adr[i] + length[i] / 2);
count[i] = length[i] / 2 / sizeof(ul);
bufa[i] = (u32v *)start_adr[i];
bufb[i] = (u32v *)(start_adr[i] + length[i] / 2);
count[i] = length[i] / 2 / sizeof(u32);
}
} else {
bufa[0] = (ulv *)buf_start;
bufb[0] = (ulv *)(buf_start + bufsize / 2);
count[0] = bufsize / 2 / sizeof(ul);
bufa[0] = (u32v *)buf_start;
bufb[0] = (u32v *)(buf_start + bufsize / 2);
count[0] = bufsize / 2 / sizeof(u32);
bufa[1] = 0;
if (start_adr[1]) {
if (buf_start < start_adr[0] ||
@ -153,7 +153,7 @@ static int do_memtester(cmd_tbl_t *cmdtp, int flag, int argc,
if (!bufa[j])
continue;
printf("testing:0x%lx - 0x%lx\n", (ul)bufa[j],
(ul)bufa[j] + count[j] * 2 * sizeof(ul));
(ul)bufa[j] + count[j] * 2 * sizeof(u32));
printf("Loop %lu", loop);
if (loops)
printf("/%lu", loops);

View File

@ -19,22 +19,11 @@
#define rand32() ((unsigned int)rand() | ((unsigned int)rand() << 16))
#ifndef CONFIG_ARM64
#define rand_ul() rand32()
#define UL_ONEBITS 0xffffffff
#define UL_LEN 32
#define CHECKERBOARD1 0x55555555
#define CHECKERBOARD2 0xaaaaaaaa
#define UL_BYTE(x) ((x | x << 8 | x << 16 | x << 24))
#else
#define rand64() (((ul)rand32()) << 32 | ((ul)rand32()))
#define rand_ul() rand64()
#define UL_ONEBITS 0xffffffffffffffffUL
#define UL_LEN 64
#define CHECKERBOARD1 0x5555555555555555
#define CHECKERBOARD2 0xaaaaaaaaaaaaaaaa
#define UL_BYTE(x) (((ul)x | (ul)x << 8 | (ul)x << 16 | (ul)x << 24 | \
(ul)x << 32 | (ul)x << 40 | (ul)x << 48 | (ul)x << 56))
#endif
#endif /* __MEMTESTER_SIZES_H */

View File

@ -20,12 +20,12 @@
union {
unsigned char bytes[UL_LEN / 8];
ul val;
u32 val;
} mword8;
union {
unsigned short u16s[UL_LEN / 16];
ul val;
u32 val;
} mword16;
char progress[] = "-\\|/";
@ -36,18 +36,18 @@ char progress[] = "-\\|/";
#define fflush(n)
/* Function definitions. */
int compare_regions(ulv *bufa, ulv *bufb, size_t count)
int compare_regions(u32v *bufa, u32v *bufb, size_t count)
{
int r = 0;
size_t i;
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
off_t physaddr;
for (i = 0; i < count; i++, p1++, p2++) {
if (*p1 != *p2) {
if (use_phys) {
physaddr = physaddrbase + (i * sizeof(ul));
physaddr = physaddrbase + (i * sizeof(u32v));
fprintf(stderr,
"FAILURE: 0x%08lx != 0x%08lx at physical address "
"0x%08lx.\n",
@ -56,7 +56,7 @@ int compare_regions(ulv *bufa, ulv *bufb, size_t count)
fprintf(stderr,
"FAILURE: 0x%08lx != 0x%08lx at offset 0x%08lx.\n",
(ul)*p1, (ul)*p2,
(ul)(i * sizeof(ul)));
(ul)(i * sizeof(u32v)));
}
/* printf("Skipping to next test..."); */
r = -1;
@ -65,9 +65,9 @@ int compare_regions(ulv *bufa, ulv *bufb, size_t count)
return r;
}
int test_stuck_address(ulv *bufa, size_t count)
int test_stuck_address(u32v *bufa, size_t count)
{
ulv *p1 = bufa;
u32v *p1 = bufa;
unsigned int j;
size_t i;
off_t physaddr;
@ -76,23 +76,23 @@ int test_stuck_address(ulv *bufa, size_t count)
fflush(stdout);
for (j = 0; j < 16; j++) {
printf("\b\b\b\b\b\b\b\b\b\b\b");
p1 = (ulv *)bufa;
p1 = (u32v *)bufa;
printf("setting %3u", j);
fflush(stdout);
for (i = 0; i < count; i++) {
*p1 = ((j + i) % 2) == 0 ? (ul)p1 : ~((ul)p1);
*p1 = ((j + i) % 2) == 0 ? (u32)(ul)p1 : ~((u32)(ul)p1);
*p1++;
}
printf("\b\b\b\b\b\b\b\b\b\b\b");
printf("testing %3u", j);
fflush(stdout);
p1 = (ulv *)bufa;
p1 = (u32v *)bufa;
for (i = 0; i < count; i++, p1++) {
if (*p1 !=
(((j + i) % 2) == 0 ? (ul)p1 : ~((ul)p1))) {
if (*p1 != (((j + i) % 2) == 0 ?
(u32)(ul)p1 : ~((u32)(ul)p1))) {
if (use_phys) {
physaddr =
physaddrbase + (i * sizeof(ul));
physaddrbase + (i * sizeof(u32v));
fprintf(stderr,
"FAILURE: possible bad address line at physical "
"address 0x%08lx.\n", physaddr);
@ -100,7 +100,7 @@ int test_stuck_address(ulv *bufa, size_t count)
fprintf(stderr,
"FAILURE: possible bad address line at offset "
"0x%08lx.\n",
(ul)(i * sizeof(ul)));
(ul)(i * sizeof(u32v)));
}
printf("Skipping to next test...\n");
fflush(stdout);
@ -113,10 +113,10 @@ int test_stuck_address(ulv *bufa, size_t count)
return 0;
}
int test_random_value(ulv *bufa, ulv *bufb, size_t count)
int test_random_value(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
ul j = 0;
size_t i;
@ -135,12 +135,12 @@ int test_random_value(ulv *bufa, ulv *bufb, size_t count)
return compare_regions(bufa, bufb, count);
}
int test_xor_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_xor_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
size_t i;
ul q = rand_ul();
u32 q = rand_ul();
for (i = 0; i < count; i++) {
*p1++ ^= q;
@ -149,12 +149,12 @@ int test_xor_comparison(ulv *bufa, ulv *bufb, size_t count)
return compare_regions(bufa, bufb, count);
}
int test_sub_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_sub_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
size_t i;
ul q = rand_ul();
u32 q = rand_ul();
for (i = 0; i < count; i++) {
*p1++ -= q;
@ -163,12 +163,12 @@ int test_sub_comparison(ulv *bufa, ulv *bufb, size_t count)
return compare_regions(bufa, bufb, count);
}
int test_mul_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_mul_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
size_t i;
ul q = rand_ul();
u32 q = rand_ul();
for (i = 0; i < count; i++) {
*p1++ *= q;
@ -177,12 +177,12 @@ int test_mul_comparison(ulv *bufa, ulv *bufb, size_t count)
return compare_regions(bufa, bufb, count);
}
int test_div_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_div_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
size_t i;
ul q = rand_ul();
u32 q = rand_ul();
for (i = 0; i < count; i++) {
if (!q)
@ -193,12 +193,12 @@ int test_div_comparison(ulv *bufa, ulv *bufb, size_t count)
return compare_regions(bufa, bufb, count);
}
int test_or_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_or_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
size_t i;
ul q = rand_ul();
u32 q = rand_ul();
for (i = 0; i < count; i++) {
*p1++ |= q;
@ -207,12 +207,12 @@ int test_or_comparison(ulv *bufa, ulv *bufb, size_t count)
return compare_regions(bufa, bufb, count);
}
int test_and_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_and_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
size_t i;
ul q = rand_ul();
u32 q = rand_ul();
for (i = 0; i < count; i++) {
*p1++ &= q;
@ -221,24 +221,24 @@ int test_and_comparison(ulv *bufa, ulv *bufb, size_t count)
return compare_regions(bufa, bufb, count);
}
int test_seqinc_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_seqinc_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
size_t i;
ul q = rand_ul();
u32 q = rand_ul();
for (i = 0; i < count; i++)
*p1++ = *p2++ = (i + q);
return compare_regions(bufa, bufb, count);
}
int test_solidbits_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_solidbits_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
unsigned int j;
ul q;
u32 q;
size_t i;
printf(" ");
@ -248,8 +248,8 @@ int test_solidbits_comparison(ulv *bufa, ulv *bufb, size_t count)
q = (j % 2) == 0 ? UL_ONEBITS : 0;
printf("setting %3u", j);
fflush(stdout);
p1 = (ulv *)bufa;
p2 = (ulv *)bufb;
p1 = (u32v *)bufa;
p2 = (u32v *)bufb;
for (i = 0; i < count; i++)
*p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
printf("\b\b\b\b\b\b\b\b\b\b\b");
@ -263,12 +263,12 @@ int test_solidbits_comparison(ulv *bufa, ulv *bufb, size_t count)
return 0;
}
int test_checkerboard_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_checkerboard_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
unsigned int j;
ul q;
u32 q;
size_t i;
printf(" ");
@ -278,8 +278,8 @@ int test_checkerboard_comparison(ulv *bufa, ulv *bufb, size_t count)
q = (j % 2) == 0 ? CHECKERBOARD1 : CHECKERBOARD2;
printf("setting %3u", j);
fflush(stdout);
p1 = (ulv *)bufa;
p2 = (ulv *)bufb;
p1 = (u32v *)bufa;
p2 = (u32v *)bufb;
for (i = 0; i < count; i++)
*p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
printf("\b\b\b\b\b\b\b\b\b\b\b");
@ -293,10 +293,10 @@ int test_checkerboard_comparison(ulv *bufa, ulv *bufb, size_t count)
return 0;
}
int test_blockseq_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_blockseq_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
unsigned int j;
size_t i;
@ -304,12 +304,12 @@ int test_blockseq_comparison(ulv *bufa, ulv *bufb, size_t count)
fflush(stdout);
for (j = 0; j < 256; j++) {
printf("\b\b\b\b\b\b\b\b\b\b\b");
p1 = (ulv *)bufa;
p2 = (ulv *)bufb;
p1 = (u32v *)bufa;
p2 = (u32v *)bufb;
printf("setting %3u", j);
fflush(stdout);
for (i = 0; i < count; i++)
*p1++ = *p2++ = (ul)UL_BYTE(j);
*p1++ = *p2++ = (u32)UL_BYTE(j);
printf("\b\b\b\b\b\b\b\b\b\b\b");
printf("testing %3u", j);
fflush(stdout);
@ -321,10 +321,10 @@ int test_blockseq_comparison(ulv *bufa, ulv *bufb, size_t count)
return 0;
}
int test_walkbits0_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_walkbits0_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
unsigned int j;
size_t i;
@ -332,8 +332,8 @@ int test_walkbits0_comparison(ulv *bufa, ulv *bufb, size_t count)
fflush(stdout);
for (j = 0; j < UL_LEN * 2; j++) {
printf("\b\b\b\b\b\b\b\b\b\b\b");
p1 = (ulv *)bufa;
p2 = (ulv *)bufb;
p1 = (u32v *)bufa;
p2 = (u32v *)bufb;
printf("setting %3u", j);
fflush(stdout);
for (i = 0; i < count; i++) {
@ -354,10 +354,10 @@ int test_walkbits0_comparison(ulv *bufa, ulv *bufb, size_t count)
return 0;
}
int test_walkbits1_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_walkbits1_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
unsigned int j;
size_t i;
@ -365,8 +365,8 @@ int test_walkbits1_comparison(ulv *bufa, ulv *bufb, size_t count)
fflush(stdout);
for (j = 0; j < UL_LEN * 2; j++) {
printf("\b\b\b\b\b\b\b\b\b\b\b");
p1 = (ulv *)bufa;
p2 = (ulv *)bufb;
p1 = (u32v *)bufa;
p2 = (u32v *)bufb;
printf("setting %3u", j);
fflush(stdout);
for (i = 0; i < count; i++) {
@ -388,10 +388,10 @@ int test_walkbits1_comparison(ulv *bufa, ulv *bufb, size_t count)
return 0;
}
int test_bitspread_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_bitspread_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
unsigned int j;
size_t i;
@ -399,8 +399,8 @@ int test_bitspread_comparison(ulv *bufa, ulv *bufb, size_t count)
fflush(stdout);
for (j = 0; j < UL_LEN * 2; j++) {
printf("\b\b\b\b\b\b\b\b\b\b\b");
p1 = (ulv *)bufa;
p2 = (ulv *)bufb;
p1 = (u32v *)bufa;
p2 = (u32v *)bufb;
printf("setting %3u", j);
fflush(stdout);
for (i = 0; i < count; i++) {
@ -431,12 +431,12 @@ int test_bitspread_comparison(ulv *bufa, ulv *bufb, size_t count)
return 0;
}
int test_bitflip_comparison(ulv *bufa, ulv *bufb, size_t count)
int test_bitflip_comparison(u32v *bufa, u32v *bufb, size_t count)
{
ulv *p1 = bufa;
ulv *p2 = bufb;
u32v *p1 = bufa;
u32v *p2 = bufb;
unsigned int j, k;
ul q;
u32 q;
size_t i;
printf(" ");
@ -448,8 +448,8 @@ int test_bitflip_comparison(ulv *bufa, ulv *bufb, size_t count)
q = ~q;
printf("setting %3u", k * 8 + j);
fflush(stdout);
p1 = (ulv *)bufa;
p2 = (ulv *)bufb;
p1 = (u32v *)bufa;
p2 = (u32v *)bufb;
for (i = 0; i < count; i++)
*p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
printf("\b\b\b\b\b\b\b\b\b\b\b");
@ -465,10 +465,10 @@ int test_bitflip_comparison(ulv *bufa, ulv *bufb, size_t count)
}
#ifdef TEST_NARROW_WRITES
int test_8bit_wide_random(ulv *bufa, ulv *bufb, size_t count)
int test_8bit_wide_random(u32v *bufa, u32v *bufb, size_t count)
{
u8v *p1, *t;
ulv *p2;
u32v *p2;
int attempt;
unsigned int b, j = 0;
size_t i;
@ -502,10 +502,10 @@ int test_8bit_wide_random(ulv *bufa, ulv *bufb, size_t count)
return 0;
}
int test_16bit_wide_random(ulv *bufa, ulv *bufb, size_t count)
int test_16bit_wide_random(u32v *bufa, u32v *bufb, size_t count)
{
u16v *p1, *t;
ulv *p2;
u32v *p2;
int attempt;
unsigned int b, j = 0;
size_t i;

View File

@ -17,40 +17,40 @@
/* Function declaration. */
int test_stuck_address(ulv *bufa, size_t count);
int test_random_value(ulv *bufa,
ulv *bufb, size_t count);
int test_xor_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_sub_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_mul_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_div_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_or_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_and_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_seqinc_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_solidbits_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_checkerboard_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_blockseq_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_walkbits0_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_walkbits1_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_bitspread_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_bitflip_comparison(ulv *bufa,
ulv *bufb, size_t count);
int test_stuck_address(u32v *bufa, size_t count);
int test_random_value(u32v *bufa,
u32v *bufb, size_t count);
int test_xor_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_sub_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_mul_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_div_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_or_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_and_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_seqinc_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_solidbits_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_checkerboard_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_blockseq_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_walkbits0_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_walkbits1_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_bitspread_comparison(u32v *bufa,
u32v *bufb, size_t count);
int test_bitflip_comparison(u32v *bufa,
u32v *bufb, size_t count);
#ifdef TEST_NARROW_WRITES
int test_8bit_wide_random(ulv *bufa,
ulv *bufb, size_t count);
int test_16bit_wide_random(ulv *bufa,
ulv *bufb, size_t count);
int test_8bit_wide_random(u32v *bufa,
u32v *bufb, size_t count);
int test_16bit_wide_random(u32v *bufa,
u32v *bufb, size_t count);
#endif

View File

@ -17,13 +17,14 @@
typedef unsigned long ul;
typedef unsigned long long ull;
typedef unsigned long volatile ulv;
/* for all rk chip, dram bandwidth both 32bit */
typedef unsigned int volatile u32v;
typedef unsigned char volatile u8v;
typedef unsigned short volatile u16v;
struct test {
char *name;
int (*fp)(ulv *bufa, ulv *bufb, size_t count);
int (*fp)(u32v *bufa, u32v *bufb, size_t count);
};
#endif /* __MEMTESTER_TYPES_H */