From: Prarit Bhargava Signed-off-by: Andrew Morton --- 25-akpm/kernel/resource.c | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletion(-) diff -puN kernel/resource.c~debug-for-pci-io-mem-allocation kernel/resource.c --- 25/kernel/resource.c~debug-for-pci-io-mem-allocation 2005-03-21 22:03:41.000000000 -0800 +++ 25-akpm/kernel/resource.c 2005-03-21 22:03:41.000000000 -0800 @@ -20,6 +20,11 @@ #include #include +#if 0 +#define DEBUGP printk +#else +#define DEBUGP(fmt , a...) +#endif struct resource ioport_resource = { .name = "PCI IO", @@ -155,6 +160,9 @@ static struct resource * __request_resou unsigned long end = new->end; struct resource *tmp, **p; + DEBUGP("%s: %s resource request at 0x%lx-0x%lx\n", __FUNCTION__, + new->name, new->start, new->end); + if (end < start) return root; if (start < root->start) @@ -168,11 +176,15 @@ static struct resource * __request_resou new->sibling = tmp; *p = new; new->parent = root; + DEBUGP("%s: %s resource allocated\n", __FUNCTION__, + new->name); return NULL; } p = &tmp->sibling; if (tmp->end < start) continue; + DEBUGP("%s: %s resource conflicted with 0x%lx-0x%lx\n", + __FUNCTION__, new->name, tmp->start, tmp->end); return tmp; } } @@ -181,6 +193,8 @@ static int __release_resource(struct res { struct resource *tmp, **p; + DEBUGP("%s: %s resource release for 0x%lx-0x%lx\n", __FUNCTION__, + old->name, old->start, old->end); p = &old->parent->child; for (;;) { tmp = *p; @@ -189,10 +203,13 @@ static int __release_resource(struct res if (tmp == old) { *p = tmp->sibling; old->parent = NULL; + DEBUGP("%s: %s resource released\n", __FUNCTION__, + old->name); return 0; } p = &tmp->sibling; } + DEBUGP("%s: %s resource cannot be released\n", __FUNCTION__, old->name); return -EINVAL; } @@ -432,6 +449,8 @@ struct resource * __request_region(struc { struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL); + DEBUGP("%s: %s requesting region 0x%lx - 0x%lx\n", __FUNCTION__, + name, start, start + n - 1); if (res) { memset(res, 0, sizeof(*res)); res->name = name; @@ -445,8 +464,11 @@ struct resource * __request_region(struc struct resource *conflict; conflict = __request_resource(parent, res); - if (!conflict) + if (!conflict) { + DEBUGP("%s: %s region assigned\n", __FUNCTION__, + name); break; + } if (conflict != parent) { parent = conflict; if (!(conflict->flags & IORESOURCE_BUSY)) @@ -454,6 +476,8 @@ struct resource * __request_region(struc } /* Uhhuh, that didn't work out.. */ + DEBUGP("%s: %s request for region 0x%lx - 0x%lx fail\n", + __FUNCTION__, res->name, res->start, res->end); kfree(res); res = NULL; break; @@ -504,6 +528,8 @@ void __release_region(struct resource *p break; *p = res->sibling; write_unlock(&resource_lock); + DEBUGP("%s: %s releasing region 0x%lx - 0x%lx\n", + __FUNCTION__, res->name, res->start, res->end); kfree(res); return; } @@ -512,6 +538,9 @@ void __release_region(struct resource *p write_unlock(&resource_lock); + DEBUGP("%s: release regions 0x%lx - 0x%lx failed\n", __FUNCTION__, + start, end); + printk(KERN_WARNING "Trying to free nonexistent resource <%08lx-%08lx>\n", start, end); } _