[Intel-gfx] [PATCH 2/7] Remove fixed MMIO size

Zhenyu Wang zhenyuw at linux.intel.com
Fri Jun 5 09:47:21 CEST 2009


Use pci resource size instead, which will get the correct MMIO range.
New chipset uses obviously larger MMIO range.

Signed-off-by: Zhenyu Wang <zhenyuw at linux.intel.com>
---
 src/common.h      |    1 +
 src/i830.h        |    1 +
 src/i830_driver.c |   10 ++++++----
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/common.h b/src/common.h
index 69f5604..83ee633 100644
--- a/src/common.h
+++ b/src/common.h
@@ -321,6 +321,7 @@ extern int I810_DEBUG;
 #endif
 
 #define I810_MEMBASE(p,n) (p)->regions[(n)].base_addr
+#define I810_MEMSIZE(p,n) (p)->regions[(n)].size
 #define VENDOR_ID(p)      (p)->vendor_id
 #define DEVICE_ID(p)      (p)->device_id
 #define SUBVENDOR_ID(p)	  (p)->subvendor_id
diff --git a/src/i830.h b/src/i830.h
index c0e7dcd..a69f47c 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -415,6 +415,7 @@ typedef struct _I830Rec {
    int Chipset;
    unsigned long LinearAddr;
    unsigned long MMIOAddr;
+   unsigned int MMIOSize;
    IOADDRESS ioBase;
    EntityInfoPtr pEnt;
    struct pci_device *PciInfo;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 8400872..aaf82e8 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -425,7 +425,7 @@ I830MapMMIO(ScrnInfoPtr pScrn)
    device = pI830->PciInfo;
    err = pci_device_map_range (device,
 			       pI830->MMIOAddr,
-			       I810_REG_SIZE,
+			       pI830->MMIOSize,
 			       PCI_DEV_MAP_FLAG_WRITABLE,
 			       (void **) &pI830->MMIOBase);
    if (err) 
@@ -508,7 +508,7 @@ I830UnmapMMIO(ScrnInfoPtr pScrn)
 {
    I830Ptr pI830 = I830PTR(pScrn);
 
-   pci_device_unmap_range (pI830->PciInfo, pI830->MMIOBase, I810_REG_SIZE);
+   pci_device_unmap_range (pI830->PciInfo, pI830->MMIOBase, pI830->MMIOSize);
    pI830->MMIOBase = NULL;
 
    if (IS_I9XX(pI830)) {
@@ -1218,6 +1218,7 @@ i830_detect_chipset(ScrnInfoPtr pScrn)
     if (pI830->pEnt->device->IOBase != 0) {
 	pI830->MMIOAddr = pI830->pEnt->device->IOBase;
 	from = X_CONFIG;
+	pI830->MMIOSize = I810_REG_SIZE;
     } else {
 	pI830->MMIOAddr = I810_MEMBASE (pI830->PciInfo, mmio_bar);
 	if (pI830->MMIOAddr == 0) {
@@ -1226,10 +1227,11 @@ i830_detect_chipset(ScrnInfoPtr pScrn)
 	    PreInitCleanup(pScrn);
 	    return FALSE;
 	}
+	pI830->MMIOSize = I810_MEMSIZE (pI830->PciInfo, mmio_bar);
     }
 
-    xf86DrvMsg(pScrn->scrnIndex, from, "IO registers at addr 0x%lX\n",
-	       (unsigned long)pI830->MMIOAddr);
+    xf86DrvMsg(pScrn->scrnIndex, from, "IO registers at addr 0x%lX size %u\n",
+	       (unsigned long)pI830->MMIOAddr, pI830->MMIOSize);
 
     /* Now figure out mapsize on 8xx chips */
     if (IS_I830(pI830) || IS_845G(pI830)) {
-- 
1.6.3.1




More information about the Intel-gfx mailing list