From 4d48b55687a33f946b4938d0897602f7d303c8d4 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 17 Apr 2014 21:04:15 +0100 Subject: [PATCH] sna: Support efficient cursor updates for old machines Given a kernel patch to fix coherency of physical objects, we can use a more efficient method for updating cursors. Signed-off-by: Chris Wilson --- src/sna/sna.h | 1 + src/sna/sna_display.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/sna/sna.h b/src/sna/sna.h index 00b12e9..bd6eb49 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -296,6 +296,7 @@ struct sna { int last_y; unsigned max_size; + bool use_gtt; } cursor; struct sna_dri { diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 90c24fe..0d5bb36 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3119,7 +3119,7 @@ static struct sna_cursor *__sna_create_cursor(struct sna *sna) /* Old hardware uses physical addresses, which the kernel * implements in an incoherent fashion requiring a pwrite. */ - if (sna->kgem.gen >= 033) { + if (sna->cursor.use_gtt) { c->image = gem_mmap(sna->kgem.fd, c->handle, c->alloc); if (c->image == NULL) { gem_close(sna->kgem.fd, c->handle); @@ -3171,7 +3171,7 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc) rotation = crtc->transform_in_use ? crtc->rotation : RR_Rotate_0; for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) { - if (cursor->serial == sna->cursor.serial && cursor->rotation == rotation) { + if (cursor->serial == sna->cursor.serial && cursor->rotation == rotation && cursor->image) { __DBG(("%s: reusing handle=%d, serial=%d, rotation=%d, size=%d\n", __FUNCTION__, cursor->handle, cursor->serial, cursor->rotation, cursor->size)); assert(cursor->size == sna->cursor.size); @@ -3616,11 +3616,14 @@ sna_cursor_pre_init(struct sna *sna) uint64_t name; uint64_t value; } cap; + int v; #define LOCAL_IOCTL_GET_CAP DRM_IOWR(0x0c, struct local_get_cap) #define DRM_CAP_CURSOR_WIDTH 8 #define DRM_CAP_CURSOR_HEIGHT 9 +#define I915_PARAM_HAS_COHERENT_PHYS_GTT 29 + sna->cursor.max_size = 64; cap.name = DRM_CAP_CURSOR_WIDTH; @@ -3636,6 +3639,20 @@ sna_cursor_pre_init(struct sna *sna) xf86DrvMsg(sna->scrn->scrnIndex, X_PROBED, "Using a maximum size of %dx%d for hardware cursors\n", sna->cursor.max_size, sna->cursor.max_size); + + v = -1; /* No param uses the sign bit, reserve it for errors */ + if (sna->kgem.gen >= 033) { + v = 1; + } else { + drm_i915_getparam_t gp = { + I915_PARAM_HAS_COHERENT_PHYS_GTT, + &v, + }; + (void)drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GETPARAM, &gp); + } + sna->cursor.use_gtt = v > 0; + DBG(("%s: cursor updates use_gtt?=%d\n", + __FUNCTION__, sna->cursor.use_gtt)); } bool -- 1.9.2