]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/i915: Check domains for userptr on release
authorChris Wilson <chris@chris-wilson.co.uk>
Sun, 31 Mar 2019 09:46:20 +0000 (10:46 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sun, 31 Mar 2019 11:46:52 +0000 (12:46 +0100)
When we return pages to the system, we release control over them and
should defensively return them to the CPU write domain so that we catch
any external writes on reacquiring them (e.g. to transparently
swapout/swapin). While we did this defensive clflushing for ordinary
shmem pages, it was forgotten for userptr. Fortunately, userptr objects
are normally cache coherent and so oblivious to the forgotten domain
tracking.

References: a679f58d0510 ("drm/i915: Flush pages on acquisition")
References: 754a25442705 ("drm/i915: Skip object locking around a no-op set-domain ioctl")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.william.auld@gmail.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.william.auld@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190331094620.15185-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_object.h
drivers/gpu/drm/i915/i915_gem_userptr.c

index e506e43cfade9c47a101eab9c4e28cbe2a1ceff5..c3b4ec52e1b7a0af08deb31f9b9c6385a4e2a609 100644 (file)
@@ -308,7 +308,7 @@ static void __start_cpu_write(struct drm_i915_gem_object *obj)
                obj->cache_dirty = true;
 }
 
-static void
+void
 __i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
                                struct sg_table *pages,
                                bool needs_clflush)
@@ -2202,7 +2202,6 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj,
        struct page *page;
 
        __i915_gem_object_release_shmem(obj, pages, true);
-
        i915_gem_gtt_finish_pages(obj, pages);
 
        if (i915_gem_object_needs_bit17_swizzle(obj))
index 1a24dc97e4fdb0abe820e5fd3ffcb399bfc1ac2d..ca93a40c0c878885110e36f675b0ba79c5050a62 100644 (file)
@@ -502,4 +502,8 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj,
                                         unsigned int cache_level);
 void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj);
 
+void __i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
+                                    struct sg_table *pages,
+                                    bool needs_clflush);
+
 #endif
index ad0087127144e6c334d0f66a4c32ccff9a111a11..215bf3fef10c9a1e3785f73ba55fe10a896d0f70 100644 (file)
@@ -673,9 +673,7 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
        if (!pages)
                return;
 
-       if (obj->mm.madv != I915_MADV_WILLNEED)
-               obj->mm.dirty = false;
-
+       __i915_gem_object_release_shmem(obj, pages, true);
        i915_gem_gtt_finish_pages(obj, pages);
 
        for_each_sgt_page(page, sgt_iter, pages) {