Commit 54c57795 authored by Vasily Gorbik's avatar Vasily Gorbik Committed by Martin Schwidefsky

s390/mem_detect: replace tprot loop with binary search

In a situation when other memory detection methods are not available
(no SCLP and no z/VM diag260), continuous online memory is assumed.
Replacing tprot loop with faster binary search, as only online memory
end has to be found.
Reviewed-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent cd45c995
...@@ -3,12 +3,10 @@ ...@@ -3,12 +3,10 @@
#include <asm/sclp.h> #include <asm/sclp.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/mem_detect.h> #include <asm/mem_detect.h>
#include <asm/sparsemem.h>
#include "compressed/decompressor.h" #include "compressed/decompressor.h"
#include "boot.h" #include "boot.h"
#define CHUNK_READ_WRITE 0
#define CHUNK_READ_ONLY 1
unsigned long __bootdata(max_physmem_end); unsigned long __bootdata(max_physmem_end);
struct mem_detect_info __bootdata(mem_detect); struct mem_detect_info __bootdata(mem_detect);
...@@ -141,38 +139,25 @@ static int tprot(unsigned long addr) ...@@ -141,38 +139,25 @@ static int tprot(unsigned long addr)
return rc; return rc;
} }
static void scan_memory(unsigned long rzm) static void search_mem_end(void)
{ {
unsigned long addr, size; unsigned long range = 1 << (MAX_PHYSMEM_BITS - 20); /* in 1MB blocks */
int type; unsigned long offset = 0;
unsigned long pivot;
if (!rzm)
rzm = 1UL << 20; while (range > 1) {
range >>= 1;
addr = 0; pivot = offset + range;
do { if (!tprot(pivot << 20))
size = 0; offset = pivot;
/* assume lowcore is writable */ }
type = addr ? tprot(addr) : CHUNK_READ_WRITE;
do { add_mem_detect_block(0, (offset + 1) << 20);
size += rzm;
if (max_physmem_end && addr + size >= max_physmem_end)
break;
} while (type == tprot(addr + size));
if (type == CHUNK_READ_WRITE || type == CHUNK_READ_ONLY) {
if (max_physmem_end && (addr + size > max_physmem_end))
size = max_physmem_end - addr;
add_mem_detect_block(addr, addr + size);
}
addr += size;
} while (addr < max_physmem_end);
} }
void detect_memory(void) void detect_memory(void)
{ {
unsigned long rzm; sclp_early_get_memsize(&max_physmem_end);
sclp_early_get_meminfo(&max_physmem_end, &rzm);
if (!sclp_early_read_storage_info()) { if (!sclp_early_read_storage_info()) {
mem_detect.info_source = MEM_DETECT_SCLP_STOR_INFO; mem_detect.info_source = MEM_DETECT_SCLP_STOR_INFO;
...@@ -190,7 +175,7 @@ void detect_memory(void) ...@@ -190,7 +175,7 @@ void detect_memory(void)
return; return;
} }
scan_memory(rzm); search_mem_end();
mem_detect.info_source = MEM_DETECT_TPROT_LOOP; mem_detect.info_source = MEM_DETECT_BIN_SEARCH;
max_physmem_end = get_mem_detect_end(); max_physmem_end = get_mem_detect_end();
} }
...@@ -9,7 +9,7 @@ enum mem_info_source { ...@@ -9,7 +9,7 @@ enum mem_info_source {
MEM_DETECT_SCLP_STOR_INFO, MEM_DETECT_SCLP_STOR_INFO,
MEM_DETECT_DIAG260, MEM_DETECT_DIAG260,
MEM_DETECT_SCLP_READ_INFO, MEM_DETECT_SCLP_READ_INFO,
MEM_DETECT_TPROT_LOOP MEM_DETECT_BIN_SEARCH
}; };
struct mem_detect_block { struct mem_detect_block {
......
...@@ -114,7 +114,7 @@ void sclp_early_printk(const char *s); ...@@ -114,7 +114,7 @@ void sclp_early_printk(const char *s);
void sclp_early_printk_force(const char *s); void sclp_early_printk_force(const char *s);
void __sclp_early_printk(const char *s, unsigned int len, unsigned int force); void __sclp_early_printk(const char *s, unsigned int len, unsigned int force);
int sclp_early_get_meminfo(unsigned long *mem, unsigned long *rzm); int sclp_early_get_memsize(unsigned long *mem);
int _sclp_get_core_info(struct sclp_core_info *info); int _sclp_get_core_info(struct sclp_core_info *info);
int sclp_core_configure(u8 core); int sclp_core_configure(u8 core);
int sclp_core_deconfigure(u8 core); int sclp_core_deconfigure(u8 core);
......
...@@ -272,7 +272,7 @@ int __init sclp_early_get_info(struct read_info_sccb *info) ...@@ -272,7 +272,7 @@ int __init sclp_early_get_info(struct read_info_sccb *info)
return 0; return 0;
} }
int __init sclp_early_get_meminfo(unsigned long *mem, unsigned long *rzm) int __init sclp_early_get_memsize(unsigned long *mem)
{ {
unsigned long rnmax; unsigned long rnmax;
unsigned long rnsize; unsigned long rnsize;
...@@ -285,7 +285,6 @@ int __init sclp_early_get_meminfo(unsigned long *mem, unsigned long *rzm) ...@@ -285,7 +285,6 @@ int __init sclp_early_get_meminfo(unsigned long *mem, unsigned long *rzm)
rnsize = sccb->rnsize ? sccb->rnsize : sccb->rnsize2; rnsize = sccb->rnsize ? sccb->rnsize : sccb->rnsize2;
rnsize <<= 20; rnsize <<= 20;
*mem = rnsize * rnmax; *mem = rnsize * rnmax;
*rzm = rnsize;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment