Thomas Zimmermann 384753
From b925708f28c2b7a3a362d709bd7f77bc75c1daac Mon Sep 17 00:00:00 2001
Thomas Zimmermann 384753
From: Chris Wilson <chris@chris-wilson.co.uk>
Thomas Zimmermann 384753
Date: Fri, 20 Sep 2019 13:18:21 +0100
Thomas Zimmermann 384753
Subject: drm/i915: Mark contents as dirty on a write fault
Thomas Zimmermann 384753
MIME-Version: 1.0
Thomas Zimmermann 384753
Content-Type: text/plain; charset=UTF-8
Thomas Zimmermann 384753
Content-Transfer-Encoding: 8bit
Thomas Zimmermann 384753
Git-commit: b925708f28c2b7a3a362d709bd7f77bc75c1daac
Thomas Zimmermann 384753
Patch-mainline: v5.4-rc3
Thomas Zimmermann 384753
References: bsc#1152489
Thomas Zimmermann 384753
Thomas Zimmermann 384753
Since dropping the set-to-gtt-domain in commit a679f58d0510 ("drm/i915:
Thomas Zimmermann 384753
Flush pages on acquisition"), we no longer mark the contents as dirty on
Thomas Zimmermann 384753
a write fault. This has the issue of us then not marking the pages as
Thomas Zimmermann 384753
dirty on releasing the buffer, which means the contents are not written
Thomas Zimmermann 384753
out to the swap device (should we ever pick that buffer as a victim).
Thomas Zimmermann 384753
Notably, this is visible in the dumb buffer interface used for cursors.
Thomas Zimmermann 384753
Having updated the cursor contents via mmap, and swapped away, if the
Thomas Zimmermann 384753
shrinker should evict the old cursor, upon next reuse, the cursor would
Thomas Zimmermann 384753
be invisible.
Thomas Zimmermann 384753
Thomas Zimmermann 384753
E.g. echo 80 > /proc/sys/kernel/sysrq ; echo f > /proc/sysrq-trigger
Thomas Zimmermann 384753
Thomas Zimmermann 384753
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111541
Thomas Zimmermann 384753
Fixes: a679f58d0510 ("drm/i915: Flush pages on acquisition")
Thomas Zimmermann 384753
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Thomas Zimmermann 384753
Cc: Matthew Auld <matthew.william.auld@gmail.com>
Thomas Zimmermann 384753
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Thomas Zimmermann 384753
Cc: <stable@vger.kernel.org> # v5.2+
Thomas Zimmermann 384753
Reviewed-by: Matthew Auld <matthew.william.auld@gmail.com>
Thomas Zimmermann 384753
Link: https://patchwork.freedesktop.org/patch/msgid/20190920121821.7223-1-chris@chris-wilson.co.uk
Thomas Zimmermann 384753
(cherry picked from commit 5028851cdfdf78dc22eacbc44a0ab0b3f599ee4a)
Thomas Zimmermann 384753
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Thomas Zimmermann 384753
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Thomas Zimmermann 384753
---
Thomas Zimmermann 384753
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 6 +++++-
Thomas Zimmermann 384753
 1 file changed, 5 insertions(+), 1 deletion(-)
Thomas Zimmermann 384753
Thomas Zimmermann 384753
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
Thomas Zimmermann 384753
index 1fd2081a905e..91051e178021 100644
Thomas Zimmermann 384753
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
Thomas Zimmermann 384753
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
Thomas Zimmermann 384753
@@ -316,7 +316,11 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
Thomas Zimmermann 384753
 		intel_wakeref_auto(&i915->ggtt.userfault_wakeref,
Thomas Zimmermann 384753
 				   msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND));
Thomas Zimmermann 384753
 
Thomas Zimmermann 384753
-	i915_vma_set_ggtt_write(vma);
Thomas Zimmermann 384753
+	if (write) {
Thomas Zimmermann 384753
+		GEM_BUG_ON(!i915_gem_object_has_pinned_pages(obj));
Thomas Zimmermann 384753
+		i915_vma_set_ggtt_write(vma);
Thomas Zimmermann 384753
+		obj->mm.dirty = true;
Thomas Zimmermann 384753
+	}
Thomas Zimmermann 384753
 
Thomas Zimmermann 384753
 err_fence:
Thomas Zimmermann 384753
 	i915_vma_unpin_fence(vma);
Thomas Zimmermann 384753
-- 
Thomas Zimmermann 384753
2.28.0
Thomas Zimmermann 384753