Skip to contentSkip to conversation

64-bit struct resource fields

PATCH In review Dave Hansen 3 participants 5 messages Nov 25, 2002 – Dec 4, 2002

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 64-bit struct resource fields

We need some way to replicate the e820 tables for kexec. This modifies struct resource to use u64's for its start and end fields. This way we can export the whole e820 table on PAE machines.

resource->flags seems to be used often to mask out things in resource->start/end, so I think it needs to be u64 too. But, Is it all right to let things like pcibios_update_resource() truncate the resource addresses like they do?

With my config, it has no more warnings than it did before.

Here's /proc/iomem from a 16-gig ia32 box with the patch:

0000000000000000-000000000009c7ff : System RAM 000000000009c800-000000000009ffff : reserved 00000000000a0000-00000000000bffff : Video RAM area 00000000000c0000-00000000000c7fff : Video ROM 00000000000c8000-00000000000cc7ff : Extension ROM 00000000000cc800-00000000000d47ff : Extension ROM 00000000000d4800-00000000000d5fff : Extension ROM 00000000000f0000-00000000000fffff : System ROM 0000000000100000-00000000efff64ff : System RAM
0000000000100000-000000000029fe78 : Kernel code 000000000029fe79-0000000000395d7f : Kernel data
00000000efff6500-00000000efffffff : ACPI Tables 00000000f8000000-00000000fbffffff : S3 Inc. Trio 64 3D 00000000fc1e0000-00000000fc1effff : PCI device 1014:00dc (IBM) 00000000fc1fd000-00000000fc1fdfff : Adaptec AIC-7896U2/7897U2 (#2)
00000000fc1fd000-00000000fc1fdfff : aic7xxx
00000000fc1fe000-00000000fc1fefff : Adaptec AIC-7896U2/7897U2
00000000fc1fe000-00000000fc1fefff : aic7xxx
00000000fc1ffc00-00000000fc1ffcff : PCI device 1014:00dc (IBM) 00000000fd7c0000-00000000fd7dffff : Intel Corp. 82557/8/9 [Ethernet 00000000fd7fcc00-00000000fd7fcc7f : Digital Equipment Co DECchip 21140
00000000fd7fcc00-00000000fd7fcc7f : tulip
00000000fd7fd000-00000000fd7fdfff : Intel Corp. 82557/8/9 [Ethernet
00000000fd7fd000-00000000fd7fdfff : eepro100
00000000fd7fe000-00000000fd7fffff : IBM Netfinity ServeRAID
00000000fd7fe000-00000000fd7fffff : ips
00000000fe1c0000-00000000fe1dffff : Intel Corp. 82546EB Gigabit Ethe
00000000fe1c0000-00000000fe1dffff : e1000
00000000fe1e0000-00000000fe1fffff : Intel Corp. 82546EB Gigabit Ethe
00000000fe1e0000-00000000fe1fffff : e1000
00000000fffb0000-00000000ffffffff : reserved 0000000100000000-00000003ffffffff : System RAM

Signature · 2 lines
Dave Hansen
[email protected]
arch/alpha/kernel/pci.c +3 -3
diff -Nru a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
@@ -149,12 +149,12 @@
 
 void
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 	struct pci_dev *dev = data;
 	struct pci_controller *hose = dev->sysdata;
-	unsigned long alignto;
-	unsigned long start = res->start;
+	u64 alignto;
+	u64 start = res->start;
 
 	if (res->flags & IORESOURCE_IO) {
 		/* Make sure we start at our min on all hoses */
arch/arm/kernel/bios32.c +3 -3
diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
@@ -268,7 +268,7 @@
 	int reg;
 
 	if (debug_pci)
-		printk("PCI: Assigning %3s %08lx to %s\n",
+		printk("PCI: Assigning %3s %016Lx to %s\n",
 			res->flags & IORESOURCE_IO ? "IO" : "MEM",
 			res->start, dev->dev.name);
 
@@ -585,9 +585,9 @@
  * which might be mirrored at 0x0100-0x03ff..
  */
 void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
+			    u64 size, u64 align)
 {
-	unsigned long start = res->start;
+	u64 start = res->start;
 
 	if (res->flags & IORESOURCE_IO && start & 0x300)
 		start = (start + 0x3ff) & ~0x3ff;
arch/i386/kernel/setup.c +9 -6
diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
@@ -798,15 +798,18 @@
 	probe_roms();
 	for (i = 0; i < e820.nr_map; i++) {
 		struct resource *res;
-		if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
-			continue;
+		
+		//if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
+		//	continue;
+	
 		res = alloc_bootmem_low(sizeof(struct resource));
 		switch (e820.map[i].type) {
-		case E820_RAM:	res->name = "System RAM"; break;
-		case E820_ACPI:	res->name = "ACPI Tables"; break;
-		case E820_NVS:	res->name = "ACPI Non-volatile Storage"; break;
-		default:	res->name = "reserved";
+		case E820_RAM:	res->name = "System RAM e820"; break;
+		case E820_ACPI:	res->name = "ACPI Tables e820"; break;
+		case E820_NVS:	res->name = "ACPI Non-volatile Storage e820"; break;
+		default:	res->name = "reserved e820";
 		}
+		res->type = e820.map[i].type;
 		res->start = e820.map[i].addr;
 		res->end = res->start + e820.map[i].size - 1;
 		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
arch/i386/pci/i386.c +3 -3
diff -Nru a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c
@@ -76,10 +76,10 @@
  */
 void
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		if (start & 0x300) {
 			start = (start + 0x3ff) & ~0x3ff;
@@ -167,7 +167,7 @@
 			else
 				disabled = !(command & PCI_COMMAND_MEMORY);
 			if (pass == disabled) {
-				DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
+				DBG("PCI: Resource %016Lx-%016Lx (f=%Lx, d=%d, p=%d)\n",
 				    r->start, r->end, r->flags, disabled, pass);
 				pr = pci_find_parent_resource(dev, r);
 				if (!pr || request_resource(pr, r) < 0) {
arch/ia64/pci/pci.c +3 -2
diff -Nru a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
@@ -151,7 +151,8 @@
 pcibios_update_resource (struct pci_dev *dev, struct resource *root,
 			 struct resource *res, int resource)
 {
-	unsigned long where, size;
+	unsigned long where
+	u64 size;
 	u32 reg;
 
 	where = PCI_BASE_ADDRESS_0 + (resource * 4);
@@ -229,7 +230,7 @@
 
 void
 pcibios_align_resource (void *data, struct resource *res,
-		        unsigned long size, unsigned long align)
+		        u64 size, u64 align)
 {
 }
 
arch/mips/ddb5074/pci.c +2 -2
diff -Nru a/arch/mips/ddb5074/pci.c b/arch/mips/ddb5074/pci.c
@@ -373,12 +373,12 @@
 }
 
 void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
+			    u64 size, u64 align)
 {
 	struct pci_dev *dev = data;
 
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		/* We need to avoid collisions with `mirrored' VGA ports
 		   and other strange ISA hardware, so we always want the
arch/mips/ddb5476/pci.c +2 -2
diff -Nru a/arch/mips/ddb5476/pci.c b/arch/mips/ddb5476/pci.c
@@ -431,12 +431,12 @@
 }
 
 void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
+			    u64 size, u64 align)
 {
 	struct pci_dev *dev = data;
 
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		/* We need to avoid collisions with `mirrored' VGA ports
 		   and other strange ISA hardware, so we always want the
arch/mips/ddb5xxx/common/pci.c +1 -1
diff -Nru a/arch/mips/ddb5xxx/common/pci.c b/arch/mips/ddb5xxx/common/pci.c
@@ -165,7 +165,7 @@
 
 void
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 	/* this should not be called */
 	MIPS_ASSERT(1 == 0);
arch/mips/gt64120/common/pci.c +2 -2
diff -Nru a/arch/mips/gt64120/common/pci.c b/arch/mips/gt64120/common/pci.c
@@ -819,12 +819,12 @@
 }
 
 void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
+			    u64 size, u64 align)
 {
 	struct pci_dev *dev = data;
 
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		/* We need to avoid collisions with `mirrored' VGA ports
 		   and other strange ISA hardware, so we always want the
arch/mips/ite-boards/generic/it8172_pci.c +1 -1
diff -Nru a/arch/mips/ite-boards/generic/it8172_pci.c b/arch/mips/ite-boards/generic/it8172_pci.c
@@ -183,7 +183,7 @@
 
 void __init
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
     printk("pcibios_align_resource\n");
 }
arch/mips/kernel/pci.c +1 -1
diff -Nru a/arch/mips/kernel/pci.c b/arch/mips/kernel/pci.c
@@ -162,7 +162,7 @@
 
 void
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 	/* this should not be called */
 }
arch/mips/mips-boards/generic/pci.c +1 -1
diff -Nru a/arch/mips/mips-boards/generic/pci.c b/arch/mips/mips-boards/generic/pci.c
@@ -232,7 +232,7 @@
 
 void __init
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 }
 
arch/mips/sni/pci.c +1 -1
diff -Nru a/arch/mips/sni/pci.c b/arch/mips/sni/pci.c
@@ -180,7 +180,7 @@
 
 void __init
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 }
 
arch/mips64/mips-boards/generic/pci.c +1 -1
diff -Nru a/arch/mips64/mips-boards/generic/pci.c b/arch/mips64/mips-boards/generic/pci.c
@@ -291,7 +291,7 @@
 
 void __init
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 }
 
arch/mips64/sgi-ip27/ip27-pci.c +1 -1
diff -Nru a/arch/mips64/sgi-ip27/ip27-pci.c b/arch/mips64/sgi-ip27/ip27-pci.c
@@ -249,7 +249,7 @@
 
 void __init
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 }
 
arch/mips64/sgi-ip32/ip32-pci.c +1 -1
diff -Nru a/arch/mips64/sgi-ip32/ip32-pci.c b/arch/mips64/sgi-ip32/ip32-pci.c
@@ -329,7 +329,7 @@
 }
 
 void __init pcibios_align_resource (void *data, struct resource *res,
-				    unsigned long size, unsigned long align)
+				    u64 size, u64 align)
 {
 }
 
arch/parisc/kernel/pci.c +3 -3
diff -Nru a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
@@ -392,11 +392,11 @@
 */
 void __devinit
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long alignment)
+		       u64 size, u64 alignment)
 {
-	unsigned long mask, align;
+	u64 mask, align;
 
-	DBG_RES("pcibios_align_resource(%s, (%p) [%lx,%lx]/%x, 0x%lx, 0x%lx)\n",
+	DBG_RES("pcibios_align_resource(%s, (%p) [%Lx,%Lx]/%Lx, 0x%Lx, 0x%Lx)\n",
 		((struct pci_dev *) data)->slot_name,
 		res->parent, res->start, res->end,
 		(int) res->flags, size, alignment);
arch/ppc/kernel/pci.c +16 -15
diff -Nru a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
@@ -128,7 +128,7 @@
 		       "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
 		       new, check);
 	}
-	printk(KERN_INFO "PCI: moved device %s resource %d (%lx) to %x\n",
+	printk(KERN_INFO "PCI: moved device %s resource %d (%Lx) to %x\n",
 	       dev->slot_name, resource, res->flags,
 	       new & ~PCI_REGION_FLAG_MASK);
 }
@@ -149,7 +149,7 @@
 		if (!res->flags)
 			continue;
 		if (!res->start || res->end == 0xffffffff) {
-			DBG("PCI:%s Resource %d [%08lx-%08lx] is unassigned\n",
+			DBG("PCI:%s Resource %d [%016Lx-%016Lx] is unassigned\n",
 			    dev->slot_name, i, res->start, res->end);
 			res->end -= res->start;
 			res->start = 0;
@@ -167,7 +167,7 @@
 			res->start += offset;
 			res->end += offset;
 #ifdef DEBUG
-			printk("Fixup res %d (%lx) of dev %s: %lx -> %lx\n",
+			printk("Fixup res %d (%Lx) of dev %s: %Lx -> %Lx\n",
 			       i, res->flags, dev->slot_name,
 			       res->start - offset, res->start);
 #endif
@@ -230,17 +230,17 @@
  * which might have be mirrored at 0x0100-0x03ff..
  */
 void
-pcibios_align_resource(void *data, struct resource *res, unsigned long size,
-		       unsigned long align)
+pcibios_align_resource(void *data, struct resource *res, u64 size,
+		       u64 align)
 {
 	struct pci_dev *dev = data;
 
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		if (size > 0x100) {
-			printk(KERN_ERR "PCI: I/O Region %s/%d too large"
-			       " (%ld bytes)\n", dev->slot_name,
+			printk(KERN_ERR "PCI: I/O Region %s/%Ld too large"
+			       " (%Ld bytes)\n", dev->slot_name,
 			       dev->resource - res, size);
 		}
 
@@ -314,7 +314,7 @@
 				}
 			}
 
-			DBG("PCI: bridge rsrc %lx..%lx (%lx), parent %p\n",
+			DBG("PCI: bridge rsrc %Lx..%Lx (%Lx), parent %p\n",
 			    res->start, res->end, res->flags, pr);
 			if (pr) {
 				if (request_resource(pr, res) == 0)
@@ -419,12 +419,12 @@
 		try = conflict->start - 1;
 	}
 	if (request_resource(pr, res)) {
-		DBG(KERN_ERR "PCI: huh? couldn't move to %lx..%lx\n",
+		DBG(KERN_ERR "PCI: huh? couldn't move to %Lx..%Lx\n",
 		    res->start, res->end);
 		return -1;		/* "can't happen" */
 	}
 	update_bridge_base(bus, i);
-	printk(KERN_INFO "PCI: bridge %d resource %d moved to %lx..%lx\n",
+	printk(KERN_INFO "PCI: bridge %d resource %d moved to %Lx..%Lx\n",
 	       bus->number, i, res->start, res->end);
 	return 0;
 }
@@ -485,7 +485,8 @@
 	u8 io_base_lo, io_limit_lo;
 	u16 mem_base, mem_limit;
 	u16 cmd;
-	unsigned long start, end, off;
+	u64 start, end;
+	unsigned long off;
 	struct pci_dev *dev = bus->self;
 	struct pci_controller *hose = dev->sysdata;
 
@@ -530,7 +531,7 @@
 		pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, mem_limit);
 
 	} else {
-		DBG(KERN_ERR "PCI: ugh, bridge %s res %d has flags=%lx\n",
+		DBG(KERN_ERR "PCI: ugh, bridge %s res %d has flags=%Lx\n",
 		    dev->slot_name, i, res->flags);
 	}
 	pci_write_config_word(dev, PCI_COMMAND, cmd);
@@ -540,14 +541,14 @@
 {
 	struct resource *pr, *r = &dev->resource[idx];
 
-	DBG("PCI:%s: Resource %d: %08lx-%08lx (f=%lx)\n",
+	DBG("PCI:%s: Resource %d: %016Lx-%016Lx (f=%Lx)\n",
 	    dev->slot_name, idx, r->start, r->end, r->flags);
 	pr = pci_find_parent_resource(dev, r);
 	if (!pr || request_resource(pr, r) < 0) {
 		printk(KERN_ERR "PCI: Cannot allocate resource region %d"
 		       " of device %s\n", idx, dev->slot_name);
 		if (pr)
-			DBG("PCI:  parent is %p: %08lx-%08lx (f=%lx)\n",
+			DBG("PCI:  parent is %p: %016Lx-%016Lx (f=%Lx)\n",
 			    pr, pr->start, pr->end, pr->flags);
 		/* We'll assign a new address later */
 		r->flags |= IORESOURCE_UNSET;
arch/ppc64/kernel/pci.c +3 -3
diff -Nru a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
@@ -178,15 +178,15 @@
  */
 void
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 	struct pci_dev *dev = data;
 
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		if (size > 0x100) {
-			printk(KERN_ERR "PCI: Can not align I/O Region %s %s because size %ld is too large.\n",
+			printk(KERN_ERR "PCI: Can not align I/O Region %s %s because size %Ld is too large.\n",
                                         dev->slot_name, res->name, size);
 		}
 
arch/sh/kernel/pcibios.c +2 -2
diff -Nru a/arch/sh/kernel/pcibios.c b/arch/sh/kernel/pcibios.c
@@ -61,10 +61,10 @@
  * modulo 0x400.
  */
 void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
+			    u64 size, u64 align)
 {
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		if (start & 0x300) {
 			start = (start + 0x3ff) & ~0x3ff;
arch/sparc/kernel/pcic.c +1 -1
diff -Nru a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
@@ -861,7 +861,7 @@
 }
 
 void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
+			    u64 size, u64 align)
 {
 }
 
arch/sparc64/kernel/pci.c +1 -1
diff -Nru a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
@@ -485,7 +485,7 @@
 }
 
 void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
+			    u64 size, u64 align)
 {
 }
 
arch/sparc64/kernel/pci_common.c +2 -2
diff -Nru a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c
@@ -270,7 +270,7 @@
 			    ap->phys_hi, ap->phys_mid, ap->phys_lo,
 			    ap->size_hi, ap->size_lo);
 	if (res)
-		prom_printf("PCI: RES[%016lx-->%016lx:(%lx)]\n",
+		prom_printf("PCI: RES[%016lx-->%016lx:(%Lx)]\n",
 			    res->start, res->end, res->flags);
 	prom_printf("Please email this information to [email protected]\n");
 	if (do_prom_halt)
@@ -403,7 +403,7 @@
 			 */
 			if ((res->start >> 32) != 0UL) {
 				printk(KERN_ERR "PCI: OBP assigns out of range MEM address "
-				       "%016lx for region %ld on device %s\n",
+				       "%016Lx for region %ld on device %s\n",
 				       res->start, (res - &pdev->resource[0]), pdev->dev.name);
 				continue;
 			}
arch/v850/kernel/rte_mb_a_pci.c +1 -1
diff -Nru a/arch/v850/kernel/rte_mb_a_pci.c b/arch/v850/kernel/rte_mb_a_pci.c
@@ -339,7 +339,7 @@
 
 void
 pcibios_align_resource (void *data, struct resource *res,
-			unsigned long size, unsigned long align)
+			u64 size, u64 align)
 {
 }
 
arch/x86_64/pci/x86-64.c +3 -3
diff -Nru a/arch/x86_64/pci/x86-64.c b/arch/x86_64/pci/x86-64.c
@@ -76,10 +76,10 @@
  */
 void
 pcibios_align_resource(void *data, struct resource *res,
-		       unsigned long size, unsigned long align)
+		       u64 size, u64 align)
 {
 	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
+		u64 start = res->start;
 
 		if (start & 0x300) {
 			start = (start + 0x3ff) & ~0x3ff;
@@ -167,7 +167,7 @@
 			else
 				disabled = !(command & PCI_COMMAND_MEMORY);
 			if (pass == disabled) {
-				DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
+				DBG("PCI: Resource %016Lx-%016Lx (f=%Lx, d=%d, p=%d)\n",
 				    r->start, r->end, r->flags, disabled, pass);
 				pr = pci_find_parent_resource(dev, r);
 				if (!pr || request_resource(pr, r) < 0) {
drivers/ide/pci/aec62xx.c +1 -1
diff -Nru a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
@@ -413,7 +413,7 @@
 
 	if (dev->resource[PCI_ROM_RESOURCE].start) {
 		pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
-		printk("%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
+		printk("%s: ROM enabled at 0x%016Lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
 	}
 
 #if defined(DISPLAY_AEC62XX_TIMINGS) && defined(CONFIG_PROC_FS)
drivers/ide/pci/cmd64x.c +1 -1
diff -Nru a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
@@ -606,7 +606,7 @@
 #ifdef __i386__
 	if (dev->resource[PCI_ROM_RESOURCE].start) {
 		pci_write_config_byte(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
-		printk("%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
+		printk("%s: ROM enabled at 0x%016Lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
 	}
 #endif
 
drivers/ide/pci/hpt34x.c +1 -1
diff -Nru a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
@@ -249,7 +249,7 @@
 		if (pci_resource_start(dev, PCI_ROM_RESOURCE)) {
 			pci_write_config_byte(dev, PCI_ROM_ADDRESS,
 				dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
-			printk(KERN_INFO "HPT345: ROM enabled at 0x%08lx\n",
+			printk(KERN_INFO "HPT345: ROM enabled at 0x%016Lx\n",
 				dev->resource[PCI_ROM_RESOURCE].start);
 		}
 		pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0);
drivers/ide/pci/pdc202xx_new.c +1 -1
diff -Nru a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
@@ -538,7 +538,7 @@
 	if (dev->resource[PCI_ROM_RESOURCE].start) {
 		pci_write_config_dword(dev, PCI_ROM_ADDRESS,
 			dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
-		printk("%s: ROM enabled at 0x%08lx\n",
+		printk("%s: ROM enabled at 0x%016Lx\n",
 			name, dev->resource[PCI_ROM_RESOURCE].start);
 	}
 
drivers/ide/pci/pdc202xx_old.c +1 -1
diff -Nru a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
@@ -718,7 +718,7 @@
 	if (dev->resource[PCI_ROM_RESOURCE].start) {
 		pci_write_config_dword(dev, PCI_ROM_ADDRESS,
 			dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
-		printk("%s: ROM enabled at 0x%08lx\n",
+		printk("%s: ROM enabled at 0x%016Lx\n",
 			name, dev->resource[PCI_ROM_RESOURCE].start);
 	}
 
drivers/net/e100/e100_main.c +1 -1
diff -Nru a/drivers/net/e100/e100_main.c b/drivers/net/e100/e100_main.c
@@ -2986,7 +2986,7 @@
 	bdp->scb = (scb_t *) ioremap_nocache(dev->mem_start, sizeof (scb_t));
 
 	if (!bdp->scb) {
-		printk(KERN_ERR "e100: %s: Failed to map PCI address 0x%lX\n",
+		printk(KERN_ERR "e100: %s: Failed to map PCI address 0x%LX\n",
 		       dev->name, pci_resource_start(pcid, 0));
 		rc = -ENOMEM;
 		goto err_region;
drivers/net/eepro100.c +2 -2
diff -Nru a/drivers/net/eepro100.c b/drivers/net/eepro100.c
@@ -621,12 +621,12 @@
 	ioaddr = (unsigned long)ioremap(pci_resource_start(pdev, 0),
 									pci_resource_len(pdev, 0));
 	if (!ioaddr) {
-		printk (KERN_ERR "eepro100: cannot remap MMIO region %lx @ %lx\n",
+		printk (KERN_ERR "eepro100: cannot remap MMIO region %Lx @ %Lx\n",
 				pci_resource_len(pdev, 0), pci_resource_start(pdev, 0));
 		goto err_out_free_mmio_region;
 	}
 	if (DEBUG & NETIF_MSG_PROBE)
-		printk("Found Intel i82557 PCI Speedo, MMIO at %#lx, IRQ %d.\n",
+		printk("Found Intel i82557 PCI Speedo, MMIO at %#Lx, IRQ %d.\n",
 			   pci_resource_start(pdev, 0), irq);
 #endif
 
drivers/net/tc35815.c +1 -1
diff -Nru a/drivers/net/tc35815.c b/drivers/net/tc35815.c
@@ -499,7 +499,7 @@
 
 	        pci_memaddr = pci_resource_start (pdev, 1);
 
-	        printk(KERN_INFO "    pci_memaddr=%#08lx  resource_flags=%#08lx\n", pci_memaddr, pci_resource_flags (pdev, 0));
+	        printk(KERN_INFO "    pci_memaddr=%#016Lx  resource_flags=%#016Lx\n", pci_memaddr, pci_resource_flags (pdev, 0));
 
 		if (!pci_memaddr) {
 			printk(KERN_WARNING "no PCI MEM resources, aborting\n");
drivers/net/tulip/tulip_core.c +1 -1
diff -Nru a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
@@ -1361,7 +1361,7 @@
 	}
 
 	if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) {
-		printk (KERN_ERR PFX "%s: I/O region (0x%lx@0x%lx) too small, "
+		printk (KERN_ERR PFX "%s: I/O region (0x%Lx@0x%Lx) too small, "
 			"aborting\n", pdev->slot_name,
 			pci_resource_len (pdev, 0),
 			pci_resource_start (pdev, 0));
drivers/parisc/ccio-dma.c +1 -1
diff -Nru a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
@@ -1438,7 +1438,7 @@
 	res->name = name;
 	result = request_resource(&iomem_resource, res);
 	if (result < 0) {
-		printk(KERN_ERR "%s: failed to claim CCIO bus address space (%08lx,%08lx)\n", 
+		printk(KERN_ERR "%s: failed to claim CCIO bus address space (%016Lx,%016Lx)\n", 
 		       __FILE__, res->start, res->end);
 	}
 }
drivers/pci/pci.c +2 -2
diff -Nru a/drivers/pci/pci.c b/drivers/pci/pci.c
@@ -500,7 +500,7 @@
 	return 0;
 
 err_out:
-	printk (KERN_WARNING "PCI: Unable to reserve %s region #%d:%lx@%lx for device %s\n",
+	printk (KERN_WARNING "PCI: Unable to reserve %s region #%d:%Lx@%Lx for device %s\n",
 		pci_resource_flags(pdev, bar) & IORESOURCE_IO ? "I/O" : "mem",
 		bar + 1, /* PCI BAR # */
 		pci_resource_len(pdev, bar), pci_resource_start(pdev, bar),
@@ -549,7 +549,7 @@
 	return 0;
 
 err_out:
-	printk (KERN_WARNING "PCI: Unable to reserve %s region #%d:%lx@%lx for device %s\n",
+	printk (KERN_WARNING "PCI: Unable to reserve %s region #%d:%Lx@%Lx for device %s\n",
 		pci_resource_flags(pdev, i) & IORESOURCE_IO ? "I/O" : "mem",
 		i + 1, /* PCI BAR # */
 		pci_resource_len(pdev, i), pci_resource_start(pdev, i),
drivers/pci/proc.c +1 -5
diff -Nru a/drivers/pci/proc.c b/drivers/pci/proc.c
@@ -299,11 +299,7 @@
 #endif /* HAVE_PCI_MMAP */
 };
 
-#if BITS_PER_LONG == 32
-#define LONG_FORMAT "\t%08lx"
-#else
-#define LONG_FORMAT "\t%16lx"
-#endif
+#define LONG_FORMAT "\t%016Lx"
 
 /* iterator */
 static void *pci_seq_start(struct seq_file *m, loff_t *pos)
drivers/pci/setup-res.c +8 -8
diff -Nru a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
@@ -46,7 +46,7 @@
 		err = request_resource(root, res);
 
 	if (err) {
-		printk(KERN_ERR "PCI: %s region %d of %s %s [%lx:%lx]\n",
+		printk(KERN_ERR "PCI: %s region %d of %s %s [%Lx:%Lx]\n",
 		       root ? "Address space collision on" :
 			      "No parent found for",
 		       resource, dtype, dev->slot_name, res->start, res->end);
@@ -63,12 +63,12 @@
 static int pci_assign_bus_resource(const struct pci_bus *bus,
 	struct pci_dev *dev,
 	struct resource *res,
-	unsigned long size,
-	unsigned long min,
-	unsigned int type_mask,
+	u64 size,
+	u64 min,
+	u64 type_mask,
 	int resno)
 {
-	unsigned long align;
+	u64 align;
 	int i;
 
 	type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
@@ -123,13 +123,13 @@
 		 * window (it will just not perform as well).
 		 */
 		if (!(res->flags & IORESOURCE_PREFETCH) || pci_assign_bus_resource(bus, dev, res, size, min, 0, i) < 0) {
-			printk(KERN_ERR "PCI: Failed to allocate resource %d(%lx-%lx) for %s\n",
+			printk(KERN_ERR "PCI: Failed to allocate resource %d(%Lx-%Lx) for %s\n",
 			       i, res->start, res->end, dev->slot_name);
 			return -EBUSY;
 		}
 	}
 
-	DBGC((KERN_ERR "  got res[%lx:%lx] for resource %d of %s\n", res->start,
+	DBGC((KERN_ERR "  got res[%Lx:%Lx] for resource %d of %s\n", res->start,
 						res->end, i, dev->dev.name));
 
 	return 0;
@@ -153,7 +153,7 @@
 			continue;
 		if (!r_align) {
 			printk(KERN_WARNING "PCI: Ignore bogus resource %d "
-					    "[%lx:%lx] of %s\n",
+					    "[%Lx:%Lx] of %s\n",
 					    i, r->start, r->end, dev->dev.name);
 			continue;
 		}
drivers/video/clgenfb.c +1 -1
diff -Nru a/drivers/video/clgenfb.c b/drivers/video/clgenfb.c
@@ -2690,7 +2690,7 @@
 		info->fbmem_phys = board_addr + 16777216;
 		info->fbmem = ioremap (info->fbmem_phys, 16777216);
 	} else {
-		printk (" REG at $%lx\n", (unsigned long) z2->resource.start);
+		printk (" REG at $%Lx\n", (unsigned long) z2->resource.start);
 
 		info->fbmem_phys = board_addr;
 		if (board_addr > 0x01000000)
include/linux/ioport.h +28 -25

91 lines not on this page · raw message

include/linux/pci.h +1 -1
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -511,7 +511,7 @@
 
 /* Used only when drivers/pci/setup.c is used */
 void pcibios_align_resource(void *, struct resource *,
-			    unsigned long, unsigned long);
+			    u64, u64);
 void pcibios_update_resource(struct pci_dev *, struct resource *,
 			     struct resource *, int);
 void pcibios_update_irq(struct pci_dev *, int irq);
kernel/resource.c +20 -20
diff -Nru a/kernel/resource.c b/kernel/resource.c
@@ -16,7 +16,7 @@
 #include <asm/io.h>
 
 struct resource ioport_resource = { "PCI IO", 0x0000, IO_SPACE_LIMIT, IORESOURCE_IO };
-struct resource iomem_resource = { "PCI mem", 0x00000000, 0xffffffff, IORESOURCE_MEM };
+struct resource iomem_resource = { "PCI mem", 0x0000000000000000, 0xffffffffffffffff, IORESOURCE_MEM };
 
 static rwlock_t resource_lock = RW_LOCK_UNLOCKED;
 
@@ -30,7 +30,7 @@
 
 	while (entry) {
 		const char *name = entry->name;
-		unsigned long from, to;
+		u64 from, to;
 
 		if ((int) (end-buf) < 80)
 			return buf;
@@ -39,7 +39,7 @@
 		to = entry->end;
 		if (!name)
 			name = "<BAD>";
-
+		
 		buf += sprintf(buf, fmt + offset, from, to, name);
 		if (entry->child)
 			buf = do_resource_list(entry->child, fmt, offset-2, buf, end);
@@ -54,9 +54,9 @@
 	char *fmt;
 	int retval;
 
-	fmt = "        %08lx-%08lx : %s\n";
+	fmt = "        %016Lx-%016Lx : %s\n";
 	if (root->end < 0x10000)
-		fmt = "        %04lx-%04lx : %s\n";
+		fmt = "        %04Lx-%04Lx : %s\n";
 	read_lock(&resource_lock);
 	retval = do_resource_list(root->child, fmt, 8, buf, buf + size) - buf;
 	read_unlock(&resource_lock);
@@ -66,8 +66,8 @@
 /* Return the conflict entry if you can't request it */
 static struct resource * __request_resource(struct resource *root, struct resource *new)
 {
-	unsigned long start = new->start;
-	unsigned long end = new->end;
+	u64 start = new->start;
+	u64 end = new->end;
 	struct resource *tmp, **p;
 
 	if (end < start)
@@ -135,11 +135,11 @@
  * Find empty slot in the resource tree given range and alignment.
  */
 static int find_resource(struct resource *root, struct resource *new,
-			 unsigned long size,
-			 unsigned long min, unsigned long max,
-			 unsigned long align,
+			 u64 size,
+			 u64 min, u64 max,
+			 u64 align,
 			 void (*alignf)(void *, struct resource *,
-					unsigned long, unsigned long),
+					u64, u64),
 			 void *alignf_data)
 {
 	struct resource *this = root->child;
@@ -173,11 +173,11 @@
  * Allocate empty slot in the resource tree given range and alignment.
  */
 int allocate_resource(struct resource *root, struct resource *new,
-		      unsigned long size,
-		      unsigned long min, unsigned long max,
-		      unsigned long align,
+		      u64 size,
+		      u64 min, u64 max,
+		      u64 align,
 		      void (*alignf)(void *, struct resource *,
-				     unsigned long, unsigned long),
+				     u64, u64),
 		      void *alignf_data)
 {
 	int err;
@@ -202,7 +202,7 @@
  *
  * Release-region releases a matching busy region.
  */
-struct resource * __request_region(struct resource *parent, unsigned long start, unsigned long n, const char *name)
+struct resource * __request_region(struct resource *parent, u64 start, u64 n, const char *name)
 {
 	struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL);
 
@@ -237,7 +237,7 @@
 	return res;
 }
 
-int __check_region(struct resource *parent, unsigned long start, unsigned long n)
+int __check_region(struct resource *parent, u64 start, u64 n)
 {
 	struct resource * res;
 
@@ -250,10 +250,10 @@
 	return 0;
 }
 
-void __release_region(struct resource *parent, unsigned long start, unsigned long n)
+void __release_region(struct resource *parent, u64 start, u64 n)
 {
 	struct resource **p;
-	unsigned long end;
+	u64 end;
 
 	p = &parent->child;
 	end = start + n - 1;
@@ -276,7 +276,7 @@
 		}
 		p = &res->sibling;
 	}
-	printk(KERN_WARNING "Trying to free nonexistent resource <%08lx-%08lx>\n", start, end);
+	printk(KERN_WARNING "Trying to free nonexistent resource <%016Lx-%016Lx>\n", start, end);
 }
 
 /*
#1 lore raw
Quoted 10 lines · Dave Hansen

We need some way to replicate the e820 tables for kexec. This modifies struct resource to use u64's for its start and end fields. This way we can export the whole e820 table on PAE machines.

resource->flags seems to be used often to mask out things in resource->start/end, so I think it needs to be u64 too. But, Is it all right to let things like pcibios_update_resource() truncate the resource addresses like they do?

With my config, it has no more warnings than it did before.

I could make use of this on my PPC440 systems which have all I/O (onboard and PCIX host bridge) above 4GB. However, the patch I have been playing with typedefs a phys_addr_t so that only systems which are 32-bit/36-bit+ split like PAE ia32, AUxxxx (MIPS), and PPC440 have to do long long manipulation. If you explicitly use u64 everywhere it forces all native 32-bit/32-bit systems to do unnecessary long long manipulation.

In the past there has been quite a bit of resistance to even introducing a physical address typedef due to some claims of gcc not handling long longs very well [1]. I don't see how having _everybody_ that is 32-bit native handle long longs is going to be more acceptable but I could be surprised.

That said, I think when we have existence of systems that require long long types and gcc is "buggy" in this respect, then using a phys_addr_t is the lesser of two evils (even though everybody hates typedefs). We already have this type defined local to PPC because it is necessary to cleanly handle ioremap and local page mapping functionality. going to u64 or phys_addr_t resources would be a huge improvement on a horribly kludgy hack we use to crate the most significant 32-bits for our 64-bit ioremaps.

BTW, since u64 is long long on 32-bit platforms and long on 64-bit platforms, you will get warnings from every printk that dumps resource infos. My thought is to provide some macros to massage resource values to strings for display.

[1] I get feedback from many people using the PPC440 port and have yet to find any instances of gcc mishandling long longs. (though this is just anecdotal evidence).

Regards,

Signature · 3 lines
Matt Porter
[email protected]
This is Linux Country. On a quiet night, you can hear Windows reboot.
#2 lore raw
Quoted 12 lines · Matt Porter
Quoted 10 lines · Dave Hansen

We need some way to replicate the e820 tables for kexec. This modifies struct resource to use u64's for its start and end fields. This way we can export the whole e820 table on PAE machines.

resource->flags seems to be used often to mask out things in resource->start/end, so I think it needs to be u64 too. But, Is it all right to let things like pcibios_update_resource() truncate the resource addresses like they do?

With my config, it has no more warnings than it did before.

Quoted 7 lines

I could make use of this on my PPC440 systems which have all I/O (onboard and PCIX host bridge) above 4GB. However, the patch I have been playing with typedefs a phys_addr_t so that only systems which are 32-bit/36-bit+ split like PAE ia32, AUxxxx (MIPS), and PPC440 have to do long long manipulation. If you explicitly use u64 everywhere it forces all native 32-bit/32-bit systems to do unnecessary long long manipulation.

Except for the fact that if you have a 32bit pci bus, you can plug in cards with 64bit bars. And they can still legitimately do 64bit DAC to other pci cards. It is a silly configuration, but possible.

Quoted 5 lines

In the past there has been quite a bit of resistance to even introducing a physical address typedef due to some claims of gcc not handling long longs very well [1]. I don't see how having _everybody_ that is 32-bit native handle long longs is going to be more acceptable but I could be surprised.

The primary concern has been efficiency and I do believe there is anywhere the pci resource allocator is on the fast path, so that should not be a problem.

There are some rare bugs with 2.95.2 and kin with handling long longs but all it has been possible to reformulate the C code so it works in all cases where the bugs have been observed.

And beyond that it was Linus idea to bring the resource allocator to 64bits which tends to help.

Quoted 8 lines

That said, I think when we have existence of systems that require long long types and gcc is "buggy" in this respect, then using a phys_addr_t is the lesser of two evils (even though everybody hates typedefs). We already have this type defined local to PPC because it is necessary to cleanly handle ioremap and local page mapping functionality. going to u64 or phys_addr_t resources would be a huge improvement on a horribly kludgy hack we use to crate the most significant 32-bits for our 64-bit ioremaps.

A phys_addr_t may be a sane idea, or in this case it would need to be a res_addr_t.

Quoted 9 lines

BTW, since u64 is long long on 32-bit platforms and long on 64-bit platforms, you will get warnings from every printk that dumps resource infos. My thought is to provide some macros to massage resource values to strings for display.

[1] I get feedback from many people using the PPC440 port and have yet to find any instances of gcc mishandling long longs. (though this is just anecdotal evidence).

I have written code that trips it up, but I believe the bugs have been fixed in recent compilers, and the bugs (not the inefficiencies) may be specific to a specific port.

Eric

#3 lore raw
Quoted 22 lines · Eric W. Biederman
Quoted 12 lines · Matt Porter
Quoted 10 lines · Dave Hansen

We need some way to replicate the e820 tables for kexec. This modifies struct resource to use u64's for its start and end fields. This way we can export the whole e820 table on PAE machines.

resource->flags seems to be used often to mask out things in resource->start/end, so I think it needs to be u64 too. But, Is it all right to let things like pcibios_update_resource() truncate the resource addresses like they do?

With my config, it has no more warnings than it did before.

Quoted 7 lines

I could make use of this on my PPC440 systems which have all I/O (onboard and PCIX host bridge) above 4GB. However, the patch I have been playing with typedefs a phys_addr_t so that only systems which are 32-bit/36-bit+ split like PAE ia32, AUxxxx (MIPS), and PPC440 have to do long long manipulation. If you explicitly use u64 everywhere it forces all native 32-bit/32-bit systems to do unnecessary long long manipulation.

Quoted 4 lines

Except for the fact that if you have a 32bit pci bus, you can plug in cards with 64bit bars. And they can still legitimately do 64bit DAC to other pci cards. It is a silly configuration, but possible.

Erm, ok. Silly is right, but possible.

Quoted 10 lines
Quoted 5 lines

In the past there has been quite a bit of resistance to even introducing a physical address typedef due to some claims of gcc not handling long longs very well [1]. I don't see how having _everybody_ that is 32-bit native handle long longs is going to be more acceptable but I could be surprised.

The primary concern has been efficiency and I do believe there is anywhere the pci resource allocator is on the fast path, so that should not be a problem.

Quoted 6 lines

There are some rare bugs with 2.95.2 and kin with handling long longs but all it has been possible to reformulate the C code so it works in all cases where the bugs have been observed.

And beyond that it was Linus idea to bring the resource allocator to 64bits which tends to help.

Ok, good. Then that should include bringing all related interfaces to 64bits as well? Like remap_page_range(), since we want to handle this easily on bigphys systems with I/O above 4GB instead of some of our current hacks.

Quoted 11 lines
Quoted 8 lines

That said, I think when we have existence of systems that require long long types and gcc is "buggy" in this respect, then using a phys_addr_t is the lesser of two evils (even though everybody hates typedefs). We already have this type defined local to PPC because it is necessary to cleanly handle ioremap and local page mapping functionality. going to u64 or phys_addr_t resources would be a huge improvement on a horribly kludgy hack we use to crate the most significant 32-bits for our 64-bit ioremaps.

A phys_addr_t may be a sane idea, or in this case it would need to be a res_addr_t.

Sounds reasonable, I assume on some architectures that resources don't map directly to physical addresses as DaveM once explained a resource to merely be an ioremapable token (alpha?, sparc64?). We'll need to define a phys_addr_t to for the arguments to remap_page_range() but this is a tangential to the original discussion...sounds like we need both.

Quoted 3 lines

I have written code that trips it up, but I believe the bugs have been fixed in recent compilers, and the bugs (not the inefficiencies) may be specific to a specific port.

Ok, the past discussions seemed to be implying the existence of horrible bugs...sounds like gcc 3.x doesn't have these problems.

Regards,

Signature · 3 lines
Matt Porter
[email protected]
This is Linux Country. On a quiet night, you can hear Windows reboot.
#4 lore raw
In reply to Dave Hansen
Quoted 6 lines · Dave Hansen

We need some way to replicate the e820 tables for kexec. This modifies struct resource to use u64's for its start and end fields. This way we can export the whole e820 table on PAE machines.

resource->flags seems to be used often to mask out things in resource->start/end, so I think it needs to be u64 too.

I don't see this in the parts of the kernel your patch changes, I will have to look a little more and see if this is really true. If it is you probably should append ULL to the flag constants.

Quoted 4 lines

But, Is it all right to

let things like pcibios_update_resource() truncate the resource addresses like they do?

The type of addresses for resources will always be equal or larger than the resources they actually represent. Until someone modifies the pcibios_xxxx code to handle 64bit BARs it should only be truncation of zeros and thus safe.

I will see if I can scrutinize this carefully, and try it in the next little while. For now I am placing it on the back burner and going to bed. It looks like a good start though.

Eric