[PATCH 1/4] xfree86: Remove no-op /dev/mem checks from xf86OSInitVidMem

Adam Jackson ajax at redhat.com
Wed Oct 8 08:38:56 PDT 2014


pciaccess doesn't end up using the fd being inspected here, so there's
not really any point.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 hw/xfree86/os-support/bsd/alpha_video.c | 122 --------------------------------
 hw/xfree86/os-support/bsd/arm_video.c   |  52 --------------
 hw/xfree86/os-support/hurd/hurd_video.c |   4 --
 3 files changed, 178 deletions(-)

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index 236def6..fd8f823 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -45,131 +45,9 @@
 #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
 #endif
 
-#ifndef __NetBSD__
-extern unsigned long dense_base(void);
-#else                           /* __NetBSD__ */
-static struct alpha_bus_window *abw;
-static int abw_count = -1;
-
-static void
-init_abw(void)
-{
-    if (abw_count < 0) {
-        abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
-        if (abw_count <= 0)
-            FatalError("init_abw: alpha_bus_getwindows failed\n");
-    }
-}
-
-static unsigned long
-dense_base(void)
-{
-    if (abw_count < 0)
-        init_abw();
-
-    /* XXX check abst_flags for ABST_DENSE just to be safe? */
-    xf86Msg(X_INFO, "dense base = %#lx\n", abw[0].abw_abst.abst_sys_start);     /* XXXX */
-    return abw[0].abw_abst.abst_sys_start;
-}
-
-#endif                          /* __NetBSD__ */
-
-#define BUS_BASE	dense_base()
-
-/***************************************************************************/
-/* Video Memory Mapping section                                            */
-/***************************************************************************/
-
-#ifdef __OpenBSD__
-#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
-                  "\tin /etc/sysctl.conf and reboot your machine\n" \
-                  "\trefer to xf86(4) for details"
-#endif
-
-static int devMemFd = -1;
-
-#ifdef HAS_APERTURE_DRV
-#define DEV_APERTURE "/dev/xf86"
-#endif
-
-/*
- * Check if /dev/mem can be mmap'd.  If it can't print a warning when
- * "warn" is TRUE.
- */
-static void
-checkDevMem(Bool warn)
-{
-    static Bool devMemChecked = FALSE;
-    int fd;
-    void *base;
-
-    if (devMemChecked)
-        return;
-    devMemChecked = TRUE;
-
-#ifdef HAS_APERTURE_DRV
-    /* Try the aperture driver first */
-    if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
-        /* Try to map a page at the VGA address */
-        base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
-                    MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE);
-
-        if (base != MAP_FAILED) {
-            munmap((caddr_t) base, 4096);
-            devMemFd = fd;
-            xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
-                    DEV_APERTURE);
-            return;
-        }
-        else {
-            if (warn) {
-                xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
-                        DEV_APERTURE, strerror(errno));
-            }
-        }
-    }
-#endif
-    if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
-        /* Try to map a page at the VGA address */
-        base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
-                    MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE);
-
-        if (base != MAP_FAILED) {
-            munmap((caddr_t) base, 4096);
-            devMemFd = fd;
-            return;
-        }
-        else {
-            if (warn) {
-                xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
-                        DEV_MEM, strerror(errno));
-            }
-        }
-    }
-    if (warn) {
-#ifndef HAS_APERTURE_DRV
-        xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
-                DEV_MEM, strerror(errno));
-#else
-#ifndef __OpenBSD__
-        xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
-                "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
-#else                           /* __OpenBSD__ */
-        xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
-                "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
-                SYSCTL_MSG);
-#endif                          /* __OpenBSD__ */
-#endif
-        xf86ErrorF("\tlinear framebuffer access unavailable\n");
-    }
-    return;
-}
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-    checkDevMem(TRUE);
-
     pVidMem->initialised = TRUE;
 }
 
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index 3a639b8..fea8528 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -72,61 +72,9 @@
 #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
 #endif
 
-#define BUS_BASE	0L
-#define BUS_BASE_BWX	0L
-
-/***************************************************************************/
-/* Video Memory Mapping section                                            */
-/***************************************************************************/
-
-static int devMemFd = -1;
-
-/*
- * Check if /dev/mem can be mmap'd.  If it can't print a warning when
- * "warn" is TRUE.
- */
-static void
-checkDevMem(Bool warn)
-{
-    static Bool devMemChecked = FALSE;
-    int fd;
-    void *base;
-
-    if (devMemChecked)
-        return;
-    devMemChecked = TRUE;
-
-    if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
-        /* Try to map a page at the VGA address */
-        base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE,
-                    MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE);
-
-        if (base != MAP_FAILED) {
-            munmap((caddr_t) base, 4096);
-            devMemFd = fd;
-            return;
-        }
-        else {
-            /* This should not happen */
-            if (warn) {
-                xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
-                        DEV_MEM, strerror(errno));
-            }
-            return;
-        }
-    }
-    if (warn) {
-        xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
-                DEV_MEM, strerror(errno));
-    }
-    return;
-}
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-    checkDevMem(TRUE);
-
     pVidMem->initialised = TRUE;
 }
 
diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c
index 2a96393..1e7d604 100644
--- a/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/hw/xfree86/os-support/hurd/hurd_video.c
@@ -40,10 +40,6 @@
 #include "xf86OSpriv.h"
 
 /**************************************************************************
- * Video Memory Mapping section                                            
- ***************************************************************************/
-
-/**************************************************************************
  * I/O Permissions section                                                 
  ***************************************************************************/
 
-- 
1.9.3



More information about the xorg-devel mailing list