Skip to contentSkip to conversation

2.5 and 2.4: fix PCI IO BAR flags

PATCH New Russell King 1 participant 1 message Mar 15, 2002 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5 and 2.4: fix PCI IO BAR flags

There is a problem where the resource flags sometimes contain bits from the address part of the PCI BAR, especially when you have the low address bit set for an IO BAR.

(bit 3 of a PCI IO BAR is an address bit, and (bar & 0xf) propagates this to res->flags).

This exists in Ivan Kokshaysky PCI patches, and so far hasn't made it into the kernel. It's required for IDE on certain ARM machines to even work.

This patch fixes this. Please apply.

drivers/pci/pci.c +3 -1
@@ -1011,13 +1011,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);
Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html