[PATCH] PCI updates - handle resource flags correctly

From: Russell King (rmk@flint.arm.linux.org.uk)
Date: Tue Dec 18 2001 - 18:50:31 EST


The following patch fixes a problem noticed on ARM while the generic PCI
code allocates bus addresses.

The region flags ended up containing some of the low-order bits of the IO
address that was read initially. This carries over some of the old PCI
address bits after the PCI resource allocator has reassigned them.

Obviously not good. The following patch correctly masks the resource flags
depending on the resource type.

This patch is being sent for only review at this time, but is ultimately
targeted at both the 2.4 and 2.5 kernel series.

diff -ur orig/drivers/pci/pci.c linux/drivers/pci/pci.c
--- orig/drivers/pci/pci.c Fri Nov 23 10:12:15 2001
+++ linux/drivers/pci/pci.c Tue Dec 18 19:31:15 2001
@@ -914,13 +914,15 @@
                         l = 0;
                 if ((l & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) {
                         res->start = l & PCI_BASE_ADDRESS_MEM_MASK;
+ res->flags |= l & ~PCI_BASE_ADDRESS_MEM_MASK;
                         sz = pci_size(sz, PCI_BASE_ADDRESS_MEM_MASK);
                 } else {
                         res->start = l & PCI_BASE_ADDRESS_IO_MASK;
+ res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK;
                         sz = pci_size(sz, PCI_BASE_ADDRESS_IO_MASK & 0xffff);
                 }
                 res->end = res->start + (unsigned long) sz;
- res->flags |= (l & 0xf) | pci_calc_resource_flags(l);
+ res->flags |= pci_calc_resource_flags(l);
                 if ((l & (PCI_BASE_ADDRESS_SPACE | PCI_BASE_ADDRESS_MEM_TYPE_MASK))
                     == (PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64)) {
                         pci_read_config_dword(dev, reg+4, &l);

--
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Dec 23 2001 - 21:00:18 EST