[PATCH 07/12] xfree86: Remove the memory of MTRR awareness

Adam Jackson ajax at redhat.com
Tue Jul 29 12:00:14 PDT 2014


pciaccess does this for us, and none of our internal hooks really
remain.  This does remove a cleanup pass from the BSD code, but the case
it's covering (a previous server leaving MTRRs around) can't happen
anymore.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 configure.ac                           |  23 -------
 hw/xfree86/doc/README.DRIcomp          |   3 -
 hw/xfree86/doc/Registry                |   1 -
 hw/xfree86/man/xorg.conf.man           |   6 --
 hw/xfree86/os-support/bsd/i386_video.c | 112 ---------------------------------
 include/dix-config.h.in                |   3 -
 include/xorg-config.h.in               |   6 --
 7 files changed, 154 deletions(-)

diff --git a/configure.ac b/configure.ac
index f3d9654..e4d3d43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -235,29 +235,6 @@ dnl fbdev header
 AC_CHECK_HEADERS([linux/fb.h], FBDEV=yes)
 AM_CONDITIONAL(FBDEVHW, [test "x$FBDEV" = xyes])
 
-dnl MTRR header
-AC_CHECK_HEADERS([asm/mtrr.h], ac_cv_asm_mtrr_h=yes)
-if test "x$ac_cv_asm_mtrr_h" = xyes; then
-	HAVE_MTRR=yes
-fi
-
-dnl BSD MTRR header
-AC_CHECK_HEADERS([sys/memrange.h], ac_cv_memrange_h=yes)
-if test "x$ac_cv_memrange_h" = xyes; then
-	HAVE_MTRR=yes
-fi
-
-if test "x$HAVE_MTRR" = xyes; then
-	AC_DEFINE(HAS_MTRR_SUPPORT, 1, [MTRR support available])
-fi
-
-dnl A NetBSD MTRR header
-AC_CHECK_HEADERS([machine/mtrr.h], ac_cv_machine_mtrr_h=yes)
-if test "x$ac_cv_machine_mtrr_h" = xyes; then
-	AC_DEFINE(HAS_MTRR_BUILTIN, 1, [Define to 1 if NetBSD built-in MTRR
-		support is available])
-fi
-
 dnl FreeBSD kldload support (sys/linker.h)
 AC_CHECK_HEADERS([sys/linker.h],
 	[ac_cv_sys_linker_h=yes],
diff --git a/hw/xfree86/doc/README.DRIcomp b/hw/xfree86/doc/README.DRIcomp
index 2d3ebf1..7388650 100644
--- a/hw/xfree86/doc/README.DRIcomp
+++ b/hw/xfree86/doc/README.DRIcomp
@@ -142,9 +142,6 @@ Here are the basic steps for kernel setup.
 
         o Enable all chipsets' support for AGP
 
-        o It's recommended that you turn on MTRRs under Processor type and
-          Features, but not required.
-
    o Configure the rest of the kernel as required for your system (i.e. Eth-
      ernet, SCSI, etc)
 
diff --git a/hw/xfree86/doc/Registry b/hw/xfree86/doc/Registry
index 48e24a2..ad5b9bf 100644
--- a/hw/xfree86/doc/Registry
+++ b/hw/xfree86/doc/Registry
@@ -231,7 +231,6 @@ DDC                       B     C    Enable/disable DDC
 DDC1                      B     C    Enable/disable DDC1
 DDC2                      B     C    Enable/disable DDC2
 DPMS                      O     C    Enable DPMS
-MTRR                      B     C    Enable/disable setting MTRRs
 
 BaudRate                  I     I    Serial port baud rate
 ButtonNumber              I     I    Button number (for touch screen?)
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index 1631212..378f26b 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -2023,12 +2023,6 @@ Default: false.
 Disables the Int10 module, a module that uses the int10 call to the BIOS
 of the graphics card to initialize it.
 Default: false.
-.TP 7
-.BI "Option \*qNoMTRR\*q"
-Disables MTRR (Memory Type Range Register) support, a feature of modern
-processors which can improve video performance by a factor of up to 2.5.
-Some hardware has buggy MTRR support, and some video drivers have been
-known to exhibit problems when MTRR's are used.
 .PP
 Each
 .B Screen
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index dae3555..6c3bbcb 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -34,27 +34,6 @@
 #include <errno.h>
 #include <sys/mman.h>
 
-#ifdef HAS_MTRR_SUPPORT
-#ifndef __NetBSD__
-#include <sys/types.h>
-#include <sys/memrange.h>
-#else
-#include "memrange.h"
-#endif
-#define X_MTRR_ID "XFree86"
-#endif
-
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-#include <machine/mtrr.h>
-#include <machine/sysarch.h>
-#include <sys/queue.h>
-#ifdef __x86_64__
-#define i386_set_mtrr x86_64_set_mtrr
-#define i386_get_mtrr x86_64_get_mtrr
-#define i386_iopl x86_64_iopl
-#endif
-#endif
-
 #include "xf86_OSlib.h"
 #include "xf86OSpriv.h"
 
@@ -85,10 +64,6 @@ static int devMemFd = -1;
 #define DEV_APERTURE "/dev/xf86"
 #endif
 
-#ifdef HAS_MTRR_SUPPORT
-static Bool cleanMTRR(void);
-#endif
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -181,9 +156,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
     pci_system_init_dev_mem(devMemFd);
 
-#ifdef HAS_MTRR_SUPPORT
-    cleanMTRR();
-#endif
     pVidMem->initialised = TRUE;
 }
 
@@ -354,87 +326,3 @@ xf86SetRGBOut()
     return;
 }
 #endif
-
-#ifdef HAS_MTRR_SUPPORT
-/* memory range (MTRR) support for FreeBSD */
-
-/*
- * This code is experimental.  Some parts may be overkill, and other parts
- * may be incomplete.
- */
-
-/*
- * getAllRanges returns the full list of memory ranges with attributes set.
- */
-
-static struct mem_range_desc *
-getAllRanges(int *nmr)
-{
-    struct mem_range_desc *mrd;
-    struct mem_range_op mro;
-
-    /*
-     * Find how many ranges there are.  If this fails, then the kernel
-     * probably doesn't have MTRR support.
-     */
-    mro.mo_arg[0] = 0;
-    if (ioctl(devMemFd, MEMRANGE_GET, &mro))
-        return NULL;
-    *nmr = mro.mo_arg[0];
-    mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
-    mro.mo_arg[0] = *nmr;
-    mro.mo_desc = mrd;
-    if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
-        free(mrd);
-        return NULL;
-    }
-    return mrd;
-}
-
-/*
- * cleanMTRR removes any memory attribute that may be left by a previous
- * X server.  Normally there won't be any, but this takes care of the
- * case where a server crashed without being able finish cleaning up.
- */
-
-static Bool
-cleanMTRR()
-{
-    struct mem_range_desc *mrd;
-    struct mem_range_op mro;
-    int nmr, i;
-
-    /* This shouldn't happen */
-    if (devMemFd < 0)
-        return FALSE;
-
-    if (!(mrd = getAllRanges(&nmr)))
-        return FALSE;
-
-    for (i = 0; i < nmr; i++) {
-        if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
-            (mrd[i].mr_flags & MDF_ACTIVE)) {
-#ifdef DEBUG
-            ErrorF("Clean for (0x%lx,0x%lx)\n",
-                   (unsigned long) mrd[i].mr_base,
-                   (unsigned long) mrd[i].mr_len);
-#endif
-            if (mrd[i].mr_flags & MDF_FIXACTIVE) {
-                mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-                mrd[i].mr_flags = MDF_UNCACHEABLE;
-            }
-            else {
-                mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
-            }
-            mro.mo_desc = mrd + i;
-            ioctl(devMemFd, MEMRANGE_SET, &mro);
-        }
-    }
-#ifdef DEBUG
-    sleep(10);
-#endif
-    free(mrd);
-    return TRUE;
-}
-
-#endif                          /* HAS_MTRR_SUPPORT */
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 2203f82..4268b8f 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -57,9 +57,6 @@
 /* Support SHM */
 #undef HAS_SHM
 
-/* Define to 1 if you have the <asm/mtrr.h> header file. */
-#undef HAVE_ASM_MTRR_H
-
 /* Has backtrace support */
 #undef HAVE_BACKTRACE
 
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 629ae40..7c03126 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -82,12 +82,6 @@
 /* Building vgahw module */
 #undef WITH_VGAHW
 
-/* Define to 1 if NetBSD built-in MTRR support is available */
-#undef HAS_MTRR_BUILTIN
-
-/* Define to 1 if BSD MTRR support is available */
-#undef HAS_MTRR_SUPPORT
-
 /* NetBSD PIO alpha IO */
 #undef USE_ALPHA_PIO
 
-- 
1.9.3



More information about the xorg-devel mailing list