diff options
Diffstat (limited to 'arch/x86/mm/memtest.c')
| -rw-r--r-- | arch/x86/mm/memtest.c | 43 | 
1 files changed, 16 insertions, 27 deletions
diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c index 92faf3a1c53..1e9da795767 100644 --- a/arch/x86/mm/memtest.c +++ b/arch/x86/mm/memtest.c @@ -9,6 +9,7 @@  #include <linux/memblock.h>  static u64 patterns[] __initdata = { +	/* The first entry has to be 0 to leave memtest with zeroed memory */  	0,  	0xffffffffffffffffULL,  	0x5555555555555555ULL, @@ -34,7 +35,7 @@ static void __init reserve_bad_mem(u64 pattern, u64 start_bad, u64 end_bad)  	       (unsigned long long) pattern,  	       (unsigned long long) start_bad,  	       (unsigned long long) end_bad); -	memblock_x86_reserve_range(start_bad, end_bad, "BAD RAM"); +	memblock_reserve(start_bad, end_bad - start_bad);  }  static void __init memtest(u64 pattern, u64 start_phys, u64 size) @@ -70,24 +71,19 @@ static void __init memtest(u64 pattern, u64 start_phys, u64 size)  static void __init do_one_pass(u64 pattern, u64 start, u64 end)  { -	u64 size = 0; - -	while (start < end) { -		start = memblock_x86_find_in_range_size(start, &size, 1); - -		/* done ? */ -		if (start >= end) -			break; -		if (start + size > end) -			size = end - start; - -		printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n", -		       (unsigned long long) start, -		       (unsigned long long) start + size, -		       (unsigned long long) cpu_to_be64(pattern)); -		memtest(pattern, start, size); - -		start += size; +	u64 i; +	phys_addr_t this_start, this_end; + +	for_each_free_mem_range(i, NUMA_NO_NODE, &this_start, &this_end, NULL) { +		this_start = clamp_t(phys_addr_t, this_start, start, end); +		this_end = clamp_t(phys_addr_t, this_end, start, end); +		if (this_start < this_end) { +			printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n", +			       (unsigned long long)this_start, +			       (unsigned long long)this_end, +			       (unsigned long long)cpu_to_be64(pattern)); +			memtest(pattern, this_start, this_end - this_start); +		}  	}  } @@ -115,15 +111,8 @@ void __init early_memtest(unsigned long start, unsigned long end)  		return;  	printk(KERN_INFO "early_memtest: # of tests: %d\n", memtest_pattern); -	for (i = 0; i < memtest_pattern; i++) { +	for (i = memtest_pattern-1; i < UINT_MAX; --i) {  		idx = i % ARRAY_SIZE(patterns);  		do_one_pass(patterns[idx], start, end);  	} - -	if (idx > 0) { -		printk(KERN_INFO "early_memtest: wipe out " -		       "test pattern from memory\n"); -		/* additional test with pattern 0 will do this */ -		do_one_pass(0, start, end); -	}  }  | 
