Port-mips archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: xf86-video-sis changes for mips



[ I'm not subscribed to tech-x11, so please keep either me or port-mips in Cc ]

Hello,
based on suggetion from macallan@, here's a new, less intrusive patch.
It uses the PCI_MAGIC_IO_RANGE other drivers are already using.
The challenge here is to find a value that will never show up in
PCI BARs, for any hardware supported by evbmips (a conflict here would be
a problem only when trying to map these ranges in userspace).
Using a 64bit value, we're safe for 32bit devices. I'm not sure if 64bit
devices can use values that high.

Attached is a kernel patch which defines a PCI_MAGIC_IO_RANGE for evbmips,
and use it for sisfb.
Then the xorg patch is much simpler: mips has to be handled the same way
as arm in ppc_video.c (I think it's a bug that mips was ommited here, because
the mips and arm inx/outx functions both use IOPortBase). Then we just
need to adjust the address in sisfb to use the correct address.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
Index: sys/dev/pci/sisfb.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/sisfb.c,v
retrieving revision 1.5
diff -u -p -u -r1.5 sisfb.c
--- sys/dev/pci/sisfb.c 26 Jan 2014 21:22:49 -0000      1.5
+++ sys/dev/pci/sisfb.c 28 Jan 2014 11:49:21 -0000
@@ -488,12 +488,15 @@ sisfb_mmap(void *v, void *vs, off_t offs
                    prot, BUS_SPACE_MAP_LINEAR);
                return pa;
        }
-       if (offset >= (fb->iobase & ~PAGE_MASK) &&
-           offset <= ((fb->iobase + fb->iosize + PAGE_SIZE - 1) & ~PAGE_MASK)) 
{
-               pa = bus_space_mmap(fb->iot, fb->iobase, offset - fb->iobase,
-                   prot, BUS_SPACE_MAP_LINEAR);
+#ifdef PCI_MAGIC_IO_RANGE
+       /* allow mapping of IO space */
+       if ((offset >= PCI_MAGIC_IO_RANGE) &&
+           (offset < PCI_MAGIC_IO_RANGE + 0x10000)) {
+               pa = bus_space_mmap(fb->iot, offset - PCI_MAGIC_IO_RANGE,
+                   0, prot, BUS_SPACE_MAP_LINEAR);     
                return pa;
-       }
+       }       
+#endif /* PCI_MAGIC_IO_RANGE */
        return -1;
 }
 
Index: sys/arch/evbmips/include/param.h
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/include/param.h,v
retrieving revision 1.9
diff -u -p -u -r1.9 param.h
--- sys/arch/evbmips/include/param.h    18 Mar 2011 16:30:01 -0000      1.9
+++ sys/arch/evbmips/include/param.h    28 Jan 2014 11:49:21 -0000
@@ -62,4 +62,6 @@ void  delay(int n);
 #endif /* !_LOCORE */
 #endif /* _KERNEL */
 
+/* at this offset we mmap() the PCI IO range in display drivers */
+#define PCI_MAGIC_IO_RANGE      0x00ffffff00000000ULL
 #endif /* !_EVBMIPS_PARAM_H_ */
Index: xf86-video-sis/dist/src/sis_driver.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xf86-video-sis/dist/src/sis_driver.c,v
retrieving revision 1.1.1.4
diff -u -p -u -r1.1.1.4 sis_driver.c
--- xf86-video-sis/dist/src/sis_driver.c        17 Jul 2010 06:32:06 -0000      
1.1.1.4
+++ xf86-video-sis/dist/src/sis_driver.c        28 Jan 2014 11:35:42 -0000
@@ -4421,7 +4421,14 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
        * XXX Should check that the config file value matches one of the
        * PCI base address values.
        */
+#if defined(__mips__) || defined(__arm32__)
+       /* inX/outX macros on these use IOPortBase as offset
+       * and this driver use these macros for memory space too.
+        * This is entirely skrewed. */
+       pSiS->IOAddress = pSiS->pEnt->device->IOBase - IOPortBase;
+#else
        pSiS->IOAddress = pSiS->pEnt->device->IOBase;
+#endif
        from = X_CONFIG;
     } else {
        pSiS->IOAddress = PCI_REGION_BASE(pSiS->PciInfo, 1, REGION_MEM) & 
0xFFFFFFF0;
Index: xorg-server/dist/hw/xfree86/os-support/bsd/ppc_video.c
===================================================================
RCS file: 
/cvsroot/xsrc/external/mit/xorg-server/dist/hw/xfree86/os-support/bsd/ppc_video.c,v
retrieving revision 1.5
diff -u -p -u -r1.5 ppc_video.c
--- xorg-server/dist/hw/xfree86/os-support/bsd/ppc_video.c      23 Nov 2010 
06:38:09 -0000      1.5
+++ xorg-server/dist/hw/xfree86/os-support/bsd/ppc_video.c      28 Jan 2014 
11:35:43 -0000
@@ -145,7 +145,7 @@ xf86EnableInterrupts()
 }
 
 /* XXX why the hell is this necessary?! */
-#ifdef __arm__
+#if defined(__arm__) || defined(__mips__)
 unsigned int IOPortBase = (int)MAP_FAILED;
 #endif
 
@@ -165,7 +165,7 @@ Bool xf86EnableIO()
                        return FALSE;
                }
         }
-#ifdef __arm__
+#if defined(__arm__) || defined(__mips__)
         IOPortBase = (unsigned int)ioBase;
 #endif
        return TRUE;
@@ -181,7 +181,7 @@ void xf86DisableIO()
         {
                 munmap(__UNVOLATILE(ioBase), 0x10000);
                 ioBase = MAP_FAILED;
-#ifdef __arm__
+#if defined(__arm__) || defined(__mips__)
                IOPortBase = (unsigned int)MAP_FAILED;
 #endif
         }


Home | Main Index | Thread Index | Old Index