[Intel-gfx] [PATCH] drm/i915: Extend wait-ioctl to only wait on writes
Chris Wilson
chris at chris-wilson.co.uk
Wed Mar 29 14:58:26 UTC 2017
Currently, we allow read-read CPU/GPU concurrency via set-domain-ioctl,
but we don't have a similar facility for a plain wait-ioctl. If we add a
new flag that userspace can use to opt-in for only waiting for GPU
writes, userspace can use it to co-ordinate its own read-read
concurrency (without the side-effect of touching cache domains on the
GEM object).
To test whether this flag is available, userspace needs to do a query
operation like:
bool test_wait_has_read_only(int fd)
{
struct drm_i915_gem_wait arg = { .flags = I915_WAIT_READ_ONLY };
int err = 0;
if (ioctl(fd, DRM_IOCTL_I915_GEM_WAIT, &arg))
err = -errno;
return err == -ENOENT;
}
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem.c | 5 +++--
include/uapi/drm/i915_drm.h | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c2a660c7538b..d50710752265 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3006,7 +3006,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
ktime_t start;
long ret;
- if (args->flags != 0)
+ if (args->flags & ~(I915_WAIT_READ_ONLY))
return -EINVAL;
obj = i915_gem_object_lookup(file, args->bo_handle);
@@ -3016,7 +3016,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
start = ktime_get();
ret = i915_gem_object_wait(obj,
- I915_WAIT_INTERRUPTIBLE | I915_WAIT_ALL,
+ I915_WAIT_INTERRUPTIBLE |
+ (args->flags & I915_WAIT_READ_ONLY ? 0 : I915_WAIT_ALL),
to_wait_timeout(args->timeout_ns),
to_rps_client(file));
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 72460826f818..6387a7485702 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1312,6 +1312,7 @@ struct drm_i915_gem_wait {
/** Handle of BO we shall wait on */
__u32 bo_handle;
__u32 flags;
+#define I915_WAIT_READ_ONLY 0x1
/** Number of nanoseconds to wait, Returns time remaining. */
__s64 timeout_ns;
};
--
2.11.0
More information about the Intel-gfx
mailing list