mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-15 11:56:45 +07:00
423d5b364c
The memory detection code historically had to use unsigned long long since the machine reported the true memory size (>4GB) even if the virtual machine was running in ESA/390 mode. Since the old code is gone use unsigned long everywhere and also get rid of an unused ADDR2G define. (this patch converts all long longs within sclp_info to longs) There are many more possible conversions, however that can be done if somebody touches the corresponding code. Since people started to convert unrelated long types to long longs because of the types within struct sclp_info convert this now. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
/*
|
|
* Copyright IBM Corp. 2008, 2009
|
|
*
|
|
* Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/memblock.h>
|
|
#include <linux/init.h>
|
|
#include <linux/debugfs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <asm/ipl.h>
|
|
#include <asm/sclp.h>
|
|
#include <asm/setup.h>
|
|
|
|
#define CHUNK_READ_WRITE 0
|
|
#define CHUNK_READ_ONLY 1
|
|
|
|
static inline void memblock_physmem_add(phys_addr_t start, phys_addr_t size)
|
|
{
|
|
memblock_add_range(&memblock.memory, start, size, 0, 0);
|
|
memblock_add_range(&memblock.physmem, start, size, 0, 0);
|
|
}
|
|
|
|
void __init detect_memory_memblock(void)
|
|
{
|
|
unsigned long memsize, rnmax, rzm, addr, size;
|
|
int type;
|
|
|
|
rzm = sclp.rzm;
|
|
rnmax = sclp.rnmax;
|
|
memsize = rzm * rnmax;
|
|
if (!rzm)
|
|
rzm = 1UL << 17;
|
|
max_physmem_end = memsize;
|
|
addr = 0;
|
|
/* keep memblock lists close to the kernel */
|
|
memblock_set_bottom_up(true);
|
|
do {
|
|
size = 0;
|
|
type = tprot(addr);
|
|
do {
|
|
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;
|
|
memblock_physmem_add(addr, size);
|
|
}
|
|
addr += size;
|
|
} while (addr < max_physmem_end);
|
|
memblock_set_bottom_up(false);
|
|
if (!max_physmem_end)
|
|
max_physmem_end = memblock_end_of_DRAM();
|
|
}
|