summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@nwnk.net>2006-05-18 23:48:46 +0000
committerAdam Jackson <ajax@nwnk.net>2006-05-18 23:48:46 +0000
commita3da58bf1ccaf81506fa67c0da60144ea900695c (patch)
tree7fd1a7b626dfa2edfd23a7bd090b6e6ed799c0f4
parente8b044ca913f1ac25cfb6aaf4c12fd87dcc1dcc3 (diff)
Bug #6377: Ignore disabled BARs, and allow matching BARs aligned to less
than 16 bytes. (Felix Kühling, ATI)
-rw-r--r--ChangeLog6
-rw-r--r--hw/xfree86/os-support/linux/lnx_pci.c26
2 files changed, 21 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 406b740f8..154f654f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2006-05-18 Adam Jackson <ajax@freedesktop.org>
+ * hw/xfree86/os-support/linux/lnx_pci.c:
+ Bug #6377: Ignore disabled BARs, and allow matching BARs
+ aligned to less than 16 bytes. (Felix Kühling, ATI)
+
+2006-05-18 Adam Jackson <ajax@freedesktop.org>
+
* hw/xfree86/os-support/linux/lnx_acpi.c:
Bug #5877: Avoid burning CPU when acpid dies. Require acpid to
be running for ACPI support on Linux. Minor errno handling
diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c
index cec9226c8..3505887bc 100644
--- a/hw/xfree86/os-support/linux/lnx_pci.c
+++ b/hw/xfree86/os-support/linux/lnx_pci.c
@@ -202,22 +202,26 @@ xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base)
if (tag == pciTag(bus,dev,fn)) {
/* ok now look through all the BAR values of this device */
for (ndx=0; ndx<7; ndx++) {
- unsigned long savePtr;
- /*
- * remember to lop of the last 4bits of the BAR values as they are
- * memory attributes
- */
+ unsigned long savePtr, flagMask;
if (ndx == 6)
- savePtr = (0xFFFFFFF0) &
- pciReadLong(tag, PCI_CMD_BIOS_REG);
+ savePtr = pciReadLong(tag, PCI_CMD_BIOS_REG);
else /* this the ROM bar */
- savePtr = (0xFFFFFFF0) &
- pciReadLong(tag, PCI_CMD_BASE_REG + (0x4 * ndx));
+ savePtr = pciReadLong(tag, PCI_CMD_BASE_REG + (0x4 * ndx));
+ /* Ignore unset base addresses. The kernel may
+ * have reported non-zero size and address even
+ * if they are disabled (e.g. disabled ROM BAR).
+ */
+ if (savePtr == 0)
+ continue;
+ /* Remove memory attribute bits, different for IO
+ * and memory ranges. */
+ flagMask = (savePtr & 0x1) ? ~0x3UL : ~0xFUL;
+ savePtr &= flagMask;
/* find the index of the incoming base */
- if (base >= savePtr && base <= (savePtr + size[ndx])) {
+ if (base >= savePtr && base < (savePtr + size[ndx])) {
fclose(file);
- return (offset[ndx] & ~(0xFUL)) + (base - savePtr);
+ return (offset[ndx] & flagMask) + (base - savePtr);
}
}
}