[PATCH] x86: check hpet with BAR v2 insert some resources to resource tree forcily, so could avoid kernel update the resources in pci device. should check in device too. Signed-off-by: Yinghai Lu --- arch/x86/pci/i386.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) Index: linux-2.6/arch/x86/pci/i386.c =================================================================== --- linux-2.6.orig/arch/x86/pci/i386.c +++ linux-2.6/arch/x86/pci/i386.c @@ -33,6 +33,7 @@ #include #include +#include #include "pci.h" @@ -77,6 +78,30 @@ pcibios_align_resource(void *data, struc } EXPORT_SYMBOL(pcibios_align_resource); +static int check_res_with_valid(struct pci_dev *dev, struct resource *res) +{ + unsigned long base; + unsigned long size; + + base = res->start; + size = (res->start == 0 && res->end == res->start) ? 0 : + (res->end - res->start + 1); + + if (!base || !size) + return 0; + +#ifdef CONFIG_HPET_TIMER + /* for hpet */ + if (base == hpet_address && (res->flags & IORESOURCE_MEM)) { + dev_info(&dev->dev, "BAR has HPET at %08lx-%08lx\n", + base, base + size - 1); + return 1; + } +#endif + + return 0; +} + /* * Handle resources of PCI devices. If the world were perfect, we could * just allocate all the resource regions and do nothing more. It isn't. @@ -171,6 +196,22 @@ static void __init pcibios_allocate_reso r->flags, disabled, pass); pr = pci_find_parent_resource(dev, r); if (!pr || request_resource(pr, r) < 0) { + if (check_res_with_valid(dev, r)) { + struct resource *root = NULL; + + /* + * forcibly insert it into the + * resource tree + */ + if (r->flags & IORESOURCE_MEM) + root = &iomem_resource; + else if (r->flags & IORESOURCE_IO) + root = &ioport_resource; + + if (root) + insert_resource(root, r); + continue; + } dev_err(&dev->dev, "BAR %d: can't " "allocate resource\n", idx); /* We'll assign a new address later */