From vivek@in.ibm.com Thu Mar 23 12:00:14 2006 Date: Thu, 23 Mar 2006 14:59:44 -0500 From: Vivek Goyal Cc: Linus Torvalds , Morton Andrew Morton , "Eric W. Biederman" , galak@kernel.crashing.org, gregkh@suse.de, bcrl@kvack.org, Dave Jiang , arjan@infradead.org, Maneesh Soni , Murali Subject: [PATCH 1/10] PCI: 64 bit resources core changes Message-ID: <20060323195944.GE7175@in.ibm.com> Content-Disposition: inline o Core changes for 64bit resources. Changes start and end field to u64 from unsigned long. Signed-off-by: Dave Jiang Signed-off-by: Vivek Goyal Signed-off-by: Greg Kroah-Hartman --- include/linux/ioport.h | 23 ++++++++++++----------- kernel/resource.c | 48 +++++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 34 deletions(-) --- gregkh-2.6.orig/include/linux/ioport.h +++ gregkh-2.6/include/linux/ioport.h @@ -9,13 +9,14 @@ #define _LINUX_IOPORT_H #include +#include /* * Resources are tree-like, allowing * nesting etc.. */ struct resource { + u64 start, end; const char *name; - unsigned long start, end; unsigned long flags; struct resource *parent, *sibling, *child; }; @@ -96,31 +97,31 @@ extern struct resource * ____request_res extern int release_resource(struct resource *new); extern __deprecated_for_modules int insert_resource(struct resource *parent, struct resource *new); extern 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 adjust_resource(struct resource *res, unsigned long start, - unsigned long size); +int adjust_resource(struct resource *res, u64 start, + u64 size); /* Convenience shorthand with allocation */ #define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name)) #define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name)) #define rename_region(region, newname) do { (region)->name = (newname); } while (0) -extern struct resource * __request_region(struct resource *, unsigned long start, unsigned long n, const char *name); +extern struct resource * __request_region(struct resource *, u64 start, u64 n, const char *name); /* Compatibility cruft */ #define release_region(start,n) __release_region(&ioport_resource, (start), (n)) #define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n)) #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) -extern int __check_region(struct resource *, unsigned long, unsigned long); -extern void __release_region(struct resource *, unsigned long, unsigned long); +extern int __check_region(struct resource *, u64, u64); +extern void __release_region(struct resource *, u64, u64); -static inline int __deprecated check_region(unsigned long s, unsigned long n) +static inline int __deprecated check_region(u64 s, u64 n) { return __check_region(&ioport_resource, s, n); } --- gregkh-2.6.orig/kernel/resource.c +++ gregkh-2.6/kernel/resource.c @@ -23,7 +23,7 @@ struct resource ioport_resource = { .name = "PCI IO", - .start = 0x0000, + .start = 0x0000ULL, .end = IO_SPACE_LIMIT, .flags = IORESOURCE_IO, }; @@ -32,8 +32,8 @@ EXPORT_SYMBOL(ioport_resource); struct resource iomem_resource = { .name = "PCI mem", - .start = 0UL, - .end = ~0UL, + .start = 0ULL, + .end = ~0ULL, .flags = IORESOURCE_MEM, }; @@ -83,10 +83,10 @@ static int r_show(struct seq_file *m, vo for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent) if (p->parent == root) break; - seq_printf(m, "%*s%0*lx-%0*lx : %s\n", + seq_printf(m, "%*s%0*llx-%0*llx : %s\n", depth * 2, "", - width, r->start, - width, r->end, + width, (unsigned long long) r->start, + width, (unsigned long long) r->end, r->name ? r->name : ""); return 0; } @@ -151,8 +151,8 @@ __initcall(ioresources_init); /* 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) @@ -236,11 +236,11 @@ EXPORT_SYMBOL(release_resource); * 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; @@ -282,11 +282,11 @@ static int find_resource(struct resource * 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; @@ -378,10 +378,10 @@ EXPORT_SYMBOL(insert_resource); * arguments. Returns -EBUSY if it can't fit. Existing children of * the resource are assumed to be immutable. */ -int adjust_resource(struct resource *res, unsigned long start, unsigned long size) +int adjust_resource(struct resource *res, u64 start, u64 size) { struct resource *tmp, *parent = res->parent; - unsigned long end = start + size - 1; + u64 end = start + size - 1; int result = -EBUSY; write_lock(&resource_lock); @@ -428,7 +428,7 @@ EXPORT_SYMBOL(adjust_resource); * * 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 = kzalloc(sizeof(*res), GFP_KERNEL); @@ -464,7 +464,7 @@ struct resource * __request_region(struc EXPORT_SYMBOL(__request_region); -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; @@ -479,10 +479,10 @@ int __check_region(struct resource *pare EXPORT_SYMBOL(__check_region); -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; @@ -511,7 +511,9 @@ void __release_region(struct resource *p write_unlock(&resource_lock); - printk(KERN_WARNING "Trying to free nonexistent resource <%08lx-%08lx>\n", start, end); + printk(KERN_WARNING "Trying to free nonexistent resource " + "<%16llx-%16llx>\n", (unsigned long long)start, + (unsigned long long) end); } EXPORT_SYMBOL(__release_region);