xf86-video-intel: src/sna/kgem.c src/sna/kgem.h src/sna/sna_driver.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 15 17:03:55 UTC 2020


 src/sna/kgem.c       |   15 +++++++++++++++
 src/sna/kgem.h       |    1 +
 src/sna/sna_driver.c |   13 ++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit a511f22cdec56504913b457a2e60dafee8e2b570
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 15 17:00:20 2020 +0000

    sna: Enable TearFree by default on recent HW
    
    When there is ample memory bandwidth and we are not fighting for global
    resources, enable TearFree by default. Avoiding tearing is much more
    pleasant (for direct rendering where the source itself is not being
    synchronized to vblank) at negligible power cost; just doubles the
    memory footprint of scanout.
    
    References: https://gitlab.freedesktop.org/drm/intel/-/issues/2799
    References: https://gitlab.freedesktop.org/drm/intel/-/issues/2763
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 6a35067c..2e21bc11 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1944,6 +1944,19 @@ static uint64_t get_gtt_size(int fd)
 	return aperture.aper_size;
 }
 
+static int get_gtt_type(int fd)
+{
+        struct drm_i915_getparam p;
+        int val = 0;
+
+        memset(&p, 0, sizeof(p));
+        p.param = I915_PARAM_HAS_ALIASING_PPGTT;
+        p.value = &val;
+
+	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &p);
+	return val;
+}
+
 void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, unsigned gen)
 {
 	size_t totalram;
@@ -2108,6 +2121,8 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, unsigned gen)
 	     !DBG_NO_CPU && (kgem->has_llc | kgem->has_userptr | kgem->has_caching),
 	     kgem->has_llc, kgem->has_caching, kgem->has_userptr));
 
+	kgem->has_full_ppgtt = get_gtt_type(fd) > 1;
+
 	gtt_size = get_gtt_size(fd);
 	kgem->aperture_total = gtt_size;
 	kgem->aperture_high = gtt_size * 3/4;
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index b7871590..6a087a57 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -191,6 +191,7 @@ struct kgem {
 	uint32_t has_pinned_batches :1;
 	uint32_t has_caching :1;
 	uint32_t has_coherent_mmap_gtt :1;
+	uint32_t has_full_ppgtt :1;
 	uint32_t has_llc :1;
 	uint32_t has_wt :1;
 	uint32_t has_no_reloc :1;
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 4f8895f1..d810b262 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -459,7 +459,18 @@ static bool enable_tear_free(struct sna *sna)
 	if (sna->flags & SNA_LINEAR_FB)
 		return false;
 
-	/* Under certain conditions, we should enable TearFree by default,
+	/*
+	 * On recent HW, where the display surfaces are in a seperate GTT
+	 * to userspace, there is much less contention on global resources
+	 * and also we can assume there is much more memory bandwidth
+	 * available (i.e. gen8+). This HW should rarely be under such
+	 * constaints as to need to disable TearFree, so enable by default.
+	 */
+	if (sna->kgem.has_full_ppgtt)
+		return true;
+
+	/*
+	 * Under certain conditions, we should enable TearFree by default,
 	 * for example when the hardware requires pageflipping to run within
 	 * its power/performance budget.
 	 */


More information about the xorg-commit mailing list