Skip to content

Commit

Permalink
powerpc: Fix erroneous lmb->memblock conversions
Browse files Browse the repository at this point in the history
Oooops... we missed these. We incorrectly converted strings
used when parsing the device-tree on pseries, thus breaking
access to drconf memory and hotplug memory.

While at it, also revert some variable names that represent
something the FW calls "lmb" and thus don't need to be converted
to "memblock".

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
  • Loading branch information
Benjamin Herrenschmidt committed Jul 23, 2010
1 parent 4b8692c commit 3fdfd99
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
u64 base, size, memblock_size;
unsigned int is_kexec_kdump = 0, rngs;

ls = of_get_flat_dt_prop(node, "ibm,memblock-size", &l);
ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
if (ls == NULL || l < dt_root_size_cells * sizeof(__be32))
return 0;
memblock_size = dt_mem_next_cell(dt_root_size_cells, &ls);
Expand Down
24 changes: 12 additions & 12 deletions arch/powerpc/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,15 @@ static int of_get_drconf_memory(struct device_node *memory, const u32 **dm)
}

/*
* Retreive and validate the ibm,memblock-size property for drconf memory
* Retreive and validate the ibm,lmb-size property for drconf memory
* from the device tree.
*/
static u64 of_get_memblock_size(struct device_node *memory)
static u64 of_get_lmb_size(struct device_node *memory)
{
const u32 *prop;
u32 len;

prop = of_get_property(memory, "ibm,memblock-size", &len);
prop = of_get_property(memory, "ibm,lmb-size", &len);
if (!prop || len < sizeof(unsigned int))
return 0;

Expand Down Expand Up @@ -562,7 +562,7 @@ static unsigned long __init numa_enforce_memory_limit(unsigned long start,
static inline int __init read_usm_ranges(const u32 **usm)
{
/*
* For each memblock in ibm,dynamic-memory a corresponding
* For each lmb in ibm,dynamic-memory a corresponding
* entry in linux,drconf-usable-memory property contains
* a counter followed by that many (base, size) duple.
* read the counter from linux,drconf-usable-memory
Expand All @@ -578,16 +578,16 @@ static void __init parse_drconf_memory(struct device_node *memory)
{
const u32 *dm, *usm;
unsigned int n, rc, ranges, is_kexec_kdump = 0;
unsigned long memblock_size, base, size, sz;
unsigned long lmb_size, base, size, sz;
int nid;
struct assoc_arrays aa;

n = of_get_drconf_memory(memory, &dm);
if (!n)
return;

memblock_size = of_get_memblock_size(memory);
if (!memblock_size)
lmb_size = of_get_lmb_size(memory);
if (!lmb_size)
return;

rc = of_get_assoc_arrays(memory, &aa);
Expand All @@ -611,7 +611,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
continue;

base = drmem.base_addr;
size = memblock_size;
size = lmb_size;
ranges = 1;

if (is_kexec_kdump) {
Expand Down Expand Up @@ -1072,16 +1072,16 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
{
const u32 *dm;
unsigned int drconf_cell_cnt, rc;
unsigned long memblock_size;
unsigned long lmb_size;
struct assoc_arrays aa;
int nid = -1;

drconf_cell_cnt = of_get_drconf_memory(memory, &dm);
if (!drconf_cell_cnt)
return -1;

memblock_size = of_get_memblock_size(memory);
if (!memblock_size)
lmb_size = of_get_lmb_size(memory);
if (!lmb_size)
return -1;

rc = of_get_assoc_arrays(memory, &aa);
Expand All @@ -1100,7 +1100,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
continue;

if ((scn_addr < drmem.base_addr)
|| (scn_addr >= (drmem.base_addr + memblock_size)))
|| (scn_addr >= (drmem.base_addr + lmb_size)))
continue;

nid = of_drconf_to_nid_single(&drmem, &aa);
Expand Down
22 changes: 11 additions & 11 deletions arch/powerpc/platforms/pseries/hotplug-memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int pseries_remove_memory(struct device_node *np)
const char *type;
const unsigned int *regs;
unsigned long base;
unsigned int memblock_size;
unsigned int lmb_size;
int ret = -EINVAL;

/*
Expand All @@ -87,9 +87,9 @@ static int pseries_remove_memory(struct device_node *np)
return ret;

base = *(unsigned long *)regs;
memblock_size = regs[3];
lmb_size = regs[3];

ret = pseries_remove_memblock(base, memblock_size);
ret = pseries_remove_memblock(base, lmb_size);
return ret;
}

Expand All @@ -98,7 +98,7 @@ static int pseries_add_memory(struct device_node *np)
const char *type;
const unsigned int *regs;
unsigned long base;
unsigned int memblock_size;
unsigned int lmb_size;
int ret = -EINVAL;

/*
Expand All @@ -116,36 +116,36 @@ static int pseries_add_memory(struct device_node *np)
return ret;

base = *(unsigned long *)regs;
memblock_size = regs[3];
lmb_size = regs[3];

/*
* Update memory region to represent the memory add
*/
ret = memblock_add(base, memblock_size);
ret = memblock_add(base, lmb_size);
return (ret < 0) ? -EINVAL : 0;
}

static int pseries_drconf_memory(unsigned long *base, unsigned int action)
{
struct device_node *np;
const unsigned long *memblock_size;
const unsigned long *lmb_size;
int rc;

np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
if (!np)
return -EINVAL;

memblock_size = of_get_property(np, "ibm,memblock-size", NULL);
if (!memblock_size) {
lmb_size = of_get_property(np, "ibm,lmb-size", NULL);
if (!lmb_size) {
of_node_put(np);
return -EINVAL;
}

if (action == PSERIES_DRCONF_MEM_ADD) {
rc = memblock_add(*base, *memblock_size);
rc = memblock_add(*base, *lmb_size);
rc = (rc < 0) ? -EINVAL : 0;
} else if (action == PSERIES_DRCONF_MEM_REMOVE) {
rc = pseries_remove_memblock(*base, *memblock_size);
rc = pseries_remove_memblock(*base, *lmb_size);
} else {
rc = -EINVAL;
}
Expand Down

0 comments on commit 3fdfd99

Please sign in to comment.