We have all the info earlier now, so we may as well avoid the excess lookup. Signed-off-by: Ben Widawsky <ben at bwidawsk.net> --- drivers/gpu/drm/i915/i915_drv.h | 5 ++--- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/i915_gem_context.c | 21 ++------------------- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 5 ++--- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 3b452f2..736c714 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1897,7 +1897,7 @@ int i915_gem_context_enable(struct drm_i915_private *dev_priv); int i915_gem_context_open(struct drm_device *dev, struct drm_file *file); void i915_gem_context_close(struct drm_device *dev, struct drm_file *file); int i915_switch_context(struct intel_ring_buffer *ring, - struct drm_file *file, int to_id); + struct i915_hw_context *to); void i915_gem_context_free(struct kref *ctx_ref); static inline void i915_gem_context_reference(struct i915_hw_context *ctx) { @@ -1913,8 +1913,7 @@ struct i915_hw_context * i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id); struct i915_ctx_hang_stats * __must_check i915_gem_context_get_hang_stats(struct intel_ring_buffer *ring, - struct drm_file *file, - u32 id); + struct i915_hw_context *to); int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file); int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index e58584b..73e116e 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2709,7 +2709,7 @@ int i915_gpu_idle(struct drm_device *dev) /* Flush everything onto the inactive list. */ for_each_ring(ring, dev_priv, i) { - ret = i915_switch_context(ring, NULL, DEFAULT_CONTEXT_ID); + ret = i915_switch_context(ring, ring->default_context); if (ret) return ret; diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 2975ca0..37ebfa2 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -400,12 +400,9 @@ static int context_idr_cleanup(int id, void *p, void *data) struct i915_ctx_hang_stats * i915_gem_context_get_hang_stats(struct intel_ring_buffer *ring, - struct drm_file *file, - u32 id) + struct i915_hw_context *to) { struct drm_i915_private *dev_priv = ring->dev->dev_private; - struct drm_i915_file_private *file_priv = file->driver_priv; - struct i915_hw_context *to; if (dev_priv->hw_contexts_disabled) return ERR_PTR(-ENOENT); @@ -413,13 +410,6 @@ i915_gem_context_get_hang_stats(struct intel_ring_buffer *ring, if (ring->id != RCS) return ERR_PTR(-EINVAL); - if (file == NULL) - return ERR_PTR(-EINVAL); - - if (id == DEFAULT_CONTEXT_ID) - return &file_priv->private_default_ctx->hang_stats; - - to = i915_gem_context_get(file->driver_priv, id); if (to == NULL) return ERR_PTR(-ENOENT); @@ -633,22 +623,15 @@ done: * object while letting the normal object tracking destroy the backing BO. */ int i915_switch_context(struct intel_ring_buffer *ring, - struct drm_file *file, - int to_id) + struct i915_hw_context *to) { struct drm_i915_private *dev_priv = ring->dev->dev_private; - struct i915_hw_context *to; if (dev_priv->hw_contexts_disabled) return 0; WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex)); - if (file == NULL) - to = ring->default_context; - else - to = i915_gem_context_get(file->driver_priv, to_id); - if (to == NULL) return -ENOENT; diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 3eda4e1..aeec8c0 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -1049,8 +1049,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, if (ret) goto err; - hs = i915_gem_context_get_hang_stats(&dev_priv->ring[RCS], - file, ctx_id); + hs = i915_gem_context_get_hang_stats(&dev_priv->ring[RCS], ctx); if (IS_ERR(hs)) { ret = PTR_ERR(hs); goto err; @@ -1061,7 +1060,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } - ret = i915_switch_context(ring, file, ctx_id); + ret = i915_switch_context(ring, ctx); if (ret) goto err; -- 1.8.3.1