Subject: [PATCH] : ! debug only ! - printk's in pci ressource handling From: Christian Ehrhardt This defines debug for pci and put's some printk's to keep track of the pci ressource handling. This patch is just for reference to understand the resulting boot message log. The patch is ugly - but for debugging only ;-) Signed-off-by: Christian Ehrhardt --- [diffstat] arch/powerpc/kernel/pci-common.c | 2 ++ arch/powerpc/mm/pgtable_32.c | 4 ++-- drivers/pci/bus.c | 3 +++ drivers/pci/setup-res.c | 12 ++++++++---- drivers/video/aty/radeon_base.c | 7 +++++++ drivers/video/aty/radeonfb.h | 4 ++-- kernel/resource.c | 17 ++++++++++++++++- 7 files changed, 40 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -37,6 +37,8 @@ #include #include #include + +#define DEBUG #ifdef DEBUG #include diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c @@ -183,8 +183,8 @@ __ioremap(phys_addr_t addr, unsigned lon * mem_init() sets high_memory so only do the check after that. */ if (mem_init_done && (p < virt_to_phys(high_memory))) { - printk("__ioremap(): phys addr 0x%llx is RAM lr %p\n", - (unsigned long long)p, __builtin_return_address(0)); + printk("__ioremap(): phys addr 0x%llx is RAM lr %p - mem_init_done %d highmem@%p\n", + (unsigned long long)p, __builtin_return_address(0), mem_init_done, virt_to_phys(high_memory)); return NULL; } diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -42,6 +42,8 @@ pci_bus_alloc_resource(struct pci_bus *b { int i, ret = -ENOMEM; +printk(KERN_ERR"%s - enter\n", __func__); + type_mask |= IORESOURCE_IO | IORESOURCE_MEM; for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { @@ -59,6 +61,7 @@ pci_bus_alloc_resource(struct pci_bus *b !(res->flags & IORESOURCE_PREFETCH)) continue; +printk(KERN_ERR"%s - call allocate ressource size %d startcalc %d, align %d\n", __func__, size, (r->start ? : min,-1), align); /* Ok, try it out.. */ ret = allocate_resource(r, res, size, r->start ? : min, diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -142,10 +142,13 @@ int pci_assign_resource(struct pci_dev * required alignment in the "start" field. */ align = (resno < PCI_BRIDGE_RESOURCES) ? size : res->start; +printk(KERN_ERR"%s - allocate with IORESOURCE_PREFETCH\n", __func__); + /* First, try exact prefetching match.. */ ret = pci_bus_alloc_resource(bus, res, size, align, min, IORESOURCE_PREFETCH, pcibios_align_resource, dev); + if (ret < 0 && (res->flags & IORESOURCE_PREFETCH)) { /* @@ -154,13 +157,14 @@ int pci_assign_resource(struct pci_dev * * But a prefetching area can handle a non-prefetching * window (it will just not perform as well). */ +printk(KERN_ERR"%s - second pci_bus_alloc_resource call\n", __func__); ret = pci_bus_alloc_resource(bus, res, size, align, min, 0, pcibios_align_resource, dev); } if (ret) { - printk(KERN_ERR "PCI: Failed to allocate %s resource " - "#%d:%llx@%llx for %s\n", + printk(KERN_ERR "PCI: %s - Failed to allocate %s resource " + "#%d:%llx@%llx for %s\n", __func__, res->flags & IORESOURCE_IO ? "I/O" : "mem", resno, (unsigned long long)size, (unsigned long long)res->start, pci_name(dev)); @@ -197,8 +201,8 @@ int pci_assign_resource_fixed(struct pci } if (ret) { - printk(KERN_ERR "PCI: Failed to allocate %s resource " - "#%d:%llx@%llx for %s\n", + printk(KERN_ERR "PCI: %s - Failed to allocate %s resource " + "#%d:%llx@%llx for %s\n", __func__, res->flags & IORESOURCE_IO ? "I/O" : "mem", resno, (unsigned long long)(res->end - res->start + 1), (unsigned long long)res->start, pci_name(dev)); diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c @@ -2160,6 +2160,10 @@ static int __devinit radeonfb_pci_regist int ret; RTRACE("radeonfb_pci_register BEGIN\n"); + +printk(KERN_ERR"%s - resource0 0x%0lx - 0x%0lx\n", __func__, pdev->resource[0].start, pdev->resource[0].end); +printk(KERN_ERR"%s - resource1 0x%0lx - 0x%0lx\n", __func__, pdev->resource[1].start, pdev->resource[1].end); +printk(KERN_ERR"%s - resource2 0x%0lx - 0x%0lx\n", __func__, pdev->resource[2].start, pdev->resource[2].end); /* Enable device in PCI config */ ret = pci_enable_device(pdev); @@ -2198,6 +2202,8 @@ static int __devinit radeonfb_pci_regist rinfo->fb_base_phys = pci_resource_start (pdev, 0); rinfo->mmio_base_phys = pci_resource_start (pdev, 2); +printk(KERN_ERR"%s - got pci ressources fb_base_phys 0x%0lx mmio_base_phys 0x%0lx\n", __func__,rinfo->fb_base_phys,rinfo->mmio_base_phys); + /* request the mem regions */ ret = pci_request_region(pdev, 0, "radeonfb framebuffer"); if (ret < 0) { @@ -2214,6 +2220,7 @@ static int __devinit radeonfb_pci_regist } /* map the regions */ +printk(KERN_ERR "%s - call ioremap for base %ld and size %d\n",__func__, rinfo->mmio_base_phys, RADEON_REGSIZE); rinfo->mmio_base = ioremap(rinfo->mmio_base_phys, RADEON_REGSIZE); if (!rinfo->mmio_base) { printk(KERN_ERR "radeonfb (%s): cannot map MMIO\n", diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h --- a/drivers/video/aty/radeonfb.h +++ b/drivers/video/aty/radeonfb.h @@ -287,8 +287,8 @@ struct radeonfb_info { char name[DEVICE_NAME_SIZE]; - unsigned long mmio_base_phys; - unsigned long fb_base_phys; + resource_size_t mmio_base_phys; + resource_size_t fb_base_phys; void __iomem *mmio_base; void __iomem *fb_base; diff --git a/kernel/resource.c b/kernel/resource.c --- a/kernel/resource.c +++ b/kernel/resource.c @@ -152,6 +152,9 @@ static struct resource * __request_resou resource_size_t end = new->end; struct resource *tmp, **p; +printk(KERN_ERR"%s - request %p name '%s' start 0x%0lx end 0x%0lx\n", + __func__, new, new->name, start, end); + if (end < start) return root; if (start < root->start) @@ -165,6 +168,7 @@ static struct resource * __request_resou new->sibling = tmp; *p = new; new->parent = root; +printk(KERN_ERR"%s - no conflict parent %p sibling %p\n",__func__, new->parent, new->sibling); return NULL; } p = &tmp->sibling; @@ -305,6 +309,8 @@ static int find_resource(struct resource { struct resource *this = root->child; +printk(KERN_ERR"%s - size %lx, min 0x%0lx, max 0x%0lx\n", __func__, size, min, max); + new->start = root->start; /* * Skip past an allocated resource that starts at 0, since the assignment @@ -328,10 +334,16 @@ static int find_resource(struct resource alignf(alignf_data, new, size, align); if (new->start < new->end && new->end - new->start >= size - 1) { new->end = new->start + size - 1; +printk(KERN_ERR"%s - found start 0x%0lx end 0x%0lx\n", __func__, new->start, new->end); return 0; } - if (!this) + if (!this) { +printk(KERN_ERR"%s - no this - exit\n", __func__); break; +} +else { +printk(KERN_ERR"%s - continue with start 0x%0lx on %p\n", __func__, (this->end + 1), this->sibling); +} new->start = this->end + 1; this = this->sibling; } @@ -385,6 +397,9 @@ int insert_resource(struct resource *par { int result; struct resource *first, *next; + +printk(KERN_ERR"%s - insert %p (start 0x%0lx end 0x%0lx) under parent %p\n", + __func__, new, new->start, new->end, parent); write_lock(&resource_lock);