xf86-video-intel: 3 commits - configure.ac src/intel_driver.h src/intel_module.c src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_display.c src/sna/sna.h src/sna/sna_io.c src/uxa/intel_display.c src/uxa/intel_dri3.c src/uxa/intel_dri.c src/uxa/intel_driver.c src/uxa/intel_glamor.c src/uxa/intel_glamor.h src/uxa/intel_uxa.c src/uxa/intel_uxa.h src/uxa/intel_uxa_video.c src/uxa/intel_video.c src/uxa/Makefile.am src/uxa/uxa-accel.c src/uxa/uxa.c src/uxa/uxa-glamor.h src/uxa/uxa-glyphs.c src/uxa/uxa.h src/uxa/uxa-render.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Nov 6 09:02:21 PST 2014


 configure.ac              |   57 +------
 src/intel_driver.h        |    2 
 src/intel_module.c        |    5 
 src/sna/kgem.c            |  338 ++++++++++++++++++++++++++++++----------------
 src/sna/kgem.h            |   13 +
 src/sna/sna.h             |    3 
 src/sna/sna_accel.c       |   68 ++++++---
 src/sna/sna_display.c     |    2 
 src/sna/sna_io.c          |   21 ++
 src/uxa/Makefile.am       |   10 -
 src/uxa/intel_display.c   |    2 
 src/uxa/intel_dri.c       |  131 -----------------
 src/uxa/intel_dri3.c      |    9 -
 src/uxa/intel_driver.c    |   11 -
 src/uxa/intel_glamor.c    |  309 ------------------------------------------
 src/uxa/intel_glamor.h    |   96 -------------
 src/uxa/intel_uxa.c       |   52 -------
 src/uxa/intel_uxa.h       |    1 
 src/uxa/intel_uxa_video.c |    1 
 src/uxa/intel_video.c     |   12 -
 src/uxa/uxa-accel.c       |  231 -------------------------------
 src/uxa/uxa-glamor.h      |   65 --------
 src/uxa/uxa-glyphs.c      |   28 ---
 src/uxa/uxa-render.c      |   91 ------------
 src/uxa/uxa.c             |   11 -
 src/uxa/uxa.h             |   16 --
 26 files changed, 318 insertions(+), 1267 deletions(-)

New commits:
commit 0aa2edbd29c8dd26a5f3748e3875c445ea358a6d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Nov 5 11:56:20 2014 +0000

    Remove defunct glamor support
    
    It never was a stable or complete replacement, and now it is
    incorporated in Xorg itself!
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index 75fd3b6..e5877c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -427,31 +427,6 @@ fi
 PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_server_version xproto fontsproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES])
 ABI_VERSION=`$PKG_CONFIG --variable=abi_videodrv xorg-server`
 
-AC_ARG_ENABLE(glamor,
-	      AS_HELP_STRING([--enable-glamor],
-			     [Enable glamor, a new GL-based acceleration [default=no]]),
-	      [GLAMOR="$enableval"],
-	      [GLAMOR="no"])
-if test "x$GLAMOR" != "xno"; then
-	if test "x$UXA" != "xyes"; then
-		AC_MSG_ERROR([Glamor acceleration requested but UXA is not enabled])
-	fi
-	if pkg-config --exists "xorg-server >= 1.15.99.901"; then
-		save_CPPFLAGS=$CPPFLAGS
-		CPPFLAGS="$XORG_CFLAGS"
-		AC_CHECK_HEADER([glamor.h],
-				[GLAMOR="yes (using Xorg glamor module)"],
-				[test "x$GLAMOR" != "xauto" && AC_MSG_ERROR("failed to find required Xorg headers for glamor")
-				GLAMOR="no"], [#include <xorg-server.h>])
-		CPPFLAGS=$save_CPPFLAGS
-	else
-		PKG_CHECK_MODULES(LIBGLAMOR, [glamor >= 0.6.0])
-		PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl])
-		GLAMOR="yes (using libglamor)"
-	fi
-	AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
-fi
-
 if test "x$ONLY_UMS" = "xyes"; then
 	UMS="yes"
 	KMS="no"
@@ -651,10 +626,6 @@ AC_MSG_CHECKING([whether to include UXA support])
 AC_MSG_RESULT([$UXA])
 AM_CONDITIONAL(UXA, test "x$UXA" != "xno")
 
-AC_MSG_CHECKING([whether to include GLAMOR support])
-AC_MSG_RESULT([$GLAMOR])
-AM_CONDITIONAL(GLAMOR, test "x$GLAMOR" != "xno")
-
 AC_MSG_CHECKING([whether to include SNA support])
 AM_CONDITIONAL(SNA, test "x$SNA" != "xno")
 AC_MSG_RESULT([$SNA])
@@ -675,7 +646,7 @@ fi
 
 AC_ARG_WITH(default-accel,
 	    AS_HELP_STRING([--with-default-accel],
-			   [Select the default acceleration method out of glamor, none, sna, or uxa  [default is sna if enabled, otherwise uxa]]),
+			   [Select the default acceleration method out of none, sna, or uxa  [default is sna if enabled, otherwise uxa]]),
 			   [accel="$withval"],
 			   [accel="auto"])
 if test "x$accel" = "xyes"; then
@@ -716,15 +687,6 @@ if test "x$accel" = "xuxa"; then
 	fi
 fi
 
-if test "x$accel" = "xglamor"; then
-	if test "x$GLAMOR" != "xno"; then
-		AC_DEFINE(DEFAULT_ACCEL_METHOD, GLAMOR, [Default acceleration method])
-		have_accel="yes"
-	else
-		AC_MSG_ERROR([glamor acceleration requested as default, but is not enabled])
-	fi
-fi
-
 if test "x$have_accel" = "xnone"; then
 	if test "x$KMS" = "xyes"; then
 		if test "x$SNA" != "xno" -o "x$UXA" != "xno"; then
@@ -922,13 +884,6 @@ if test "x$UXA" != "xno"; then
 		accel_msg="$accel_msg uxa"
 	fi
 fi
-if test "x$GLAMOR" != "xno"; then
-	if test "$accel" = "glamor"; then
-		accel_msg="$accel_msg *glamor"
-	else
-		accel_msg="$accel_msg glamor"
-	fi
-fi
 
 if test "x$dri_msg" = "x"; then
 	dri_msg=" none"
diff --git a/src/intel_driver.h b/src/intel_driver.h
index f3eb90a..28ed1a0 100644
--- a/src/intel_driver.h
+++ b/src/intel_driver.h
@@ -137,7 +137,7 @@ void intel_put_device(struct intel_device *dev);
 void intel_detect_chipset(ScrnInfoPtr scrn, struct intel_device *dev);
 
 #define IS_DEFAULT_ACCEL_METHOD(x) ({ \
-	enum { NOACCEL, SNA, UXA, GLAMOR } default_accel_method__ = DEFAULT_ACCEL_METHOD; \
+	enum { NOACCEL, SNA, UXA } default_accel_method__ = DEFAULT_ACCEL_METHOD; \
 	default_accel_method__ == x; \
 })
 
diff --git a/src/intel_module.c b/src/intel_module.c
index 2fbb4df..102d52a 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -500,7 +500,7 @@ _xf86findDriver(const char *ident, XF86ConfDevicePtr p)
 	return NULL;
 }
 
-static enum accel_method { NOACCEL, SNA, UXA, GLAMOR } get_accel_method(void)
+static enum accel_method { NOACCEL, SNA, UXA } get_accel_method(void)
 {
 	enum accel_method accel_method = DEFAULT_ACCEL_METHOD;
 	XF86ConfDevicePtr dev;
@@ -520,8 +520,6 @@ static enum accel_method { NOACCEL, SNA, UXA, GLAMOR } get_accel_method(void)
 				accel_method = SNA;
 			else if (strcasecmp(s, "uxa") == 0)
 				accel_method = UXA;
-			else if (strcasecmp(s, "glamor") == 0)
-				accel_method = GLAMOR;
 		}
 	}
 
@@ -583,7 +581,6 @@ intel_scrn_create(DriverPtr		driver,
 #if !USE_SNA
 	case NOACCEL:
 #endif
-	case GLAMOR:
 	case UXA:
 		  return intel_init_scrn(scrn);
 #endif
diff --git a/src/uxa/Makefile.am b/src/uxa/Makefile.am
index 23b074d..426f598 100644
--- a/src/uxa/Makefile.am
+++ b/src/uxa/Makefile.am
@@ -34,7 +34,6 @@ libuxa_la_SOURCES = \
 	intel_batchbuffer.h \
 	intel_display.c \
 	intel_driver.c \
-	intel_glamor.h \
 	intel_memory.c \
 	intel_uxa.c \
 	intel_video.c \
@@ -58,21 +57,12 @@ libuxa_la_SOURCES = \
 	uxa.c \
 	uxa.h \
 	uxa-accel.c \
-	uxa-glamor.h \
 	uxa-glyphs.c \
 	uxa-render.c \
 	uxa-priv.h \
 	uxa-unaccel.c
 	$(NULL)
 
-if GLAMOR
-AM_CFLAGS += $(LIBGLAMOR_CFLAGS)
-libuxa_la_LIBADD += $(LIBGLAMOR_LIBS)
-libuxa_la_SOURCES += \
-	 intel_glamor.c \
-	 $(NULL)
-endif
-
 if DRI2
 AM_CFLAGS += $(DRI2_CFLAGS)
 libuxa_la_SOURCES += \
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index 8a4a340..395774a 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -60,8 +60,6 @@
 #include "intel_uxa.h"
 #endif
 
-#include "intel_glamor.h"
-
 #define KNOWN_MODE_FLAGS ((1<<14)-1)
 
 struct intel_drm_queue {
diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c
index dfe7a45..5b5e3fc 100644
--- a/src/uxa/intel_dri.c
+++ b/src/uxa/intel_dri.c
@@ -69,7 +69,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #if USE_UXA
 #include "intel_uxa.h"
 #endif
-#include "intel_glamor.h"
 
 typedef struct {
 	int refcnt;
@@ -109,58 +108,6 @@ static PixmapPtr get_front_buffer(DrawablePtr drawable)
 	return pixmap;
 }
 
-static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
-{
-	ScreenPtr screen = drawable->pScreen;
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	PixmapPtr old = get_drawable_pixmap(drawable);
-	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
-	GCPtr gc;
-
-	/* With a glamor pixmap, 2D pixmaps are created in texture
-	 * and without a static BO attached to it. To support DRI,
-	 * we need to create a new textured-drm pixmap and
-	 * need to copy the original content to this new textured-drm
-	 * pixmap, and then convert the old pixmap to a coherent
-	 * textured-drm pixmap which has a valid BO attached to it
-	 * and also has a valid texture, thus both glamor and DRI2
-	 * can access it.
-	 *
-	 */
-
-	/* Copy the current contents of the pixmap to the bo. */
-	gc = GetScratchGC(drawable->depth, screen);
-	if (gc) {
-		ValidateGC(&pixmap->drawable, gc);
-		gc->ops->CopyArea(drawable, &pixmap->drawable,
-				  gc,
-				  0, 0,
-				  drawable->width,
-				  drawable->height,
-				  0, 0);
-		FreeScratchGC(gc);
-	}
-
-	intel_uxa_set_pixmap_private(pixmap, NULL);
-
-	/* Exchange the underlying texture/image. */
-	intel_glamor_exchange_buffers(intel, old, pixmap);
-	/* And redirect the pixmap to the new bo (for 3D). */
-	intel_uxa_set_pixmap_private(old, priv);
-	old->refcnt++;
-
-	screen->ModifyPixmapHeader(old,
-				   drawable->width,
-				   drawable->height,
-				   0, 0,
-				   intel_pixmap_pitch(pixmap),
-				   NULL);
-	screen->DestroyPixmap(pixmap);
-	intel_get_screen_private(xf86ScreenToScrn(screen))->needs_flush = TRUE;
-	return old;
-}
-
 #if DRI2INFOREC_VERSION < 2
 static DRI2BufferPtr
 I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
@@ -172,7 +119,6 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 	DRI2BufferPtr buffers;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap, pDepthPixmap;
-	Bool is_glamor_pixmap = FALSE;
 	int i;
 
 	buffers = calloc(count, sizeof *buffers);
@@ -190,10 +136,8 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 		if (attachments[i] == DRI2BufferFrontLeft) {
 			pixmap = get_front_buffer(drawable);
 
-			if (pixmap == NULL) {
+			if (pixmap == NULL)
 				drawable = &(get_drawable_pixmap(drawable)->drawable);
-				is_glamor_pixmap = TRUE;
-			}
 		} else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) {
 			pixmap = pDepthPixmap;
 			pixmap->refcnt++;
@@ -231,9 +175,6 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 					screen->DestroyPixmap(pixmap);
 				goto unwind;
 			}
-
-			if (is_glamor_pixmap)
-				pixmap = fixup_glamor(drawable, pixmap);
 		}
 
 		if (attachments[i] == DRI2BufferDepth)
@@ -294,7 +235,6 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	DRI2Buffer2Ptr buffer;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap;
-	Bool is_glamor_pixmap = FALSE;
 
 	buffer = calloc(1, sizeof *buffer);
 	if (buffer == NULL)
@@ -308,11 +248,8 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	pixmap = NULL;
 	if (attachment == DRI2BufferFrontLeft) {
 		pixmap = get_front_buffer(drawable);
-
-		if (pixmap == NULL) {
+		if (pixmap == NULL)
 			drawable = &(get_drawable_pixmap(drawable)->drawable);
-			is_glamor_pixmap = TRUE;
-		}
 	}
 
 	if (pixmap == NULL) {
@@ -385,8 +322,6 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 			free(buffer);
 			return NULL;
 		}
-		if (is_glamor_pixmap)
-			pixmap = fixup_glamor(drawable, pixmap);
 	}
 
 	buffer->attachment = attachment;
@@ -764,8 +699,6 @@ intel_exchange_pixmap_buffers(struct intel_screen_private *intel, PixmapPtr fron
 	new_front->busy = 1;
 	new_back->busy = -1;
 
-	intel_glamor_exchange_buffers(intel, front, back);
-
 	DamageRegionProcessPending(&front->drawable);
 
 	return new_front;
@@ -795,38 +728,6 @@ I830DRI2ExchangeBuffers(struct intel_screen_private *intel, DRI2BufferPtr front,
 	dri_bo_reference (intel->front_buffer);
 }
 
-static PixmapPtr
-intel_glamor_create_back_pixmap(ScreenPtr screen,
-				PixmapPtr front_pixmap,
-				drm_intel_bo *back_bo)
-{
-	PixmapPtr back_pixmap;
-
-	back_pixmap = screen->CreatePixmap(screen,
-					   0,
-					   0,
-				           front_pixmap->drawable.depth,
-				           0);
-	if (back_pixmap == NULL)
-		return NULL;
-
-	screen->ModifyPixmapHeader(back_pixmap,
-				   front_pixmap->drawable.width,
-				   front_pixmap->drawable.height,
-				   0, 0,
-				   front_pixmap->devKind,
-				   0);
-	intel_set_pixmap_bo(back_pixmap, back_bo);
-	if (!intel_glamor_create_textured_pixmap(back_pixmap)) {
-		ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-			   "Failed to create textured back pixmap.\n");
-		screen->DestroyPixmap(back_pixmap);
-		return NULL;
-	}
-	return back_pixmap;
-}
-
 static drm_intel_bo *get_pixmap_bo(I830DRI2BufferPrivatePtr priv)
 {
 	drm_intel_bo *bo = intel_get_pixmap_bo(priv->pixmap);
@@ -885,10 +786,6 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 	}
 
 	if (intel->back_buffer == NULL) {
-		I830DRI2BufferPrivatePtr drvpriv;
-		PixmapPtr front_pixmap, back_pixmap;
-		ScreenPtr screen;
-
 		new_back = drm_intel_bo_alloc(intel->bufmgr, "front buffer",
 					      intel->front_buffer->size, 0);
 		if (new_back == NULL)
@@ -905,21 +802,6 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 
 		drm_intel_bo_disable_reuse(new_back);
 		dri_bo_flink(new_back, &intel->back_name);
-
-		if ((intel->uxa_flags & UXA_USE_GLAMOR)) {
-			screen = draw->pScreen;
-			drvpriv = info->front->driverPrivate;
-			front_pixmap = drvpriv->pixmap;
-
-			back_pixmap = intel_glamor_create_back_pixmap(screen,
-								      front_pixmap,
-								      new_back);
-			if (back_pixmap == NULL) {
-				drm_intel_bo_unreference(new_back);
-				return FALSE;
-			}
-			intel->back_pixmap = back_pixmap;
-		}
 	} else {
 		new_back = intel->back_buffer;
 		intel->back_buffer = NULL;
@@ -939,13 +821,8 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 
 	intel->back_buffer = intel->front_buffer;
 	drm_intel_bo_reference(intel->back_buffer);
-	if (!(intel->uxa_flags & UXA_USE_GLAMOR)) {
-		intel_set_pixmap_bo(priv->pixmap, new_back);
-		drm_intel_bo_unreference(new_back);
-	}
-	else
-		intel_exchange_pixmap_buffers(intel, priv->pixmap,
-					      intel->back_pixmap);
+	intel_exchange_pixmap_buffers(intel, priv->pixmap,
+				      intel->back_pixmap);
 
 	tmp_name = info->front->name;
 	info->front->name = intel->back_name;
diff --git a/src/uxa/intel_dri3.c b/src/uxa/intel_dri3.c
index 2dd2b55..6cb23bb 100644
--- a/src/uxa/intel_dri3.c
+++ b/src/uxa/intel_dri3.c
@@ -33,7 +33,6 @@
 #include "intel_uxa.h"
 #endif
 #include "dri3.h"
-#include "intel_glamor.h"
 
 static int
 intel_dri3_open(ScreenPtr screen,
@@ -66,10 +65,6 @@ static PixmapPtr intel_dri3_pixmap_from_fd(ScreenPtr screen,
 	PixmapPtr pixmap;
 	dri_bo *bo;
 
-        pixmap = intel_glamor_pixmap_from_fd(screen, fd, width, height, stride, depth, bpp);
-        if (pixmap)
-                return pixmap;
-
 	if (depth < 8)
 		return NULL;
 
@@ -118,10 +113,6 @@ static int intel_dri3_fd_from_pixmap(ScreenPtr screen,
 	struct intel_uxa_pixmap *priv;
 	int fd;
 
-        fd = intel_glamor_fd_from_pixmap(screen, pixmap, stride, size);
-        if (fd >= 0)
-                return fd;
-
 	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (!priv)
 		return -1;
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index ebd7498..ca8c613 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -72,7 +72,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "intel_uxa.h"
 #endif
 
-#include "intel_glamor.h"
 #include "intel_options.h"
 #include "i915_drm.h"
 
@@ -610,13 +609,6 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 		return FALSE;
 	}
 
-	if (!intel_glamor_pre_init(scrn)) {
-		PreInitCleanup(scrn);
-		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			"Failed to pre init glamor display.\n");
-		return FALSE;
-	}
-
 	/* Load the dri modules if requested. */
 #if HAVE_DRI2
 	if (intel->dri2 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri2"))
@@ -964,7 +956,6 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 	intel->CreateScreenResources = screen->CreateScreenResources;
 	screen->CreateScreenResources = i830CreateScreenResources;
 
-	intel_glamor_init(screen);
 	if (!xf86CrtcScreenInit(screen))
 		return FALSE;
 
@@ -1125,8 +1116,6 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 
 	DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
 
-	intel_glamor_close_screen(screen);
-
 	TimerFree(intel->cache_expire);
 	intel->cache_expire = NULL;
 
diff --git a/src/uxa/intel_glamor.c b/src/uxa/intel_glamor.c
deleted file mode 100644
index 286f365..0000000
--- a/src/uxa/intel_glamor.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including
- * the next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "xorg-server.h"
-#include <xf86.h>
-#define GLAMOR_FOR_XORG  1
-#include <glamor.h>
-
-#include "intel.h"
-#include "i915_drm.h"
-#include "intel_glamor.h"
-#include "intel_uxa.h"
-#include "intel_options.h"
-
-void
-intel_glamor_exchange_buffers(struct intel_screen_private *intel,
-			      PixmapPtr src,
-			      PixmapPtr dst)
-{
-	if (!(intel->uxa_flags & UXA_USE_GLAMOR))
-		return;
-	glamor_egl_exchange_buffers(src, dst);
-}
-
-XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0)
-		return NULL;
-
-	return glamor_xv_init(screen, num_ports);
-}
-
-Bool
-intel_glamor_create_screen_resources(ScreenPtr screen)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (!(intel->uxa_flags & UXA_USE_GLAMOR))
-		return TRUE;
-
-	if (!glamor_glyphs_init(screen))
-		return FALSE;
-
-	if (!glamor_egl_create_textured_screen_ext(screen,
-						   intel->front_buffer->handle,
-						   intel->front_pitch,
-						   &intel->back_pixmap))
-		return FALSE;
-
-	return TRUE;
-}
-
-static Bool
-intel_glamor_enabled(intel_screen_private *intel)
-{
-	const char *s;
-
-	s = xf86GetOptValString(intel->Options, OPTION_ACCEL_METHOD);
-	if (s == NULL)
-		return IS_DEFAULT_ACCEL_METHOD(GLAMOR);
-
-	return strcasecmp(s, "glamor") == 0;
-}
-
-Bool
-intel_glamor_pre_init(ScrnInfoPtr scrn)
-{
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	pointer glamor_module;
-	CARD32 version;
-
-	if (!intel_glamor_enabled(intel))
-		return TRUE;
-
-#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,15,0,0,0)
-	if (!xf86LoaderCheckSymbol("glamor_egl_init")) {
-		xf86DrvMsg(scrn->scrnIndex,  X_ERROR,
-			   "glamor requires Load \"glamoregl\" in "
-			   "Section \"Module\", disabling.\n");
-		return TRUE;
-	}
-#endif
-
-	/* Load glamor module */
-	if ((glamor_module = xf86LoadSubModule(scrn, GLAMOR_EGL_MODULE_NAME))) {
-		version = xf86GetModuleVersion(glamor_module);
-		if (version < MODULE_VERSION_NUMERIC(0,3,1)) {
-			xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			"Incompatible glamor version, required >= 0.3.0.\n");
-		} else {
-			if (glamor_egl_init(scrn, intel->drmSubFD)) {
-				xf86DrvMsg(scrn->scrnIndex, X_INFO,
-					   "glamor detected, initialising egl layer.\n");
-				intel->uxa_flags = UXA_GLAMOR_EGL_INITIALIZED;
-			} else
-				xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-					   "glamor detected, failed to initialize egl.\n");
-		}
-	} else
-		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-			   "glamor not available\n");
-
-	return TRUE;
-}
-
-PixmapPtr
-intel_glamor_pixmap_from_fd(ScreenPtr screen,
-                            int fd,
-                            CARD16 width,
-                            CARD16 height,
-                            CARD16 stride,
-                            CARD8 depth,
-                            CARD8 bpp)
-{
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,902,0)
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		return glamor_pixmap_from_fd(screen, fd, width, height, stride, depth, bpp);
-	else
-#endif
-		return NULL;
-}
-
-int
-intel_glamor_fd_from_pixmap(ScreenPtr screen,
-                            PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
-{
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,902,0)
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-                return glamor_fd_from_pixmap(screen, pixmap, stride, size);
-        else
-#endif
-                return -1;
-}
-
-PixmapPtr
-intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
-			   int depth, unsigned int usage)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		return glamor_create_pixmap(screen, w, h, depth, usage);
-	else
-		return NULL;
-}
-
-Bool
-intel_glamor_create_textured_pixmap(PixmapPtr pixmap)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_uxa_pixmap *priv;
-
-	if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0)
-		return TRUE;
-
-	priv = intel_uxa_get_pixmap_private(pixmap);
-	if (glamor_egl_create_textured_pixmap(pixmap, priv->bo->handle,
-					      intel_pixmap_pitch(pixmap))) {
-		drm_intel_bo_disable_reuse(priv->bo);
-		priv->pinned |= PIN_GLAMOR;
-		return TRUE;
-	} else
-		return FALSE;
-}
-
-void
-intel_glamor_destroy_pixmap(PixmapPtr pixmap)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-	intel_screen_private * intel;
-
-	intel = intel_get_screen_private(scrn);
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		glamor_egl_destroy_textured_pixmap(pixmap);
-}
-
-static void
-intel_glamor_need_flush(DrawablePtr pDrawable)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(pDrawable->pScreen);
-	intel_screen_private * intel;
-
-	intel = intel_get_screen_private(scrn);
-	intel->needs_flush = TRUE;
-}
-
-static void
-intel_glamor_finish_access(PixmapPtr pixmap, uxa_access_t access)
-{
-	switch(access) {
-	case UXA_ACCESS_RO:
-	case UXA_ACCESS_RW:
-	case UXA_GLAMOR_ACCESS_RO:
-		break;
-	case UXA_GLAMOR_ACCESS_RW:
-		intel_glamor_need_flush(&pixmap->drawable);
-		break;
-	default:
-		ErrorF("Invalid access mode %d\n", access);
-	}
-
-	return;
-}
-
-Bool
-intel_glamor_init(ScreenPtr screen)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if ((intel->uxa_flags & UXA_GLAMOR_EGL_INITIALIZED) == 0)
-		goto fail;
-
-	if (!glamor_init(screen,
-#if defined(GLAMOR_NO_DRI3)
-			 /* Not doing DRI3 yet, since Present support hasn't landed. */
-			 GLAMOR_NO_DRI3 |
-#endif
-			 GLAMOR_INVERTED_Y_AXIS |
-			 GLAMOR_USE_EGL_SCREEN)) {
-		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			   "Failed to initialize glamor.\n");
-		goto fail;
-	}
-
-	if (!glamor_egl_init_textured_pixmap(screen)) {
-		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			   "Failed to initialize textured pixmap of screen for glamor.\n");
-		goto fail;
-	}
-
-	intel->uxa_driver->flags |= UXA_USE_GLAMOR;
-	intel->uxa_flags |= intel->uxa_driver->flags;
-
-	intel->uxa_driver->finish_access = intel_glamor_finish_access;
-
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "Use GLAMOR acceleration.\n");
-	return TRUE;
-
-  fail:
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "Use legacy UXA acceleration.\n");
-	return FALSE;
-}
-
-void
-intel_glamor_flush(intel_screen_private * intel)
-{
-	ScreenPtr screen;
-
-	screen = xf86ScrnToScreen(intel->scrn);
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		glamor_block_handler(screen);
-}
-
-Bool
-intel_glamor_close_screen(ScreenPtr screen)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		intel->uxa_flags &= ~UXA_USE_GLAMOR;
-
-	return TRUE;
-}
diff --git a/src/uxa/intel_glamor.h b/src/uxa/intel_glamor.h
deleted file mode 100644
index a2ca448..0000000
--- a/src/uxa/intel_glamor.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including
- * the next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#ifndef INTEL_GLAMOR_H
-#define INTEL_GLAMOR_H
-
-#include <xf86xv.h>
-
-#ifdef USE_GLAMOR
-
-Bool intel_glamor_pre_init(ScrnInfoPtr scrn);
-Bool intel_glamor_init(ScreenPtr screen);
-Bool intel_glamor_create_screen_resources(ScreenPtr screen);
-Bool intel_glamor_close_screen(ScreenPtr screen);
-void intel_glamor_free_screen(int scrnIndex, int flags);
-
-void intel_glamor_flush(intel_screen_private * intel);
-
-Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap);
-void intel_glamor_destroy_pixmap(PixmapPtr pixmap);
-PixmapPtr intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
-				     int depth, unsigned int usage);
-void intel_glamor_exchange_buffers(struct intel_screen_private *intel, PixmapPtr src, PixmapPtr dst);
-XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports);
-
-int
-intel_glamor_fd_from_pixmap(ScreenPtr screen,
-                            PixmapPtr pixmap, CARD16 *stride, CARD32 *size);
-
-PixmapPtr
-intel_glamor_pixmap_from_fd(ScreenPtr screen,
-                            int fd,
-                            CARD16 width,
-                            CARD16 height,
-                            CARD16 stride,
-                            CARD8 depth,
-                            CARD8 bpp);
-
-#else
-
-static inline Bool intel_glamor_pre_init(ScrnInfoPtr scrn) { return TRUE; }
-static inline Bool intel_glamor_init(ScreenPtr screen) { return TRUE; }
-static inline Bool intel_glamor_create_screen_resources(ScreenPtr screen) { return TRUE; }
-static inline Bool intel_glamor_close_screen(ScreenPtr screen) { return TRUE; }
-static inline void intel_glamor_free_screen(int scrnIndex, int flags) { }
-
-static inline void intel_glamor_flush(intel_screen_private * intel) { }
-
-static inline Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap) { return TRUE; }
-static inline void intel_glamor_destroy_pixmap(PixmapPtr pixmap) { }
-
-static inline PixmapPtr intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
-						   int depth, unsigned int usage) { return NULL; }
-
-static inline void intel_glamor_exchange_buffers(struct intel_screen_private *intel, PixmapPtr src, PixmapPtr dst) {}
-static inline XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports) { return NULL; }
-static inline PixmapPtr intel_glamor_pixmap_from_fd(ScreenPtr screen,
-                                                    int fd,
-                                                    CARD16 width,
-                                                    CARD16 height,
-                                                    CARD16 stride,
-                                                    CARD8 depth,
-                                                    CARD8 bpp) { return NULL; }
-
-static inline int
-intel_glamor_fd_from_pixmap(ScreenPtr screen,
-                            PixmapPtr pixmap, CARD16 *stride, CARD32 *size) { return -1; }
-#endif
-
-#endif /* INTEL_GLAMOR_H */
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index 1746e3d..590ff5d 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -41,7 +41,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "intel.h"
 #include "intel_uxa.h"
-#include "intel_glamor.h"
 
 #include "i830_reg.h"
 #include "i915_drm.h"
@@ -657,16 +656,7 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 	dri_bo *bo = priv->bo;
 	int ret;
 
-	/* Transitioning to glamor acceleration, we need to flush all pending
-	 * usage by UXA. */
-	if (access == UXA_GLAMOR_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RO) {
-		if (!list_is_empty(&priv->batch))
-			intel_batch_submit(scrn);
-		return TRUE;
-	}
-
 	/* When falling back to swrast, flush all pending operations */
-	intel_glamor_flush(intel);
 	if (access == UXA_ACCESS_RW || priv->dirty)
 		intel_batch_submit(scrn);
 
@@ -692,9 +682,6 @@ static void intel_uxa_finish_access(PixmapPtr pixmap, uxa_access_t access)
 {
 	struct intel_uxa_pixmap *priv;
 
-	if (access == UXA_GLAMOR_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RO)
-		return;
-
 	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (priv == NULL)
 		return;
@@ -963,7 +950,6 @@ void intel_uxa_block_handler(intel_screen_private *intel)
 	 * and beyond rendering results may not hit the
 	 * framebuffer until significantly later.
 	 */
-	intel_glamor_flush(intel);
 	intel_flush_rendering(intel);
 	intel_throttle(intel);
 }
@@ -977,12 +963,6 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 	struct intel_uxa_pixmap *priv;
 	PixmapPtr pixmap, new_pixmap = NULL;
 
-	if (!(usage & INTEL_CREATE_PIXMAP_DRI2)) {
-		pixmap = intel_glamor_create_pixmap(screen, w, h, depth, usage);
-		if (pixmap)
-			return pixmap;
-	}
-
 	if (w > 32767 || h > 32767)
 		return NullPixmap;
 
@@ -1061,35 +1041,10 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		intel_uxa_set_pixmap_private(pixmap, priv);
 
 		screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
-
-		if (!intel_glamor_create_textured_pixmap(pixmap))
-			goto fallback_glamor;
 	}
 
 	return pixmap;
 
-fallback_glamor:
-	if (usage & INTEL_CREATE_PIXMAP_DRI2) {
-	/* XXX need further work to handle the DRI2 failure case.
-	 * Glamor don't know how to handle a BO only pixmap. Put
-	 * a warning indicator here.
-	 */
-		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-			   "Failed to create textured DRI2 pixmap.");
-		return pixmap;
-	}
-	/* Create textured pixmap failed means glamor failed to
-	 * create a texture from current BO for some reasons. We turn
-	 * to create a new glamor pixmap and clean up current one.
-	 * One thing need to be noted, this new pixmap doesn't
-	 * has a priv and bo attached to it. It's glamor's responsbility
-	 * to take care of it. Glamor will mark this new pixmap as a
-	 * texture only pixmap and will never fallback to DDX layer
-	 * afterwards.
-	 */
-	new_pixmap = intel_glamor_create_pixmap(screen, w, h,
-						depth, usage);
-	dri_bo_unreference(priv->bo);
 fallback_priv:
 	free(priv);
 fallback_pixmap:
@@ -1102,10 +1057,8 @@ fallback_pixmap:
 
 static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap)
 {
-	if (pixmap->refcnt == 1) {
-		intel_glamor_destroy_pixmap(pixmap);
+	if (pixmap->refcnt == 1)
 		intel_uxa_set_pixmap_bo(pixmap, NULL);
-	}
 	fbDestroyPixmap(pixmap);
 	return TRUE;
 }
@@ -1141,9 +1094,6 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 	if (intel_uxa_get_pixmap_private(pixmap) == NULL)
 		goto err;
 
-	if (!intel_glamor_create_screen_resources(screen))
-		goto err;
-
 	intel_uxa_get_pixmap_private(pixmap)->pinned |= PIN_SCANOUT;
 	scrn->displayWidth = intel->front_pitch / intel->cpp;
 
diff --git a/src/uxa/intel_uxa.h b/src/uxa/intel_uxa.h
index f449b54..3d495ba 100644
--- a/src/uxa/intel_uxa.h
+++ b/src/uxa/intel_uxa.h
@@ -40,7 +40,6 @@ struct intel_uxa_pixmap {
 #define PIN_DRI2 0x2
 #define PIN_DRI3 0x4
 #define PIN_PRIME 0x8
-#define PIN_GLAMOR 0x10
 };
 
 #if HAS_DEVPRIVATEKEYREC
diff --git a/src/uxa/intel_uxa_video.c b/src/uxa/intel_uxa_video.c
index c5a1956..8287be4 100644
--- a/src/uxa/intel_uxa_video.c
+++ b/src/uxa/intel_uxa_video.c
@@ -74,7 +74,6 @@
 #define _INTEL_XVMC_SERVER_
 #include "intel_xvmc.h"
 #endif
-#include "intel_glamor.h"
 
 /* overlay debugging printf function */
 #if 0
diff --git a/src/uxa/intel_video.c b/src/uxa/intel_video.c
index 33d447c..75c7f20 100644
--- a/src/uxa/intel_video.c
+++ b/src/uxa/intel_video.c
@@ -78,7 +78,6 @@
 #define _INTEL_XVMC_SERVER_
 #include "intel_xvmc.h"
 #endif
-#include "intel_glamor.h"
 #include "intel_uxa.h"
 #include "intel_video_overlay.h"
 
@@ -163,7 +162,7 @@ void intel_video_init(ScreenPtr screen)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	XF86VideoAdaptorPtr *adaptors = NULL, *newAdaptors = NULL;
-	XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL, glamorAdaptor = NULL;
+	XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL;
 	int num_adaptors = xf86XVListGenericAdaptors(scrn, &adaptors);
 
 	/* Give our adaptor list enough space for the overlay and/or texture video
@@ -213,21 +212,12 @@ void intel_video_init(ScreenPtr screen)
 		}
 	}
 
-	glamorAdaptor = intel_glamor_xv_init(screen, 16);
-	if (glamorAdaptor != NULL)
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "Set up textured video using glamor\n");
-
-
 	if (overlayAdaptor && intel->XvPreferOverlay)
 		adaptors[num_adaptors++] = overlayAdaptor;
 
 	if (texturedAdaptor)
 		adaptors[num_adaptors++] = texturedAdaptor;
 
-	if (glamorAdaptor)
-		adaptors[num_adaptors++] = glamorAdaptor;
-
 	if (overlayAdaptor && !intel->XvPreferOverlay)
 		adaptors[num_adaptors++] = overlayAdaptor;
 
diff --git a/src/uxa/uxa-accel.c b/src/uxa/uxa-accel.c
index 9e7879b..0b6538e 100644
--- a/src/uxa/uxa-accel.c
+++ b/src/uxa/uxa-accel.c
@@ -32,7 +32,6 @@
 #include <dix-config.h>
 #endif
 #include "uxa-priv.h"
-#include "uxa-glamor.h"
 #include <X11/fonts/fontstruct.h>
 #include "dixfontstr.h"
 #include "uxa.h"
@@ -50,21 +49,6 @@ uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	int x1, x2, y;
 	int off_x, off_y;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_fill_spans_nf(pDrawable,
-						  pGC, n, ppt, pwidth, fSorted);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
@@ -210,26 +194,8 @@ static void
 uxa_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 	      int w, int h, int leftPad, int format, char *bits)
 {
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_put_image_nf(pDrawable,
-						 pGC, depth, x, y, w, h,
-						 leftPad, format, bits);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (!uxa_do_put_image(pDrawable, pGC, depth, x, y, w, h, format, bits,
 			      PixmapBytePad(w, pDrawable->depth))) {
-fallback:
 		uxa_check_put_image(pDrawable, pGC, depth, x, y, w, h, leftPad,
 				    format, bits);
 	}
@@ -374,26 +340,6 @@ uxa_copy_n_to_n(DrawablePtr pSrcDrawable,
 	int dst_off_x, dst_off_y;
 	PixmapPtr pSrcPixmap, pDstPixmap;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pSrcDrawable, UXA_GLAMOR_ACCESS_RO)) {
-			if (uxa_prepare_access(pDstDrawable, UXA_GLAMOR_ACCESS_RW)) {
-				ok = glamor_copy_n_to_n_nf(pSrcDrawable, pDstDrawable,
-							   pGC, pbox, nbox, dx, dy,
-							   reverse, upsidedown, bitplane,
-							   closure);
-				uxa_finish_access(pDstDrawable, UXA_GLAMOR_ACCESS_RW);
-			}
-			uxa_finish_access(pSrcDrawable, UXA_GLAMOR_ACCESS_RO);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
@@ -560,19 +506,6 @@ uxa_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 {
 	int i;
 	xRectangle *prect;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_point_nf(pDrawable, pGC, mode, npt, ppt);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (ok)
-			return;
-	}
 
 	/* If we can't reuse the current GC as is, don't bother accelerating the
 	 * points.
@@ -611,19 +544,6 @@ uxa_poly_lines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 	xRectangle *prect;
 	int x1, x2, y1, y2;
 	int i;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_lines_nf(pDrawable, pGC, mode, npt, ppt);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (ok)
-			return;
-	}
 
 	/* Don't try to do wide lines or non-solid fill style. */
 	if (pGC->lineWidth != 0 || pGC->lineStyle != LineSolid ||
@@ -722,19 +642,6 @@ uxa_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
 {
 	xRectangle *prect;
 	int i;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_segment_nf(pDrawable, pGC, nseg, pSeg);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (ok)
-			return;
-	}
 
 	/* Don't try to do wide lines or non-solid fill style. */
 	if (pGC->lineWidth != 0 || pGC->lineStyle != LineSolid ||
@@ -782,20 +689,6 @@ uxa_poly_fill_rect(DrawablePtr pDrawable,
 	int xorg, yorg;
 	int n;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_fill_rect_nf(pDrawable, pGC, nrect, prect);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			uxa_check_poly_fill_rect(pDrawable, pGC, nrect, prect);
-
-		return;
-	}
-
 	/* Compute intersection of rects and clip region */
 	pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
 	REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
@@ -905,25 +798,6 @@ uxa_get_spans(DrawablePtr pDrawable,
 	      int wMax,
 	      DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_get_spans_nf(pDrawable, wMax, ppt,
-						 pwidth, nspans, pdstStart);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
-fallback:
 	uxa_check_get_spans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 }
 
@@ -931,25 +805,6 @@ static void
 uxa_set_spans(DrawablePtr pDrawable, GCPtr gc, char *src,
                  DDXPointPtr points, int *widths, int n, int sorted)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_set_spans_nf(pDrawable, gc, src,
-						 points, widths, n, sorted);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
-fallback:
 	uxa_check_set_spans(pDrawable, gc, src, points, widths, n, sorted);
 }
 
@@ -958,27 +813,6 @@ uxa_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 	       int srcx, int srcy, int w, int h, int dstx, int dsty,
 	       unsigned long bitPlane)
 {
-	ScreenPtr screen = pDst->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		RegionPtr region = NULL;
-		int ok = 0;
-
-		if (uxa_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW)) {
-			if (uxa_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO)) {
-				ok = glamor_copy_plane_nf(pSrc, pDst, pGC, srcx, srcy, w, h,
-							  dstx, dsty, bitPlane, &region);
-				uxa_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-			}
-			uxa_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return region;
-	}
-
-fallback:
 	return uxa_check_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
 				    dstx, dsty, bitPlane);
 }
@@ -988,22 +822,6 @@ uxa_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
 		    int x, int y, unsigned int nglyph,
 		    CharInfoPtr * ppci, pointer pglyphBase)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_image_glyph_blt_nf(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return;
-	}
-
-fallback:
 	uxa_check_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
 }
 
@@ -1012,22 +830,6 @@ uxa_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
 		   int x, int y, unsigned int nglyph,
 		   CharInfoPtr * ppci, pointer pglyphBase)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_glyph_blt_nf(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return;
-	}
-
-fallback:
 	uxa_check_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
 }
 
@@ -1035,25 +837,6 @@ static void
 uxa_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
 		DrawablePtr pDrawable, int w, int h, int x, int y)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			if (uxa_prepare_access(&pBitmap->drawable, UXA_GLAMOR_ACCESS_RO)) {
-				ok = glamor_push_pixels_nf(pGC, pBitmap, pDrawable, w, h, x, y);
-				uxa_finish_access(&pBitmap->drawable, UXA_GLAMOR_ACCESS_RO);
-			}
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return;
-	}
-
-fallback:
 	uxa_check_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y);
 }
 
@@ -1264,20 +1047,6 @@ uxa_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
 	Box.x2 = Box.x1 + w;
 	Box.y2 = Box.y1 + h;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		ok = 0;
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_get_image_nf(pDrawable, x, y, w, h,
-						 format, planeMask, d);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
diff --git a/src/uxa/uxa-glamor.h b/src/uxa/uxa-glamor.h
deleted file mode 100644
index 5ff19e0..0000000
--- a/src/uxa/uxa-glamor.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including
- * the next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Zhigang Gong <zhigang.gong at linux.intel.com>
- *
- */
-
-#ifndef UXA_GLAMOR_H
-#define UXA_GLAMOR_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef USE_GLAMOR
-#include "glamor.h"
-#else
-#define glamor_fill_spans_nf(...)	FALSE
-#define glamor_poly_fill_rect_nf(...)	FALSE
-#define glamor_put_image_nf(...)	FALSE
-#define glamor_copy_n_to_n_nf(...)	FALSE
-#define glamor_get_spans_nf(...)	FALSE
-#define glamor_set_spans_nf(...)	FALSE
-#define glamor_get_image_nf(...)	FALSE
-#define glamor_glyphs_nf(...)		FALSE
-#define glamor_glyph_unrealize(...)	do { } while(0)
-#define glamor_composite_nf(...)	FALSE
-#define glamor_composite_rects_nf(...)	FALSE
-#define glamor_trapezoids_nf(...)	FALSE
-#define glamor_triangles_nf(...)	FALSE
-#define glamor_add_traps_nf(...)	FALSE
-#define glamor_create_gc(...)		FALSE
-#define glamor_validate_gc(...)		do { } while(0)
-#define glamor_poly_point_nf(...)	FALSE
-#define glamor_poly_segment_nf(...)	FALSE
-#define glamor_poly_lines_nf(...)	FALSE
-#define glamor_push_pixels_nf(...)	FALSE
-#define glamor_copy_plane_nf(...)	FALSE
-#define glamor_image_glyph_blt_nf(...)	FALSE
-#define glamor_poly_glyph_blt_nf(...)	FALSE
-#endif
-
-#endif /* UXA_GLAMOR_H */
diff --git a/src/uxa/uxa-glyphs.c b/src/uxa/uxa-glyphs.c
index 7f35863..d24ba51 100644
--- a/src/uxa/uxa-glyphs.c
+++ b/src/uxa/uxa-glyphs.c
@@ -65,7 +65,6 @@
 #include <stdlib.h>
 
 #include "uxa-priv.h"
-#include "uxa-glamor.h"
 #include "common.h"
 
 /* Width of the pixmaps we use for the caches; this should be less than
@@ -210,10 +209,6 @@ bail:
 Bool uxa_glyphs_init(ScreenPtr pScreen)
 {
 
-	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR)
-		return TRUE;
 #if HAS_DIXREGISTERPRIVATEKEY
 	if (!dixRegisterPrivateKey(&uxa_glyph_key, PRIVATE_GLYPH, 0))
 		return FALSE;
@@ -308,12 +303,6 @@ uxa_glyph_unrealize(ScreenPtr screen,
 		    GlyphPtr glyph)
 {
 	struct uxa_glyph *priv;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		glamor_glyph_unrealize(screen, glyph);
-		return;
-	}
 
 	/* Use Lookup in case we have not attached to this glyph. */
 	priv = dixLookupPrivate(&glyph->devPrivates, &uxa_glyph_key);
@@ -975,23 +964,6 @@ uxa_glyphs(CARD8 op,
 	ScreenPtr screen = pDst->pDrawable->pScreen;
 	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		ok = glamor_glyphs_nf(op,
-				     pSrc, pDst, maskFormat,
-				     xSrc, ySrc, nlist, list, glyphs);
-		uxa_picture_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (!uxa_screen->info->prepare_composite ||
 	    uxa_screen->force_fallback ||
 	    !uxa_drawable_is_offscreen(pDst->pDrawable) ||
diff --git a/src/uxa/uxa-render.c b/src/uxa/uxa-render.c
index a138f16..0c3e856 100644
--- a/src/uxa/uxa-render.c
+++ b/src/uxa/uxa-render.c
@@ -29,23 +29,10 @@
 #include <stdlib.h>
 
 #include "uxa-priv.h"
-#include "uxa-glamor.h"
 
 #ifdef RENDER
 #include "mipict.h"
 
-/* Note: when using glamor we can not fail through to the ordinary UXA
- * code paths, as glamor keeps an internal texture which will become
- * inconsistent with the original bo. (The texture is replaced whenever
- * the format changes, e.g. switching between xRGB and ARGB, for which mesa
- * will allocate its own bo.)
- *
- * Ergo it is unsafe to fall through to the original backend operations if
- * glamor is enabled.
- *
- * XXX This has some serious implications for mixing Render, DRI, scanout...
- */
-
 static void uxa_composite_fallback_pict_desc(PicturePtr pict, char *string,
 					     int n)
 {
@@ -1357,30 +1344,6 @@ uxa_composite(CARD8 op,
 	RegionRec region;
 	int tx, ty;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		if (pMask)
-			uxa_picture_prepare_access(pMask, UXA_GLAMOR_ACCESS_RO);
-
-		ok = glamor_composite_nf(op,
-					 pSrc, pMask, pDst, xSrc, ySrc,
-					 xMask, yMask, xDst, yDst,
-					 width, height);
-
-		if (pMask)
-			uxa_picture_finish_access(pMask, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
@@ -1722,25 +1685,7 @@ uxa_trapezoids(CARD8 op, PicturePtr src, PicturePtr dst,
 	BoxRec bounds;
 	Bool direct;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(dst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(src, UXA_GLAMOR_ACCESS_RO);
-		ok = glamor_trapezoids_nf(op,
-					  src, dst, maskFormat, xSrc,
-					  ySrc, ntrap, traps);
-		uxa_picture_finish_access(src, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(dst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback) {
-fallback:
 		uxa_check_trapezoids(op, src, dst, maskFormat, xSrc, ySrc, ntrap, traps);
 		return;
 	}
@@ -1951,25 +1896,7 @@ uxa_triangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 	BoxRec bounds;
 	Bool direct;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		ok = glamor_triangles_nf(op,
-				        pSrc, pDst, maskFormat, xSrc,
-					ySrc, ntri, tris);
-		uxa_picture_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback) {
-fallback:
 		uxa_check_triangles(op, pSrc, pDst, maskFormat,
 				    xSrc, ySrc, ntri, tris);
 		return;
@@ -2051,23 +1978,5 @@ void
 uxa_add_traps(PicturePtr pPicture,
 	      INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
 {
-	ScreenPtr pScreen = pPicture->pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pPicture, UXA_GLAMOR_ACCESS_RW);
-		ok = glamor_add_traps_nf(pPicture,
-					 x_off, y_off, ntrap, traps);
-		uxa_picture_finish_access(pPicture, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
-fallback:
 	uxa_check_add_traps(pPicture, x_off, y_off, ntrap, traps);
 }
diff --git a/src/uxa/uxa.c b/src/uxa/uxa.c
index c8d7900..b682dfd 100644
--- a/src/uxa/uxa.c
+++ b/src/uxa/uxa.c
@@ -38,7 +38,6 @@
 #include <X11/fonts/fontstruct.h>
 #include "dixfontstr.h"
 #include "uxa.h"
-#include "uxa-glamor.h"
 
 #if HAS_DEVPRIVATEKEYREC
 DevPrivateKeyRec uxa_screen_index;
@@ -184,21 +183,12 @@ void uxa_finish_access(DrawablePtr pDrawable, uxa_access_t access)
 static void
 uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 {
-	uxa_screen_t *uxa_screen = uxa_get_screen(pGC->pScreen);
 	/* fbValidateGC will do direct access to pixmaps if the tiling has
 	 * changed.
 	 * Preempt fbValidateGC by doing its work and masking the change out, so
 	 * that we can do the Prepare/finish_access.
 	 */
 
-	/* If we are using GLAMOR, then the tile or stipple pixmap
-	 * may be pure GLAMOR pixmap, then we should let the glamor
-	 * to do the validation.
-	 */
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		glamor_validate_gc(pGC, changes, pDrawable);
-		goto set_ops;
-	}
 #ifdef FB_24_32BIT
 	if ((changes & GCTile) && fbGetRotatedPixmap(pGC)) {
 		(*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC));
@@ -267,7 +257,6 @@ uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 		fbValidateGC(pGC, changes, pDrawable);
 	}
 
-set_ops:
 	pGC->ops = (GCOps *) & uxa_ops;
 }
 
diff --git a/src/uxa/uxa.h b/src/uxa/uxa.h
index b8569f0..d08c601 100644
--- a/src/uxa/uxa.h
+++ b/src/uxa/uxa.h
@@ -46,8 +46,6 @@
 typedef enum {
 	UXA_ACCESS_RO,
 	UXA_ACCESS_RW,
-	UXA_GLAMOR_ACCESS_RO,
-	UXA_GLAMOR_ACCESS_RW
 } uxa_access_t;
 
 /**
@@ -545,20 +543,6 @@ typedef struct _UxaDriver {
  */
 #define UXA_TWO_BITBLT_DIRECTIONS	(1 << 2)
 
-/**
- * UXA_USE_GLAMOR indicates to use glamor acceleration to perform rendering.
- * And if glamor fail to accelerate the rendering, then goto fallback to
- * use CPU to do the rendering. This flag will be set only when glamor get
- * initialized successfully.
- * Note, in ddx close screen, this bit need to be cleared.
- */
-#define UXA_USE_GLAMOR			(1 << 3)
-
-/* UXA_GLAMOR_EGL_INITIALIZED indicates glamor egl layer get initialized
- * successfully. UXA layer does not use this flag, before call to
- * glamor_init, ddx need to check this flag. */
-#define UXA_GLAMOR_EGL_INITIALIZED	(1 << 4)
-
 /** @} */
 /** @name UXA CreatePixmap hint flags
  * @{
commit 4281bbdd5be1f846c217cdf6d09536779cd324ce
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 24 08:50:55 2014 +0100

    sna: Fix debug mmapping of active + released aux buffers
    
    The debug code wants to print the batch and the aux buffers. To do so,
    it needs to bypass the assertions on the lifetime of the buffers.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 4f79301..dd91801 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -436,10 +436,6 @@ static void *__kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo)
 
 	DBG(("%s(handle=%d, size=%d)\n", __FUNCTION__,
 	     bo->handle, bytes(bo)));
-	assert(bo->proxy == NULL);
-	assert(!bo->snoop);
-	assert(num_pages(bo) <= kgem->aperture_mappable / 2);
-	assert(kgem->gen != 021 || bo->tiling != I915_TILING_Y);
 
 	VG_CLEAR(gtt);
 retry_gtt:
@@ -492,8 +488,6 @@ static void *__kgem_bo_map__wc(struct kgem *kgem, struct kgem_bo *bo)
 
 	DBG(("%s(handle=%d, size=%d)\n", __FUNCTION__,
 	     bo->handle, bytes(bo)));
-	assert(bo->proxy == NULL);
-	assert(!bo->snoop);
 	assert(kgem->has_wc_mmap);
 
 	VG_CLEAR(wc);
@@ -6136,9 +6130,16 @@ static void *__kgem_bo_map__gtt_or_wc(struct kgem *kgem, struct kgem_bo *bo)
 	void *ptr;
 
 	DBG(("%s: handle=%d\n", __FUNCTION__, bo->handle));
+
+	assert(bo->proxy == NULL);
+	assert(!bo->snoop);
+
 	kgem_trim_vma_cache(kgem, MAP_GTT, bucket(bo));
 
 	if (bo->tiling || !kgem->has_wc_mmap) {
+		assert(num_pages(bo) <= kgem->aperture_mappable / 2);
+		assert(kgem->gen != 021 || bo->tiling != I915_TILING_Y);
+
 		ptr = bo->map__gtt;
 		if (ptr == NULL)
 			ptr = __kgem_bo_map__gtt(kgem, bo);
@@ -6250,28 +6251,11 @@ void *kgem_bo_map__wc(struct kgem *kgem, struct kgem_bo *bo)
 	return __kgem_bo_map__wc(kgem, bo);
 }
 
-void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo)
-{
-	return kgem_bo_map__async(kgem, bo);
-}
-
-void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo)
+static void *__kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo)
 {
 	struct drm_i915_gem_mmap mmap_arg;
 	int err;
 
-	DBG(("%s(handle=%d, size=%d, map=%p:%p)\n",
-	     __FUNCTION__, bo->handle, bytes(bo), bo->map__gtt, bo->map__cpu));
-	assert(!bo->purged);
-	assert(list_is_empty(&bo->list));
-	assert(bo->proxy == NULL);
-	assert_tiling(kgem, bo);
-
-	if (bo->map__cpu)
-		return MAP(bo->map__cpu);
-
-	kgem_trim_vma_cache(kgem, MAP_CPU, bucket(bo));
-
 retry:
 	VG_CLEAR(mmap_arg);
 	mmap_arg.handle = bo->handle;
@@ -6297,6 +6281,45 @@ retry:
 	return bo->map__cpu = (void *)(uintptr_t)mmap_arg.addr_ptr;
 }
 
+void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo)
+{
+	DBG(("%s(handle=%d, size=%d, map=%p:%p)\n",
+	     __FUNCTION__, bo->handle, bytes(bo), bo->map__gtt, bo->map__cpu));
+	assert(!bo->purged);
+	assert(list_is_empty(&bo->list));
+	assert(bo->proxy == NULL);
+	assert_tiling(kgem, bo);
+
+	if (bo->map__cpu)
+		return MAP(bo->map__cpu);
+
+	kgem_trim_vma_cache(kgem, MAP_CPU, bucket(bo));
+
+	return __kgem_bo_map__cpu(kgem, bo);
+}
+
+void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo)
+{
+	void *ptr;
+
+	if (bo->tiling == I915_TILING_NONE && kgem->has_llc) {
+		ptr = MAP(bo->map__cpu);
+		if (ptr == NULL)
+			ptr = __kgem_bo_map__cpu(kgem, bo);
+	} else if (bo->tiling || !kgem->has_wc_mmap) {
+		ptr = bo->map__gtt;
+		if (ptr == NULL)
+			ptr = __kgem_bo_map__gtt(kgem, bo);
+	} else {
+		ptr = bo->map__wc;
+		if (ptr == NULL)
+			ptr = __kgem_bo_map__wc(kgem, bo);
+	}
+
+	return ptr;
+}
+
+
 uint32_t kgem_bo_flink(struct kgem *kgem, struct kgem_bo *bo)
 {
 	struct drm_gem_flink flink;
commit 87802b3402ec4a829c6507b4b78fcd03e30b6fe1
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 23 10:34:44 2014 +0100

    sna: Experimental support for write-combining mmaps
    
    If we have a linear buffer, we can request the kernel mmap it directly
    with write-combining without having to pin it into the GTT. This allows
    us to efficiently upload very large buffers, and can avoid the dreaded
    aperture thrashing.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index 8b34c77..75fd3b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -760,6 +760,16 @@ if test "x$RENDERNODE" = "xyes"; then
 	xp_msg="$xp_msg rendernode"
 fi
 
+AC_ARG_ENABLE(wc-mmap,
+	      AS_HELP_STRING([--enable-wc-map],
+			     [Enable use of WriteCombining mmaps [default=no]]),
+	      [WC_MMAP="$enableval"],
+	      [WC_MMAP="no"])
+if test "x$WC_MMAP" = "xyes"; then
+	AC_DEFINE(USE_WC_MMAP,1,[Enable use of WriteCombining mmaps])
+	xp_msg="$xp_msg mmap(wc)"
+fi
+
 AC_ARG_ENABLE(create2,
 	      AS_HELP_STRING([--enable-create2],
 			     [Enable use of create2 ioctl (experimental) [default=no]]),
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 9047437..4f79301 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -83,6 +83,7 @@ search_snoop_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags);
 #define DBG_NO_FAST_RELOC 0
 #define DBG_NO_HANDLE_LUT 0
 #define DBG_NO_WT 0
+#define DBG_NO_WC_MMAP 0
 #define DBG_DUMP 0
 #define DBG_NO_MALLOC_CACHE 0
 
@@ -95,6 +96,11 @@ search_snoop_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags);
 #define SHOW_BATCH_BEFORE 0
 #define SHOW_BATCH_AFTER 0
 
+#if !USE_WC_MMAP
+#undef DBG_NO_WC_MMAP
+#define DBG_NO_WC_MMAP 1
+#endif
+
 #if 0
 #define ASSERT_IDLE(kgem__, handle__) assert(!__kgem_busy(kgem__, handle__))
 #define ASSERT_MAYBE_IDLE(kgem__, handle__, expect__) assert(!(expect__) || !__kgem_busy(kgem__, handle__))
@@ -127,12 +133,14 @@ search_snoop_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags);
 #define LOCAL_I915_PARAM_HAS_BLT		11
 #define LOCAL_I915_PARAM_HAS_RELAXED_FENCING	12
 #define LOCAL_I915_PARAM_HAS_RELAXED_DELTA	15
+#define LOCAL_I915_PARAM_HAS_LLC		17
 #define LOCAL_I915_PARAM_HAS_SEMAPHORES		20
 #define LOCAL_I915_PARAM_HAS_SECURE_BATCHES	23
 #define LOCAL_I915_PARAM_HAS_PINNED_BATCHES	24
 #define LOCAL_I915_PARAM_HAS_NO_RELOC		25
 #define LOCAL_I915_PARAM_HAS_HANDLE_LUT		26
 #define LOCAL_I915_PARAM_HAS_WT			27
+#define LOCAL_I915_PARAM_MMAP_VERSION		29
 
 #define LOCAL_I915_EXEC_IS_PINNED		(1<<10)
 #define LOCAL_I915_EXEC_NO_RELOC		(1<<11)
@@ -179,6 +187,17 @@ struct local_i915_gem_caching {
 #define LOCAL_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + LOCAL_I915_GEM_SET_CACHING, struct local_i915_gem_caching)
 #define LOCAL_IOCTL_I915_GEM_GET_CACHING DRM_IOW(DRM_COMMAND_BASE + LOCAL_I915_GEM_GET_CACHING, struct local_i915_gem_caching)
 
+struct local_i915_gem_mmap2 {
+	uint32_t handle;
+	uint32_t pad;
+	uint64_t offset;
+	uint64_t size;
+	uint64_t addr_ptr;
+	uint64_t flags;
+#define I915_MMAP_WC 0x1
+};
+#define LOCAL_IOCTL_I915_GEM_MMAP_v2 DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct local_i915_gem_mmap2)
+
 struct kgem_buffer {
 	struct kgem_bo base;
 	void *mem;
@@ -411,7 +430,7 @@ static bool __kgem_throttle_retire(struct kgem *kgem, unsigned flags)
 
 static void *__kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo)
 {
-	struct drm_i915_gem_mmap_gtt mmap_arg;
+	struct drm_i915_gem_mmap_gtt gtt;
 	void *ptr;
 	int err;
 
@@ -419,12 +438,13 @@ static void *__kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo)
 	     bo->handle, bytes(bo)));
 	assert(bo->proxy == NULL);
 	assert(!bo->snoop);
-	assert(num_pages(bo) <= kgem->aperture_mappable / 4);
+	assert(num_pages(bo) <= kgem->aperture_mappable / 2);
+	assert(kgem->gen != 021 || bo->tiling != I915_TILING_Y);
 
+	VG_CLEAR(gtt);
 retry_gtt:
-	VG_CLEAR(mmap_arg);
-	mmap_arg.handle = bo->handle;
-	if ((err = do_ioctl(kgem->fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))) {
+	gtt.handle = bo->handle;
+	if ((err = do_ioctl(kgem->fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &gtt))) {
 		assert(err != EINVAL);
 
 		(void)__kgem_throttle_retire(kgem, 0);
@@ -441,7 +461,7 @@ retry_gtt:
 
 retry_mmap:
 	ptr = mmap(0, bytes(bo), PROT_READ | PROT_WRITE, MAP_SHARED,
-		   kgem->fd, mmap_arg.offset);
+		   kgem->fd, gtt.offset);
 	if (ptr == MAP_FAILED) {
 		err = errno;
 		assert(err != EINVAL);
@@ -457,7 +477,50 @@ retry_mmap:
 		ptr = NULL;
 	}
 
-	return ptr;
+	/* Cache this mapping to avoid the overhead of an
+	 * excruciatingly slow GTT pagefault. This is more an
+	 * issue with compositing managers which need to
+	 * frequently flush CPU damage to their GPU bo.
+	 */
+	return bo->map__gtt = ptr;
+}
+
+static void *__kgem_bo_map__wc(struct kgem *kgem, struct kgem_bo *bo)
+{
+	struct local_i915_gem_mmap2 wc;
+	int err;
+
+	DBG(("%s(handle=%d, size=%d)\n", __FUNCTION__,
+	     bo->handle, bytes(bo)));
+	assert(bo->proxy == NULL);
+	assert(!bo->snoop);
+	assert(kgem->has_wc_mmap);
+
+	VG_CLEAR(wc);
+
+retry_wc:
+	wc.handle = bo->handle;
+	wc.offset = 0;
+	wc.size = bytes(bo);
+	wc.flags = I915_MMAP_WC;
+	if ((err = do_ioctl(kgem->fd, LOCAL_IOCTL_I915_GEM_MMAP_v2, &wc))) {
+		assert(err != EINVAL);
+
+		if (__kgem_throttle_retire(kgem, 0))
+			goto retry_wc;
+
+		if (kgem_cleanup_cache(kgem))
+			goto retry_wc;
+
+		ERR(("%s: failed to mmap handle=%d, %d bytes, into CPU(wc) domain: %d\n",
+		     __FUNCTION__, bo->handle, bytes(bo), -err));
+		return NULL;
+	}
+
+	VG(VALGRIND_MAKE_MEM_DEFINED(wc.addr_ptr, bytes(bo)));
+
+	DBG(("%s: caching CPU(wc) vma for %d\n", __FUNCTION__, bo->handle));
+	return bo->map__wc = (void *)(uintptr_t)wc.addr_ptr;
 }
 
 static int gem_write(int fd, uint32_t handle,
@@ -1029,9 +1092,7 @@ static bool test_has_llc(struct kgem *kgem)
 	if (DBG_NO_LLC)
 		return false;
 
-#if defined(I915_PARAM_HAS_LLC) /* Expected in libdrm-2.4.31 */
-	has_llc = gem_param(kgem, I915_PARAM_HAS_LLC);
-#endif
+	has_llc = gem_param(kgem, LOCAL_I915_PARAM_HAS_LLC);
 	if (has_llc == -1) {
 		DBG(("%s: no kernel/drm support for HAS_LLC, assuming support for LLC based on GPU generation\n", __FUNCTION__));
 		has_llc = kgem->gen >= 060;
@@ -1040,6 +1101,28 @@ static bool test_has_llc(struct kgem *kgem)
 	return has_llc;
 }
 
+static bool test_has_wc_mmap(struct kgem *kgem)
+{
+	struct local_i915_gem_mmap2 wc;
+	bool ret;
+
+	if (DBG_NO_WC_MMAP)
+		return false;
+
+	if (gem_param(kgem, LOCAL_I915_PARAM_MMAP_VERSION) < 1)
+		return false;
+
+	VG_CLEAR(wc);
+	wc.handle = gem_create(kgem->fd, 1);
+	wc.offset = 0;
+	wc.size = 4096;
+	wc.flags = I915_MMAP_WC;
+	ret = do_ioctl(kgem->fd, LOCAL_IOCTL_I915_GEM_MMAP_v2, &wc) == 0;
+	gem_close(kgem->fd, wc.handle);
+
+	return ret;
+}
+
 static bool test_has_caching(struct kgem *kgem)
 {
 	uint32_t handle;
@@ -1428,6 +1511,10 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, unsigned gen)
 	DBG(("%s: has write-through caching for scanouts? %d\n", __FUNCTION__,
 	     kgem->has_wt));
 
+	kgem->has_wc_mmap = test_has_wc_mmap(kgem);
+	DBG(("%s: has wc-mmapping? %d\n", __FUNCTION__,
+	     kgem->has_wc_mmap));
+
 	kgem->has_caching = test_has_caching(kgem);
 	DBG(("%s: has set-cache-level? %d\n", __FUNCTION__,
 	     kgem->has_caching));
@@ -1975,17 +2062,23 @@ static void kgem_bo_free(struct kgem *kgem, struct kgem_bo *bo)
 
 	DBG(("%s: releasing %p:%p vma for handle=%d, count=%d\n",
 	     __FUNCTION__, bo->map__gtt, bo->map__cpu,
-	     bo->handle, list_is_empty(&bo->vma) ? 0 : kgem->vma[bo->map__gtt == NULL].count));
+	     bo->handle, list_is_empty(&bo->vma) ? 0 : kgem->vma[bo->map__gtt == NULL && bo->map__wc == NULL].count));
 
 	if (!list_is_empty(&bo->vma)) {
 		_list_del(&bo->vma);
-		kgem->vma[bo->map__gtt == NULL].count--;
+		kgem->vma[bo->map__gtt == NULL && bo->map__wc == NULL].count--;
 	}
 
 	if (bo->map__gtt)
-		munmap(MAP(bo->map__gtt), bytes(bo));
-	if (bo->map__cpu)
+		munmap(bo->map__gtt, bytes(bo));
+	if (bo->map__wc) {
+		VG(VALGRIND_MAKE_MEM_NOACCESS(bo->map__wc, bytes(bo)));
+		munmap(bo->map__wc, bytes(bo));
+	}
+	if (bo->map__cpu) {
+		VG(VALGRIND_MAKE_MEM_NOACCESS(MAP(bo->map__cpu), bytes(bo)));
 		munmap(MAP(bo->map__cpu), bytes(bo));
+	}
 
 	_list_del(&bo->list);
 	_list_del(&bo->request);
@@ -2021,25 +2114,24 @@ inline static void kgem_bo_move_to_inactive(struct kgem *kgem,
 
 	if (bucket(bo) >= NUM_CACHE_BUCKETS) {
 		if (bo->map__gtt) {
-			munmap(MAP(bo->map__gtt), bytes(bo));
+			munmap(bo->map__gtt, bytes(bo));
 			bo->map__gtt = NULL;
 		}
 
 		list_move(&bo->list, &kgem->large_inactive);
 	} else {
 		assert(bo->flush == false);
+		assert(list_is_empty(&bo->vma));
 		list_move(&bo->list, &kgem->inactive[bucket(bo)]);
-		if (bo->map__gtt) {
-			if (!kgem_bo_can_map(kgem, bo)) {
-				munmap(MAP(bo->map__gtt), bytes(bo));
-				bo->map__gtt = NULL;
-			}
-			if (bo->map__gtt) {
-				list_add(&bo->vma, &kgem->vma[0].inactive[bucket(bo)]);
-				kgem->vma[0].count++;
-			}
+		if (bo->map__gtt && !kgem_bo_can_map(kgem, bo)) {
+			munmap(bo->map__gtt, bytes(bo));
+			bo->map__gtt = NULL;
 		}
-		if (bo->map__cpu && !bo->map__gtt) {
+		if (bo->map__gtt || (bo->map__wc && !bo->tiling)) {
+			list_add(&bo->vma, &kgem->vma[0].inactive[bucket(bo)]);
+			kgem->vma[0].count++;
+		}
+		if (bo->map__cpu && list_is_empty(&bo->vma)) {
 			list_add(&bo->vma, &kgem->vma[1].inactive[bucket(bo)]);
 			kgem->vma[1].count++;
 		}
@@ -2087,9 +2179,9 @@ inline static void kgem_bo_remove_from_inactive(struct kgem *kgem,
 	assert(bo->rq == NULL);
 	assert(bo->exec == NULL);
 	if (!list_is_empty(&bo->vma)) {
-		assert(bo->map__gtt || bo->map__cpu);
+		assert(bo->map__gtt || bo->map__wc || bo->map__cpu);
 		list_del(&bo->vma);
-		kgem->vma[bo->map__gtt == NULL].count--;
+		kgem->vma[bo->map__gtt == NULL && bo->map__wc == NULL].count--;
 	}
 }
 
@@ -2824,6 +2916,7 @@ static void kgem_commit(struct kgem *kgem)
 		assert(list_is_empty(&rq->buffers));
 
 		assert(rq->bo->map__gtt == NULL);
+		assert(rq->bo->map__wc == NULL);
 		assert(rq->bo->map__cpu == NULL);
 		gem_close(kgem->fd, rq->bo->handle);
 		kgem_cleanup_cache(kgem);
@@ -3985,7 +4078,7 @@ discard:
 		     __FUNCTION__, for_cpu ? "cpu" : "gtt"));
 		cache = &kgem->vma[for_cpu].inactive[cache_bucket(num_pages)];
 		list_for_each_entry(bo, cache, vma) {
-			assert(for_cpu ? bo->map__cpu : bo->map__gtt);
+			assert(for_cpu ? !!bo->map__cpu : (bo->map__gtt || bo->map__wc));
 			assert(bucket(bo) == cache_bucket(num_pages));
 			assert(bo->proxy == NULL);
 			assert(bo->rq == NULL);
@@ -4067,10 +4160,10 @@ discard:
 			bo->pitch = 0;
 		}
 
-		if (bo->map__gtt || bo->map__cpu) {
+		if (bo->map__gtt || bo->map__wc || bo->map__cpu) {
 			if (flags & (CREATE_CPU_MAP | CREATE_GTT_MAP)) {
 				int for_cpu = !!(flags & CREATE_CPU_MAP);
-				if (for_cpu ? bo->map__cpu : bo->map__gtt){
+				if (for_cpu ? !!bo->map__cpu : (bo->map__gtt || bo->map__wc)){
 					if (first != NULL)
 						break;
 
@@ -4477,7 +4570,7 @@ unsigned kgem_can_create_2d(struct kgem *kgem,
 			flags |= KGEM_CAN_CREATE_CPU;
 		if (size > 4096 && size <= kgem->max_gpu_size)
 			flags |= KGEM_CAN_CREATE_GPU;
-		if (size <= PAGE_SIZE*kgem->aperture_mappable/4)
+		if (size <= PAGE_SIZE*kgem->aperture_mappable/4 || kgem->has_wc_mmap)
 			flags |= KGEM_CAN_CREATE_GTT;
 		if (size > kgem->large_object_size)
 			flags |= KGEM_CAN_CREATE_LARGE;
@@ -4903,7 +4996,7 @@ large_inactive:
 				assert(bucket(bo) == bucket);
 				assert(bo->refcnt == 0);
 				assert(!bo->scanout);
-				assert(for_cpu ? bo->map__cpu : bo->map__gtt);
+				assert(for_cpu ? !!bo->map__cpu : (bo->map__gtt || bo->map__wc));
 				assert(bo->rq == NULL);
 				assert(bo->exec == NULL);
 				assert(list_is_empty(&bo->request));
@@ -5996,7 +6089,6 @@ static void kgem_trim_vma_cache(struct kgem *kgem, int type, int bucket)
 	i = 0;
 	while (kgem->vma[type].count > 0) {
 		struct kgem_bo *bo = NULL;
-		void **ptr;
 
 		for (j = 0;
 		     bo == NULL && j < ARRAY_SIZE(kgem->vma[type].inactive);
@@ -6011,12 +6103,23 @@ static void kgem_trim_vma_cache(struct kgem *kgem, int type, int bucket)
 		DBG(("%s: discarding inactive %s vma cache for %d\n",
 		     __FUNCTION__, type ? "CPU" : "GTT", bo->handle));
 
-		ptr = type ? &bo->map__cpu : &bo->map__gtt;
 		assert(bo->rq == NULL);
+		if (type) {
+			VG(VALGRIND_MAKE_MEM_NOACCESS(MAP(bo->map__cpu), bytes(bo)));
+			munmap(MAP(bo->map__cpu), bytes(bo));
+			bo->map__cpu = NULL;
+		} else {
+			if (bo->map__wc) {
+				VG(VALGRIND_MAKE_MEM_NOACCESS(bo->map__wc, bytes(bo)));
+				munmap(bo->map__wc, bytes(bo));
+				bo->map__wc = NULL;
+			}
+			if (bo->map__gtt) {
+				munmap(bo->map__gtt, bytes(bo));
+				bo->map__gtt = NULL;
+			}
+		}
 
-		VG(if (type) VALGRIND_MAKE_MEM_NOACCESS(MAP(*ptr), bytes(bo)));
-		munmap(MAP(*ptr), bytes(bo));
-		*ptr = NULL;
 		list_del(&bo->vma);
 		kgem->vma[type].count--;
 
@@ -6028,10 +6131,28 @@ static void kgem_trim_vma_cache(struct kgem *kgem, int type, int bucket)
 	}
 }
 
-void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo)
+static void *__kgem_bo_map__gtt_or_wc(struct kgem *kgem, struct kgem_bo *bo)
 {
 	void *ptr;
 
+	DBG(("%s: handle=%d\n", __FUNCTION__, bo->handle));
+	kgem_trim_vma_cache(kgem, MAP_GTT, bucket(bo));
+
+	if (bo->tiling || !kgem->has_wc_mmap) {
+		ptr = bo->map__gtt;
+		if (ptr == NULL)
+			ptr = __kgem_bo_map__gtt(kgem, bo);
+	} else {
+		ptr = bo->map__wc;
+		if (ptr == NULL)
+			ptr = __kgem_bo_map__wc(kgem, bo);
+	}
+
+	return ptr;
+}
+
+void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo)
+{
 	DBG(("%s: handle=%d, offset=%ld, tiling=%d, map=%p:%p, domain=%d\n", __FUNCTION__,
 	     bo->handle, (long)bo->presumed_offset, bo->tiling, bo->map__gtt, bo->map__cpu, bo->domain));
 
@@ -6046,26 +6167,7 @@ void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo)
 		return kgem_bo_map__cpu(kgem, bo);
 	}
 
-	ptr = MAP(bo->map__gtt);
-	if (ptr == NULL) {
-		assert(num_pages(bo) <= kgem->aperture_mappable / 2);
-
-		kgem_trim_vma_cache(kgem, MAP_GTT, bucket(bo));
-
-		ptr = __kgem_bo_map__gtt(kgem, bo);
-		if (ptr == NULL)
-			return NULL;
-
-		/* Cache this mapping to avoid the overhead of an
-		 * excruciatingly slow GTT pagefault. This is more an
-		 * issue with compositing managers which need to frequently
-		 * flush CPU damage to their GPU bo.
-		 */
-		bo->map__gtt = ptr;
-		DBG(("%s: caching GTT vma for %d\n", __FUNCTION__, bo->handle));
-	}
-
-	return ptr;
+	return __kgem_bo_map__gtt_or_wc(kgem, bo);
 }
 
 void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
@@ -6091,25 +6193,7 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
 		return ptr;
 	}
 
-	ptr = MAP(bo->map__gtt);
-	if (ptr == NULL) {
-		assert(num_pages(bo) <= kgem->aperture_mappable / 2);
-		assert(kgem->gen != 021 || bo->tiling != I915_TILING_Y);
-
-		kgem_trim_vma_cache(kgem, MAP_GTT, bucket(bo));
-
-		ptr = __kgem_bo_map__gtt(kgem, bo);
-		if (ptr == NULL)
-			return NULL;
-
-		/* Cache this mapping to avoid the overhead of an
-		 * excruciatingly slow GTT pagefault. This is more an
-		 * issue with compositing managers which need to frequently
-		 * flush CPU damage to their GPU bo.
-		 */
-		bo->map__gtt = ptr;
-		DBG(("%s: caching GTT vma for %d\n", __FUNCTION__, bo->handle));
-	}
+	ptr = __kgem_bo_map__gtt_or_wc(kgem, bo);
 
 	if (bo->domain != DOMAIN_GTT || FORCE_MMAP_SYNC & (1 << DOMAIN_GTT)) {
 		struct drm_i915_gem_set_domain set_domain;
@@ -6137,8 +6221,6 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
 
 void *kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo)
 {
-	void *ptr;
-
 	DBG(("%s: handle=%d, offset=%ld, tiling=%d, map=%p:%p, domain=%d\n", __FUNCTION__,
 	     bo->handle, (long)bo->presumed_offset, bo->tiling, bo->map__gtt, bo->map__cpu, bo->domain));
 
@@ -6148,26 +6230,24 @@ void *kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo)
 	assert_tiling(kgem, bo);
 	assert(!bo->purged || bo->reusable);
 
-	ptr = MAP(bo->map__gtt);
-	if (ptr == NULL) {
-		assert(num_pages(bo) <= kgem->aperture_mappable / 4);
+	return __kgem_bo_map__gtt_or_wc(kgem, bo);
+}
 
-		kgem_trim_vma_cache(kgem, MAP_GTT, bucket(bo));
+void *kgem_bo_map__wc(struct kgem *kgem, struct kgem_bo *bo)
+{
+	DBG(("%s: handle=%d, offset=%ld, tiling=%d, map=%p:%p, domain=%d\n", __FUNCTION__,
+	     bo->handle, (long)bo->presumed_offset, bo->tiling, bo->map__gtt, bo->map__cpu, bo->domain));
 
-		ptr = __kgem_bo_map__gtt(kgem, bo);
-		if (ptr == NULL)
-			return NULL;
+	assert(bo->proxy == NULL);
+	assert(bo->exec == NULL);
+	assert(list_is_empty(&bo->list));
+	assert_tiling(kgem, bo);
+	assert(!bo->purged || bo->reusable);
 
-		/* Cache this mapping to avoid the overhead of an
-		 * excruciatingly slow GTT pagefault. This is more an
-		 * issue with compositing managers which need to frequently
-		 * flush CPU damage to their GPU bo.
-		 */
-		bo->map__gtt = ptr;
-		DBG(("%s: caching GTT vma for %d\n", __FUNCTION__, bo->handle));
-	}
+	if (bo->map__wc)
+		return bo->map__wc;
 
-	return ptr;
+	return __kgem_bo_map__wc(kgem, bo);
 }
 
 void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo)
@@ -6512,6 +6592,7 @@ init_buffer_from_bo(struct kgem_buffer *bo, struct kgem_bo *old)
 	     __FUNCTION__, old->handle));
 
 	assert(old->proxy == NULL);
+	assert(list_is_empty(&old->list));
 
 	memcpy(&bo->base, old, sizeof(*old));
 	if (old->rq)
@@ -6817,7 +6898,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
 	assert(alloc);
 
 	alloc /= PAGE_SIZE;
-	if (alloc > kgem->aperture_mappable / 4)
+	if (alloc > kgem->aperture_mappable / 4 && !kgem->has_wc_mmap)
 		flags &= ~KGEM_BUFFER_INPLACE;
 
 	if (kgem->has_llc &&
@@ -7049,7 +7130,7 @@ init:
 	assert(!bo->need_io || !bo->base.needs_flush);
 	assert(!bo->need_io || bo->base.domain != DOMAIN_GPU);
 	assert(bo->mem);
-	assert(bo->mmapped != MMAPPED_GTT || MAP(bo->base.map__gtt) == bo->mem);
+	assert(bo->mmapped != MMAPPED_GTT || bo->base.map__gtt == bo->mem || bo->base.map__wc == bo->mem);
 	assert(bo->mmapped != MMAPPED_CPU || MAP(bo->base.map__cpu) == bo->mem);
 
 	bo->used = size;
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 7ac81cb..6adae3b 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -62,6 +62,7 @@ struct kgem_bo {
 
 	void *map__cpu;
 	void *map__gtt;
+	void *map__wc;
 #define MAP(ptr) ((void*)((uintptr_t)(ptr) & ~3))
 
 	struct kgem_bo_binding {
@@ -192,6 +193,7 @@ struct kgem {
 	uint32_t has_wt :1;
 	uint32_t has_no_reloc :1;
 	uint32_t has_handle_lut :1;
+	uint32_t has_wc_mmap :1;
 
 	uint32_t can_blt_cpu :1;
 	uint32_t can_render_y :1;
@@ -504,6 +506,7 @@ uint64_t kgem_add_reloc64(struct kgem *kgem,
 void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo);
 void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo);
 void *kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo);
+void *kgem_bo_map__wc(struct kgem *kgem, struct kgem_bo *bo);
 void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo);
 void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo);
 void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo);
@@ -715,13 +718,16 @@ static inline bool kgem_bo_mapped(struct kgem *kgem, struct kgem_bo *bo)
 	if (bo->tiling == I915_TILING_NONE && (bo->domain == DOMAIN_CPU || kgem->has_llc))
 		return bo->map__cpu != NULL;
 
+	if (bo->tiling == I915_TILING_NONE && bo->map__wc)
+		return true;
+
 	return bo->map__gtt != NULL;
 }
 
 static inline bool kgem_bo_can_map(struct kgem *kgem, struct kgem_bo *bo)
 {
-	DBG(("%s: handle=%d, map=%p:%p, tiling=%d, domain=%d, offset=%ld\n",
-	     __FUNCTION__, bo->handle, bo->map__gtt, bo->map__cpu, bo->tiling, bo->domain, (long)bo->presumed_offset));
+	DBG(("%s: handle=%d, map=%p:%p:%p, tiling=%d, domain=%d, offset=%ld\n",
+	     __FUNCTION__, bo->handle, bo->map__gtt, bo->map__wc, bo->map__cpu, bo->tiling, bo->domain, (long)bo->presumed_offset));
 
 	if (!bo->tiling && (kgem->has_llc || bo->domain == DOMAIN_CPU))
 		return true;
@@ -734,6 +740,9 @@ static inline bool kgem_bo_can_map(struct kgem *kgem, struct kgem_bo *bo)
 	if (kgem->gen == 021 && bo->tiling == I915_TILING_Y)
 		return false;
 
+	if (!bo->tiling && kgem->has_wc_mmap)
+		return true;
+
 	return __kgem_bo_num_pages(bo) <= kgem->aperture_mappable / 4;
 }
 
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 30b0292..9d139ed 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -675,7 +675,8 @@ void sna_pixmap_destroy(PixmapPtr pixmap);
 
 #define assert_pixmap_map(pixmap, priv)  do { \
 	assert(priv->mapped != MAPPED_NONE || pixmap->devPrivate.ptr == PTR(priv->ptr)); \
-	assert(priv->mapped == MAPPED_NONE || pixmap->devPrivate.ptr == (priv->mapped == MAPPED_CPU ? MAP(priv->gpu_bo->map__cpu) : MAP(priv->gpu_bo->map__gtt))); \
+	assert(priv->mapped != MAPPED_CPU || pixmap->devPrivate.ptr == MAP(priv->gpu_bo->map__cpu)); \
+	assert(priv->mapped != MAPPED_GTT || pixmap->devPrivate.ptr == priv->gpu_bo->map__gtt || pixmap->devPrivate.ptr == priv->gpu_bo->map__wc); \
 } while (0)
 
 static inline void sna_pixmap_unmap(PixmapPtr pixmap, struct sna_pixmap *priv)
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index cd0b907..0ef56fb 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -4588,7 +4588,7 @@ can_create_upload_tiled_x(struct sna *sna,
 	if (sna->kgem.has_llc)
 		return true;
 
-	if (sna_pixmap_default_tiling(sna, pixmap))
+	if (!sna->kgem.has_wc_mmap && sna_pixmap_default_tiling(sna, pixmap))
 		return false;
 
 	return true;
@@ -4608,13 +4608,21 @@ create_upload_tiled_x(struct sna *sna,
 	assert(priv->gpu_bo == NULL);
 	assert(priv->gpu_damage == NULL);
 
-	create = CREATE_CPU_MAP | CREATE_INACTIVE;
-	if (!sna->kgem.has_llc)
-		create |= CREATE_CACHED;
+	if (sna->kgem.has_llc)
+		create = CREATE_CPU_MAP | CREATE_INACTIVE;
+	else if (sna->kgem.has_wc_mmap)
+		create = CREATE_GTT_MAP | CREATE_INACTIVE;
+	else
+		create = CREATE_CPU_MAP | CREATE_INACTIVE | CREATE_CACHED;
 
 	return sna_pixmap_alloc_gpu(sna, pixmap, priv, create);
 }
 
+static bool can_upload__tiled_x(struct kgem *kgem, struct kgem_bo *bo)
+{
+	return kgem_bo_can_map__cpu(kgem, bo, true) || kgem->has_wc_mmap;
+}
+
 static bool
 try_upload__tiled_x(PixmapPtr pixmap, RegionRec *region,
 		    int x, int y, int w, int  h, char *bits, int stride)
@@ -4625,7 +4633,7 @@ try_upload__tiled_x(PixmapPtr pixmap, RegionRec *region,
 	uint8_t *dst;
 	int n;
 
-	if (!kgem_bo_can_map__cpu(&sna->kgem, priv->gpu_bo, true)) {
+	if (!can_upload__tiled_x(&sna->kgem, priv->gpu_bo)) {
 		DBG(("%s: no, cannot map through the CPU\n", __FUNCTION__));
 		return false;
 	}
@@ -4638,11 +4646,19 @@ try_upload__tiled_x(PixmapPtr pixmap, RegionRec *region,
 	    __kgem_bo_is_busy(&sna->kgem, priv->gpu_bo))
 		return false;
 
-	dst = kgem_bo_map__cpu(&sna->kgem, priv->gpu_bo);
-	if (dst == NULL)
-		return false;
+	if (kgem_bo_can_map__cpu(&sna->kgem, priv->gpu_bo, true)) {
+		dst = kgem_bo_map__cpu(&sna->kgem, priv->gpu_bo);
+		if (dst == NULL)
+			return false;
 
-	kgem_bo_sync__cpu(&sna->kgem, priv->gpu_bo);
+		kgem_bo_sync__cpu(&sna->kgem, priv->gpu_bo);
+	} else {
+		dst = kgem_bo_map__wc(&sna->kgem, priv->gpu_bo);
+		if (dst == NULL)
+			return false;
+
+		kgem_bo_sync__gtt(&sna->kgem, priv->gpu_bo);
+	}
 
 	box = region_rects(region);
 	n = region_num_rects(region);
@@ -4712,12 +4728,14 @@ try_upload__tiled_x(PixmapPtr pixmap, RegionRec *region,
 		} while (--n);
 
 		if (!priv->shm) {
-			assert(dst == MAP(priv->gpu_bo->map__cpu));
 			pixmap->devPrivate.ptr = dst;
 			pixmap->devKind = priv->gpu_bo->pitch;
-			priv->mapped = MAPPED_CPU;
+			if (dst == MAP(priv->gpu_bo->map__cpu)) {
+				priv->mapped = MAPPED_CPU;
+				priv->cpu = true;
+			} else
+				priv->mapped = MAPPED_GTT;
 			assert_pixmap_map(pixmap, priv);
-			priv->cpu = true;
 		}
 	}
 
@@ -6129,7 +6147,7 @@ upload_inplace:
 		return false;
 	}
 
-	if (!kgem_bo_can_map__cpu(&sna->kgem, dst_priv->gpu_bo, true) ||
+	if (!can_upload__tiled_x(&sna->kgem, dst_priv->gpu_bo) ||
 	    __kgem_bo_is_busy(&sna->kgem, dst_priv->gpu_bo)) {
 		if (replaces && !dst_priv->pinned) {
 			unsigned create;
@@ -6156,7 +6174,7 @@ upload_inplace:
 			return false;
 		}
 
-		if (!kgem_bo_can_map__cpu(&sna->kgem, dst_priv->gpu_bo, true)) {
+		if (!can_upload__tiled_x(&sna->kgem, dst_priv->gpu_bo)) {
 			DBG(("%s - no, cannot map dst for reads into the CPU\n", __FUNCTION__));
 			return false;
 		}
@@ -6169,13 +6187,23 @@ upload_inplace:
 		return false;
 	}
 
-	ptr = kgem_bo_map__cpu(&sna->kgem, dst_priv->gpu_bo);
-	if (ptr == NULL) {
-		DBG(("%s - no, map failed\n", __FUNCTION__));
-		return false;
-	}
+	if (kgem_bo_can_map__cpu(&sna->kgem, dst_priv->gpu_bo, true)) {
+		ptr = kgem_bo_map__cpu(&sna->kgem, dst_priv->gpu_bo);
+		if (ptr == NULL) {
+			DBG(("%s - no, map failed\n", __FUNCTION__));
+			return false;
+		}
+
+		kgem_bo_sync__cpu(&sna->kgem, dst_priv->gpu_bo);
+	} else {
+		ptr = kgem_bo_map__wc(&sna->kgem, dst_priv->gpu_bo);
+		if (ptr == NULL) {
+			DBG(("%s - no, map failed\n", __FUNCTION__));
+			return false;
+		}
 
-	kgem_bo_sync__cpu(&sna->kgem, dst_priv->gpu_bo);
+		kgem_bo_sync__gtt(&sna->kgem, dst_priv->gpu_bo);
+	}
 
 	if (!DAMAGE_IS_ALL(dst_priv->gpu_damage)) {
 		assert(!dst_priv->clear);
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 0889f9d..f16a46c 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -5032,7 +5032,7 @@ sna_cursor_pre_init(struct sna *sna)
 #define DRM_CAP_CURSOR_WIDTH	8
 #define DRM_CAP_CURSOR_HEIGHT	9
 
-#define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
+#define I915_PARAM_HAS_COHERENT_PHYS_GTT 30
 
 	sna->cursor.max_size = 64;
 
diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c
index 0181838..d6aa129 100644
--- a/src/sna/sna_io.c
+++ b/src/sna/sna_io.c
@@ -652,6 +652,9 @@ static bool upload_inplace__tiled(struct kgem *kgem, struct kgem_bo *bo)
 		break;
 	}
 
+	if (kgem->has_wc_mmap)
+		return true;
+
 	return kgem_bo_can_map__cpu(kgem, bo, true);
 }
 
@@ -663,14 +666,22 @@ write_boxes_inplace__tiled(struct kgem *kgem,
 {
 	uint8_t *dst;
 
-	assert(kgem_bo_can_map__cpu(kgem, bo, true));
+	assert(kgem->has_wc_mmap || kgem_bo_can_map__cpu(kgem, bo, true));
 	assert(bo->tiling != I915_TILING_Y);
 
-	dst = kgem_bo_map__cpu(kgem, bo);
-	if (dst == NULL)
-		return false;
+	if (kgem_bo_can_map__cpu(kgem, bo, true)) {
+		dst = kgem_bo_map__cpu(kgem, bo);
+		if (dst == NULL)
+			return false;
 
-	kgem_bo_sync__cpu(kgem, bo);
+		kgem_bo_sync__cpu(kgem, bo);
+	} else {
+		dst = kgem_bo_map__wc(kgem, bo);
+		if (dst == NULL)
+			return false;
+
+		kgem_bo_sync__gtt(kgem, bo);
+	}
 
 	if (sigtrap_get())
 		return false;


More information about the xorg-commit mailing list