All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915: Pin pages as we flush for CPU access
@ 2016-05-06 14:36 Chris Wilson
  2016-05-06 14:36 ` [PATCH 2/2] drm/i915/dmabuf: " Chris Wilson
  2016-05-09 11:53 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: " Patchwork
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Wilson @ 2016-05-06 14:36 UTC (permalink / raw)
  To: intel-gfx

As a precautionary defensive measure against changes to the core (where
we stop changing domains when unbinding), we want to ensure that the pages
are available when we want to start CPU access, otherwise we will not
perform the requisite clflushes to make the contents coherent for the user.

We already do this for the GTT access path, so lift it from the
set-to-gtt-domain to the set-domain-ioctl caller so we also apply it for
set-to-cpu-domain.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a88e6c9e9516..625fb402b67d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1630,11 +1630,27 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		goto unref;
 
+	/* Flush and acquire obj->pages so that we are coherent through
+	 * direct access in memory with previous cached writes through
+	 * shmemfs and that our cache domain tracking remains valid.
+	 * For example, if the obj->filp was moved to swap without us
+	 * being notified and releasing the pages, we would mistakenly
+	 * continue to assume that the obj remained out of the CPU cached
+	 * domain.
+	 */
+	ret = i915_gem_object_get_pages(obj);
+	if (ret)
+		goto unref;
+
+	i915_gem_object_pin_pages(obj);
+
 	if (read_domains & I915_GEM_DOMAIN_GTT)
 		ret = i915_gem_object_set_to_gtt_domain(obj, write_domain != 0);
 	else
 		ret = i915_gem_object_set_to_cpu_domain(obj, write_domain != 0);
 
+	i915_gem_object_unpin_pages(obj);
+
 	if (write_domain != 0)
 		intel_fb_obj_invalidate(obj,
 					write_domain == I915_GEM_DOMAIN_GTT ?
@@ -3754,18 +3770,6 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
 	if (ret)
 		return ret;
 
-	/* Flush and acquire obj->pages so that we are coherent through
-	 * direct access in memory with previous cached writes through
-	 * shmemfs and that our cache domain tracking remains valid.
-	 * For example, if the obj->filp was moved to swap without us
-	 * being notified and releasing the pages, we would mistakenly
-	 * continue to assume that the obj remained out of the CPU cached
-	 * domain.
-	 */
-	ret = i915_gem_object_get_pages(obj);
-	if (ret)
-		return ret;
-
 	i915_gem_object_flush_cpu_write_domain(obj);
 
 	/* Serialise direct access to this object with the barriers for
-- 
2.8.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-09 11:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-06 14:36 [PATCH 1/2] drm/i915: Pin pages as we flush for CPU access Chris Wilson
2016-05-06 14:36 ` [PATCH 2/2] drm/i915/dmabuf: " Chris Wilson
2016-05-06 19:35   ` Dave Gordon
2016-05-06 19:52     ` Chris Wilson
2016-05-09 11:53 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.