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@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2020-12-15 17:00:20 +00:00
parent 9236c58252
commit a511f22cde
3 changed files with 28 additions and 1 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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.
*/