xf86-video-intel: 2 commits - src/sna/gen7_render.c src/sna/kgem.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 15 21:08:05 UTC 2021
src/sna/gen7_render.c | 39 +--------------------------------
src/sna/kgem.c | 58 +++++++++++++++++++++++++++++---------------------
2 files changed, 36 insertions(+), 61 deletions(-)
New commits:
commit 31486f40f8e8f8923ca0799aea84b58799754564
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jan 15 17:03:51 2021 +0000
sna: Always validate userptr upon creation
Since not all memory ranges can be mapped by userptr, in particular those
passed by XShmAttachFD, we need to validate the userptr before use. We
would ideally want to continue to lazily populate the pages as often the
userptr is created but never used, but preventing an EFAULT later is
more important.
In https://patchwork.freedesktop.org/series/33449/ we provided a more
efficient method for probing the userptr on construction while
preserving the lazy population of gup-pages. For now, always follow
userptr with set-domain.
Reported-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 2e21bc11..7b645da8 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -520,7 +520,7 @@ static bool gem_set_caching(int fd, uint32_t handle, int caching)
return do_ioctl(fd, LOCAL_IOCTL_I915_GEM_SET_CACHING, &arg) == 0;
}
-static uint32_t gem_userptr(int fd, void *ptr, int size, int read_only)
+static uint32_t gem_userptr(int fd, void *ptr, size_t size, int read_only)
{
struct local_i915_gem_userptr arg;
@@ -7031,6 +7031,30 @@ uint32_t kgem_bo_flink(struct kgem *kgem, struct kgem_bo *bo)
return flink.name;
}
+static bool probe(struct kgem *kgem, uint32_t handle)
+{
+ struct drm_i915_gem_set_domain arg = {
+ .handle = handle,
+ .read_domains = I915_GEM_DOMAIN_CPU,
+ };
+
+ return do_ioctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &arg) == 0;
+}
+
+static uint32_t probe_userptr(struct kgem *kgem,
+ void *ptr, size_t size, int read_only)
+{
+ uint32_t handle;
+
+ handle = gem_userptr(kgem->fd, ptr, size, read_only);
+ if (handle && !probe(kgem, handle)) {
+ gem_close(kgem->fd, handle);
+ handle = 0;
+ }
+
+ return handle;
+}
+
struct kgem_bo *kgem_create_map(struct kgem *kgem,
void *ptr, uint32_t size,
bool read_only)
@@ -7053,30 +7077,16 @@ struct kgem_bo *kgem_create_map(struct kgem *kgem,
last_page &= ~(uintptr_t)(PAGE_SIZE-1);
assert(last_page > first_page);
- handle = gem_userptr(kgem->fd,
- (void *)first_page, last_page-first_page,
- read_only);
+ handle = probe_userptr(kgem,
+ (void *)first_page, last_page-first_page,
+ read_only);
+ if (handle == 0 && read_only && kgem->has_wc_mmap)
+ handle = probe_userptr(kgem,
+ (void *)first_page, last_page-first_page,
+ false);
if (handle == 0) {
- if (read_only && kgem->has_wc_mmap) {
- struct drm_i915_gem_set_domain set_domain;
-
- handle = gem_userptr(kgem->fd,
- (void *)first_page, last_page-first_page,
- false);
-
- VG_CLEAR(set_domain);
- set_domain.handle = handle;
- set_domain.read_domains = I915_GEM_DOMAIN_GTT;
- set_domain.write_domain = 0;
- if (do_ioctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain)) {
- gem_close(kgem->fd, handle);
- handle = 0;
- }
- }
- if (handle == 0) {
- DBG(("%s: import failed, errno=%d\n", __FUNCTION__, errno));
- return NULL;
- }
+ DBG(("%s: import failed, errno=%d\n", __FUNCTION__, errno));
+ return NULL;
}
bo = __kgem_bo_alloc(handle, (last_page - first_page) / PAGE_SIZE);
commit ab906aa04548092bdb9dd906e1de5dd2be8eabc3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sun Jan 10 00:23:28 2021 +0000
sna/gen7: Avoid clear-residuals overhead on all gen7
Since not just Haswell will enjoy clear-residuals, be very careful
before using a potential context switch from DRI clients.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index e572b785..0c19f489 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -2957,45 +2957,10 @@ prefer_blt_copy(struct sna *sna,
struct kgem_bo *dst_bo,
unsigned flags)
{
- if (sna->kgem.mode == KGEM_BLT)
- return true;
-
- if (sna->info->gen == 075) /* avoid clear-residuals context overhead */
- return true;
-
- assert((flags & COPY_SYNC) == 0);
-
- if (untiled_tlb_miss(src_bo) ||
- untiled_tlb_miss(dst_bo))
- return true;
-
- if (flags & COPY_DRI && !sna->kgem.has_semaphores)
- return false;
-
- if (force_blt_ring(sna, dst_bo, src_bo))
- return true;
-
- if ((flags & COPY_SMALL ||
- (sna->render_state.gt < 3 && src_bo == dst_bo)) &&
- can_switch_to_blt(sna, dst_bo, flags))
- return true;
-
- if (kgem_bo_is_render(dst_bo) ||
- kgem_bo_is_render(src_bo))
- return false;
-
- if (flags & COPY_LAST &&
- sna->render_state.gt < 3 &&
- can_switch_to_blt(sna, dst_bo, flags))
- return true;
-
- if (prefer_render_ring(sna, dst_bo))
- return false;
-
- if (!prefer_blt_ring(sna, dst_bo, flags))
+ if (sna->kgem.ring != KGEM_BLT)
return false;
- return prefer_blt_bo(sna, src_bo, dst_bo);
+ return true; /* avoid clear-residuals context overhead */
}
static bool
More information about the xorg-commit
mailing list