On Fri, Feb 20, 2009 at 02:41:43PM +0800, Zhao, Yu wrote: > +static resource_size_t pci_resource_limit(struct pci_dev *dev, int resno) > +{ > + u8 io; > + u16 mem; > + struct resource r, *res = dev->resource + resno; > + struct pci_bus_region region; > + > + if (resno < PCI_BRIDGE_RESOURCES) { > + if ((res->flags & PCI_BASE_ADDRESS_SPACE) == > + PCI_BASE_ADDRESS_SPACE_MEMORY && > + (res->flags & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == > + PCI_BASE_ADDRESS_MEM_TYPE_64) { > + /* Memory BAR could be 64-bit */ > + region.end = (resource_size_t)(u64)-1; > + } else { > + /* I/O and ROM BAR are always 32-bit */ > + region.end = (u32)-1; > + } > + } else if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { > + switch (resno - PCI_BRIDGE_RESOURCES) { > + case PCI_BRIDGE_IO: > + /* I/O window could be 16 or 32-bit */ > + pci_read_config_byte(dev, PCI_IO_BASE, &io); > + region.end = (io & 0xf) ? (u32)-1 : (u16)-1; > + break; > + case PCI_BRIDGE_MEM: > + /* Memory window is always 32-bit */ > + region.end = (u32)-1; > + break; > + case PCI_BRIDGE_PREF_MEM: > + /* Prefetch memory window could be 32 or 64-bit */ > + pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem); > + region.end = (mem & 0xf) ? (resource_size_t)(u64)-1 : > + (u32)-1; > + break; > + default: > + goto bad; > + } > + } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { > + if (resno - PCI_BRIDGE_RESOURCES > PCI_CARDBUS_MAX_RESOURCE) > + goto bad; > + > + /* Cardbus resource windows are always 32-bit??? */ > + region.end = (u32)-1; > + } else { > + dev_err(&dev->dev, "invalid header type: %d\n", dev->hdr_type); > + goto bad; > + } > + > + pcibios_bus_to_resource(dev, &r, ®ion); > + > + return r.end; > + Looks like I forgot at leas two things here: assign value to r->flags and check if region->end overflows... Will fix them up and resend the patch. Thanks, Yu -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html