Skip to contentSkip to conversation

ppc4xx_pci: necessary fixes for 4GB RAM size

PATCH In review Ilya Yanok 4 participants 6 messages Aug 22, 2008 – Sep 1, 2008 PowerPC

lore
Share & tools
lore

Ilya Yanok

author
#0 lore raw

PATCH 1/1 ppc4xx_pci: necessary fixes for 4GB RAM size

1. total_memory should be phys_addr_t not unsigned long
2. is_power_of_2() works with u32 so I just inlined (size & (size-1)) != 0 instead.
Also this patch fixes default initialization: res->end should be 0x7fffffff not 0x80000000.

---
 arch/powerpc/sysdev/ppc4xx_pci.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
arch/powerpc/sysdev/ppc4xx_pci.c +6 -5
index e1c7df9..645b2c9 100644
@@ -36,7 +36,7 @@
 static int dma_offset_set;
 
 /* Move that to a useable header */
-extern unsigned long total_memory;
+extern phys_addr_t total_memory;
 
 #define U64_TO_U32_LOW(val)	((u32)((val) & 0x00000000ffffffffULL))
 #define U64_TO_U32_HIGH(val)	((u32)((val) >> 32))
@@ -105,7 +105,8 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 
 	/* Default */
 	res->start = 0;
-	res->end = size = 0x80000000;
+	size = 0x80000000;
+	res->end = size - 1;
 	res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 
 	/* Get dma-ranges property */
@@ -167,13 +168,13 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 	 */
 	if (size < total_memory) {
 		printk(KERN_ERR "%s: dma-ranges too small "
-		       "(size=%llx total_memory=%lx)\n",
-		       hose->dn->full_name, size, total_memory);
+		       "(size=%llx total_memory=%llx)\n",
+		       hose->dn->full_name, size, (u64)total_memory);
 		return -ENXIO;
 	}
 
 	/* Check we are a power of 2 size and that base is a multiple of size*/
-	if (!is_power_of_2(size) ||
+	if ((size & (size - 1)) != 0  ||
 	    (res->start & (size - 1)) != 0) {
 		printk(KERN_ERR "%s: dma-ranges unaligned\n",
 		       hose->dn->full_name);
Signature · 1 line
1.5.6.1
#1 lore raw
Quoted 7 lines · On Fri, 22 Aug 2008 11:43:35 +0400 Ilya Yanok <[email protected]> wrote:

1. total_memory should be phys_addr_t not unsigned long
2. is_power_of_2() works with u32 so I just inlined (size & (size-1)) != 0 instead.
Also this patch fixes default initialization: res->end should be 0x7fffffff not 0x80000000.

Ben, any comments here? Looks right to me.

josh

Quoted 44 lines
---
 arch/powerpc/sysdev/ppc4xx_pci.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
arch/powerpc/sysdev/ppc4xx_pci.c +6 -5
index e1c7df9..645b2c9 100644
@@ -36,7 +36,7 @@
 static int dma_offset_set;
 
 /* Move that to a useable header */
-extern unsigned long total_memory;
+extern phys_addr_t total_memory;
 
 #define U64_TO_U32_LOW(val)	((u32)((val) & 0x00000000ffffffffULL))
 #define U64_TO_U32_HIGH(val)	((u32)((val) >> 32))
@@ -105,7 +105,8 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 
 	/* Default */
 	res->start = 0;
-	res->end = size = 0x80000000;
+	size = 0x80000000;
+	res->end = size - 1;
 	res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 
 	/* Get dma-ranges property */
@@ -167,13 +168,13 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 	 */
 	if (size < total_memory) {
 		printk(KERN_ERR "%s: dma-ranges too small "
-		       "(size=%llx total_memory=%lx)\n",
-		       hose->dn->full_name, size, total_memory);
+		       "(size=%llx total_memory=%llx)\n",
+		       hose->dn->full_name, size, (u64)total_memory);
 		return -ENXIO;
 	}
 
 	/* Check we are a power of 2 size and that base is a multiple of size*/
-	if (!is_power_of_2(size) ||
+	if ((size & (size - 1)) != 0  ||
 	    (res->start & (size - 1)) != 0) {
 		printk(KERN_ERR "%s: dma-ranges unaligned\n",
 		       hose->dn->full_name);
Acked-by
#2 lore raw
Quoted 9 lines · Josh Boyer
Quoted 7 lines

1. total_memory should be phys_addr_t not unsigned long
2. is_power_of_2() works with u32 so I just inlined (size & (size-1)) != 0 instead.
Also this patch fixes default initialization: res->end should be 0x7fffffff not 0x80000000.

Ben, any comments here? Looks right to me.

Looks good to me too. So:

Best regards,
Stefan

#3 lore raw
In reply to Josh Boyer
Quoted 9 lines · Josh Boyer
Quoted 6 lines · On Fri, 22 Aug 2008 11:43:35 +0400 Ilya Yanok <[email protected]> wrote:

1. total_memory should be phys_addr_t not unsigned long
2. is_power_of_2() works with u32 so I just inlined (size & (size-1)) != 0 instead.
Also this patch fixes default initialization: res->end should be 0x7fffffff not 0x80000000.

Quoted 3 lines
Quoted 1 line

Ben, any comments here? Looks right to me.

Just one minor comment... The patch should do what I failed to do before, which is to move total_memory declaration to a header :-)

Cheers,
Ben.

Quoted 46 lines

josh

Quoted 44 lines
---
 arch/powerpc/sysdev/ppc4xx_pci.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
arch/powerpc/sysdev/ppc4xx_pci.c +6 -5
index e1c7df9..645b2c9 100644
@@ -36,7 +36,7 @@
 static int dma_offset_set;
 
 /* Move that to a useable header */
-extern unsigned long total_memory;
+extern phys_addr_t total_memory;
 
 #define U64_TO_U32_LOW(val)	((u32)((val) & 0x00000000ffffffffULL))
 #define U64_TO_U32_HIGH(val)	((u32)((val) >> 32))
@@ -105,7 +105,8 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 
 	/* Default */
 	res->start = 0;
-	res->end = size = 0x80000000;
+	size = 0x80000000;
+	res->end = size - 1;
 	res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 
 	/* Get dma-ranges property */
@@ -167,13 +168,13 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 	 */
 	if (size < total_memory) {
 		printk(KERN_ERR "%s: dma-ranges too small "
-		       "(size=%llx total_memory=%lx)\n",
-		       hose->dn->full_name, size, total_memory);
+		       "(size=%llx total_memory=%llx)\n",
+		       hose->dn->full_name, size, (u64)total_memory);
 		return -ENXIO;
 	}
 
 	/* Check we are a power of 2 size and that base is a multiple of size*/
-	if (!is_power_of_2(size) ||
+	if ((size & (size - 1)) != 0  ||
 	    (res->start & (size - 1)) != 0) {
 		printk(KERN_ERR "%s: dma-ranges unaligned\n",
 		       hose->dn->full_name);
author
#4 lore raw
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 6 lines
Quoted 6 lines

1. total_memory should be phys_addr_t not unsigned long
2. is_power_of_2() works with u32 so I just inlined (size & (size-1)) != 0 instead.
Also this patch fixes default initialization: res->end should be 0x7fffffff not 0x80000000.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Ben, any comments here? Looks right to me.

Just one minor comment... The patch should do what I failed to do before, which is to move total_memory declaration to a header :-)

Hm... looks like we already have this declaration in arch/powerpc/mm/mmu_decl.h... I'll send modified patch soon.

Regards, Ilya.

author
#5 lore raw

PATCH 1/1 ppc4xx_pci: necessary fixes for 4GB RAM size (updated)

1. declaration of total_memory removed. Now including <mm/mmu_decl.h> instead.
2. is_power_of_2() works with u32 so I just inlined (size & (size-1)) != 0 instead.
Also this patch fixes default initialization: res->end should be 0x7fffffff not 0x80000000.

---
 arch/powerpc/sysdev/ppc4xx_pci.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
arch/powerpc/sysdev/ppc4xx_pci.c +6 -7
index e1c7df9..e899716 100644
@@ -30,14 +30,12 @@
 #include <asm/machdep.h>
 #include <asm/dcr.h>
 #include <asm/dcr-regs.h>
+#include <mm/mmu_decl.h>
 
 #include "ppc4xx_pci.h"
 
 static int dma_offset_set;
 
-/* Move that to a useable header */
-extern unsigned long total_memory;
-
 #define U64_TO_U32_LOW(val)	((u32)((val) & 0x00000000ffffffffULL))
 #define U64_TO_U32_HIGH(val)	((u32)((val) >> 32))
 
@@ -105,7 +103,8 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 
 	/* Default */
 	res->start = 0;
-	res->end = size = 0x80000000;
+	size = 0x80000000;
+	res->end = size - 1;
 	res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 
 	/* Get dma-ranges property */
@@ -167,13 +166,13 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
 	 */
 	if (size < total_memory) {
 		printk(KERN_ERR "%s: dma-ranges too small "
-		       "(size=%llx total_memory=%lx)\n",
-		       hose->dn->full_name, size, total_memory);
+		       "(size=%llx total_memory=%llx)\n",
+		       hose->dn->full_name, size, (u64)total_memory);
 		return -ENXIO;
 	}
 
 	/* Check we are a power of 2 size and that base is a multiple of size*/
-	if (!is_power_of_2(size) ||
+	if ((size & (size - 1)) != 0  ||
 	    (res->start & (size - 1)) != 0) {
 		printk(KERN_ERR "%s: dma-ranges unaligned\n",
 		       hose->dn->full_name);
Signature · 1 line
1.5.6.1