Blob Blame Raw
From 89a9ad75f3e50e25275b803617d5e74709ead269 Mon Sep 17 00:00:00 2001
From: Yi Zhan <yi.zhan@intel.com>
Date: Wed, 26 Mar 2008 16:13:08 +1000
Subject: [PATCH] mach64: on IA64 systems the pciaccess page size mapping was getting E2BIG

As the ia64 pagesize was 16k, and aperture was only 4k, this was messing up
on ia64 machines.

Modified fix from RH BZ 438947 - airlied
---
 src/atividmem.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/atividmem.c b/src/atividmem.c
index 986ac0f..8950f84 100644
--- a/src/atividmem.c
+++ b/src/atividmem.c
@@ -146,7 +146,12 @@ ATIUnmapMMIO
 #ifndef XSERVER_LIBPCIACCESS
         xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize());
 #else
-        pci_device_unmap_range(pATI->PCIInfo, pATI->pMMIO, getpagesize());
+        unsigned long size;
+
+        size = PCI_REGION_SIZE(pATI->PCIInfo, 2);
+        if (!size || size > getpagesize())
+                size = getpagesize();
+        pci_device_unmap_range(pATI->PCIInfo, pATI->pMMIO, size);
 #endif
     }
 
@@ -340,10 +345,15 @@ ATIMapApertures
 
         int mode = PCI_DEV_MAP_FLAG_WRITABLE;
 
-        int err = pci_device_map_range(pVideo,
-                                       MMIOBase,
-                                       PageSize,
-                                       mode, &pATI->pMMIO);
+        int err;
+        int size;
+
+        size = PCI_REGION_SIZE(pVideo, 2);
+        if (!size || size > PageSize)
+               size = PageSize;
+
+	err = pci_device_map_range(pVideo, MMIOBase,
+                                   size, mode, &pATI->pMMIO);
 
         if (err)
         {
-- 
1.5.4.4