7b2583d
From 89a9ad75f3e50e25275b803617d5e74709ead269 Mon Sep 17 00:00:00 2001
7b2583d
From: Yi Zhan <yi.zhan@intel.com>
7b2583d
Date: Wed, 26 Mar 2008 16:13:08 +1000
7b2583d
Subject: [PATCH] mach64: on IA64 systems the pciaccess page size mapping was getting E2BIG
7b2583d
7b2583d
As the ia64 pagesize was 16k, and aperture was only 4k, this was messing up
7b2583d
on ia64 machines.
7b2583d
7b2583d
Modified fix from RH BZ 438947 - airlied
7b2583d
---
7b2583d
 src/atividmem.c |   20 +++++++++++++++-----
7b2583d
 1 files changed, 15 insertions(+), 5 deletions(-)
7b2583d
7b2583d
diff --git a/src/atividmem.c b/src/atividmem.c
7b2583d
index 986ac0f..8950f84 100644
7b2583d
--- a/src/atividmem.c
7b2583d
+++ b/src/atividmem.c
7b2583d
@@ -146,7 +146,12 @@ ATIUnmapMMIO
7b2583d
 #ifndef XSERVER_LIBPCIACCESS
7b2583d
         xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize());
7b2583d
 #else
7b2583d
-        pci_device_unmap_range(pATI->PCIInfo, pATI->pMMIO, getpagesize());
7b2583d
+        unsigned long size;
7b2583d
+
7b2583d
+        size = PCI_REGION_SIZE(pATI->PCIInfo, 2);
7b2583d
+        if (!size || size > getpagesize())
7b2583d
+                size = getpagesize();
7b2583d
+        pci_device_unmap_range(pATI->PCIInfo, pATI->pMMIO, size);
7b2583d
 #endif
7b2583d
     }
7b2583d
 
7b2583d
@@ -340,10 +345,15 @@ ATIMapApertures
7b2583d
 
7b2583d
         int mode = PCI_DEV_MAP_FLAG_WRITABLE;
7b2583d
 
7b2583d
-        int err = pci_device_map_range(pVideo,
7b2583d
-                                       MMIOBase,
7b2583d
-                                       PageSize,
7b2583d
-                                       mode, &pATI->pMMIO);
7b2583d
+        int err;
7b2583d
+        int size;
7b2583d
+
7b2583d
+        size = PCI_REGION_SIZE(pVideo, 2);
7b2583d
+        if (!size || size > PageSize)
7b2583d
+               size = PageSize;
7b2583d
+
7b2583d
+	err = pci_device_map_range(pVideo, MMIOBase,
7b2583d
+                                   size, mode, &pATI->pMMIO);
7b2583d
 
7b2583d
         if (err)
7b2583d
         {
7b2583d
-- 
7b2583d
1.5.4.4
7b2583d