[Intel-gfx] [PATCH 115/190] drm/i915: Remove (struct_mutex) locking for busy-ioctl
Chris Wilson
chris at chris-wilson.co.uk
Mon Jan 11 02:44:59 PST 2016
By applying the same logic as for wait-ioctl, we can query whether a
request has completed without holding struct_mutex. The biggest impact
system-wide is removing the flush_active and the contention that causes.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem.c | 51 ++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f30207596ec6..95d4d2460f6a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3559,34 +3559,39 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
{
struct drm_i915_gem_busy *args = data;
struct drm_i915_gem_object *obj;
- int ret;
-
- ret = i915_mutex_lock_interruptible(dev);
- if (ret)
- return ret;
obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
- ret = -ENOENT;
- goto unlock;
- }
+ if (&obj->base == NULL)
+ return -ENOENT;
- /* Count all active objects as busy, even if they are currently not used
- * by the gpu. Users of this interface expect objects to eventually
- * become non-busy without any further actions, therefore emit any
- * necessary flushes here.
- */
- i915_gem_object_flush_active(obj);
+ args->busy = 0;
+ if (__I915_BO_ACTIVE(obj)) {
+ struct drm_i915_gem_request *req;
+ int i;
- BUILD_BUG_ON(I915_NUM_RINGS > 16);
- args->busy = I915_BO_ACTIVE(obj) << 16;
- if (obj->last_write.request)
- args->busy |= obj->last_write.request->engine->id;
+ BUILD_BUG_ON(I915_NUM_RINGS > 16);
+ rcu_read_lock();
+ for (i = 0; i < I915_NUM_RINGS; i++) {
+ req = i915_gem_active_get_request_rcu(&obj->last_read[i]);
+ if (req == NULL)
+ continue;
- drm_gem_object_unreference(&obj->base);
-unlock:
- mutex_unlock(&dev->struct_mutex);
- return ret;
+ if (!i915_gem_request_completed(req))
+ args->busy |= 1 << (16 + i);
+ i915_gem_request_put(req);
+ }
+
+ req = i915_gem_active_get_request_rcu(&obj->last_write);
+ if (req) {
+ if (!i915_gem_request_completed(req))
+ args->busy |= 1 << req->engine->id;
+ i915_gem_request_put(req);
+ }
+ rcu_read_unlock();
+ }
+
+ drm_gem_object_unreference_unlocked(&obj->base);
+ return 0;
}
int
--
2.7.0.rc3
More information about the Intel-gfx
mailing list