diff mbox

drm/i915: Do an initial lockless wait for render completion before pread/pwrite

Message ID 1355680315-25793-1-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Dec. 16, 2012, 5:51 p.m. UTC
Before performing the domain transition for pread/pwrite, and so a locked
completion if still required, wait for any pending rendering locklessly.
This should reduce contention when reading back results from the GPU, for
example.

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

Comments

Chris Wilson Dec. 16, 2012, 6:29 p.m. UTC | #1
On Sun, 16 Dec 2012 17:51:55 +0000, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Before performing the domain transition for pread/pwrite, and so a locked
> completion if still required, wait for any pending rendering locklessly.
> This should reduce contention when reading back results from the GPU, for
> example.

Meh, the pwrite side messes around with the ret=-EFAULT and so screws up
the shmem_write patch.
-Chris
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a831641..447ad9d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -599,6 +599,10 @@  i915_gem_pread_ioctl(struct drm_device *dev, void *data,
 
 	trace_i915_gem_object_pread(obj, args->offset, args->size);
 
+	ret = i915_gem_object_wait_rendering__nonblocking(obj, true);
+	if (ret)
+		goto out;
+
 	ret = i915_gem_shmem_pread(dev, obj, args, file);
 
 out:
@@ -1001,6 +1005,10 @@  i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
 		goto out;
 	}
 
+	ret = i915_gem_object_wait_rendering__nonblocking(obj, false);
+	if (ret)
+		goto out;
+
 	if (obj->cache_level == I915_CACHE_NONE &&
 	    obj->tiling_mode == I915_TILING_NONE &&
 	    obj->base.write_domain != I915_GEM_DOMAIN_CPU) {