* [PATCH] prom.c: Fix dt_mem_next_cell() to read the full mem cells
@ 2008-02-15 18:17 Becky Bruce
2008-02-16 11:45 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 2+ messages in thread
From: Becky Bruce @ 2008-02-15 18:17 UTC (permalink / raw)
To: linuxppc-dev
dt_mem_next_cell() currently does of_read_ulong(). This does
not allow for the case where #size-cells and/or #address-cells = 2 on
a 32-bit system, as it will end up reading 32 bits instead of the
expected 64. Change it to use of_read_number instead and always return
a u64.
Signed-off-by: Becky Bruce <becky.bruce at freescale.com>
---
arch/powerpc/kernel/prom.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index c17a585..ff600ef 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -865,12 +865,12 @@ static int __init early_init_dt_scan_root(unsigned long node,
return 1;
}
-static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp)
+static u64 __init dt_mem_next_cell(int s, cell_t **cellp)
{
cell_t *p = *cellp;
*cellp = p + s;
- return of_read_ulong(p, s);
+ return of_read_number(p, s);
}
#ifdef CONFIG_PPC_PSERIES
@@ -883,8 +883,8 @@ static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp)
static int __init early_init_dt_scan_drconf_memory(unsigned long node)
{
cell_t *dm, *ls;
- unsigned long l, n;
- unsigned long base, size, lmb_size, flags;
+ unsigned long l, n, flags;
+ u64 base, size, lmb_size;
ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
@@ -959,14 +959,15 @@ static int __init early_init_dt_scan_memory(unsigned long node,
uname, l, reg[0], reg[1], reg[2], reg[3]);
while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
- unsigned long base, size;
+ u64 base, size;
base = dt_mem_next_cell(dt_root_addr_cells, ®);
size = dt_mem_next_cell(dt_root_size_cells, ®);
if (size == 0)
continue;
- DBG(" - %lx , %lx\n", base, size);
+ DBG(" - %llx , %llx\n", (unsigned long long)base,
+ (unsigned long long)size);
#ifdef CONFIG_PPC64
if (iommu_is_off) {
if (base >= 0x80000000ul)
--
1.5.3.8
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] prom.c: Fix dt_mem_next_cell() to read the full mem cells
2008-02-15 18:17 [PATCH] prom.c: Fix dt_mem_next_cell() to read the full mem cells Becky Bruce
@ 2008-02-16 11:45 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2008-02-16 11:45 UTC (permalink / raw)
To: Becky Bruce; +Cc: linuxppc-dev
On Fri, 2008-02-15 at 12:17 -0600, Becky Bruce wrote:
> dt_mem_next_cell() currently does of_read_ulong(). This does
> not allow for the case where #size-cells and/or #address-cells = 2 on
> a 32-bit system, as it will end up reading 32 bits instead of the
> expected 64. Change it to use of_read_number instead and always return
> a u64.
>
> Signed-off-by: Becky Bruce <becky.bruce at freescale.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/kernel/prom.c | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index c17a585..ff600ef 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -865,12 +865,12 @@ static int __init early_init_dt_scan_root(unsigned long node,
> return 1;
> }
>
> -static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp)
> +static u64 __init dt_mem_next_cell(int s, cell_t **cellp)
> {
> cell_t *p = *cellp;
>
> *cellp = p + s;
> - return of_read_ulong(p, s);
> + return of_read_number(p, s);
> }
>
> #ifdef CONFIG_PPC_PSERIES
> @@ -883,8 +883,8 @@ static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp)
> static int __init early_init_dt_scan_drconf_memory(unsigned long node)
> {
> cell_t *dm, *ls;
> - unsigned long l, n;
> - unsigned long base, size, lmb_size, flags;
> + unsigned long l, n, flags;
> + u64 base, size, lmb_size;
>
> ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
> if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
> @@ -959,14 +959,15 @@ static int __init early_init_dt_scan_memory(unsigned long node,
> uname, l, reg[0], reg[1], reg[2], reg[3]);
>
> while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
> - unsigned long base, size;
> + u64 base, size;
>
> base = dt_mem_next_cell(dt_root_addr_cells, ®);
> size = dt_mem_next_cell(dt_root_size_cells, ®);
>
> if (size == 0)
> continue;
> - DBG(" - %lx , %lx\n", base, size);
> + DBG(" - %llx , %llx\n", (unsigned long long)base,
> + (unsigned long long)size);
> #ifdef CONFIG_PPC64
> if (iommu_is_off) {
> if (base >= 0x80000000ul)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-16 11:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-15 18:17 [PATCH] prom.c: Fix dt_mem_next_cell() to read the full mem cells Becky Bruce
2008-02-16 11:45 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).