Commit f8ca0c07 authored by Dave Gordon's avatar Dave Gordon Committed by Chris Wilson

drm/i915: rename & update eb_select_ring()

'ring' is an old deprecated term for a GPU engine, so we're trying to
phase out all such terminology. eb_select_ring() not only has 'ring'
(meaning engine) in its name, but it has an ugly calling convention
whereby it returns an errno and stores a pointer-to-engine indirectly
through an output parameter. As there is only one error it ever returns
(-EINVAL), we can make it return the pointer directly, and have the
caller pass back the error code -EINVAL if the pointer result is NULL.

Thus we can replace
-	ret = eb_select_ring(dev_priv, file, args, &engine);
-	if (ret)
-		return ret;
with
+	engine = eb_select_engine(dev_priv, file, args);
+	if (!engine)
+		return -EINVAL;
for increased clarity and maybe save a few cycles too.
Signed-off-by: default avatarDave Gordon <david.s.gordon@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1469034967-15840-4-git-send-email-david.s.gordon@intel.comReviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent 38a0f2db
...@@ -1380,24 +1380,24 @@ static const enum intel_engine_id user_ring_map[I915_USER_RINGS + 1] = { ...@@ -1380,24 +1380,24 @@ static const enum intel_engine_id user_ring_map[I915_USER_RINGS + 1] = {
[I915_EXEC_VEBOX] = VECS [I915_EXEC_VEBOX] = VECS
}; };
static int static struct intel_engine_cs *
eb_select_ring(struct drm_i915_private *dev_priv, eb_select_engine(struct drm_i915_private *dev_priv,
struct drm_file *file, struct drm_file *file,
struct drm_i915_gem_execbuffer2 *args, struct drm_i915_gem_execbuffer2 *args)
struct intel_engine_cs **ring)
{ {
unsigned int user_ring_id = args->flags & I915_EXEC_RING_MASK; unsigned int user_ring_id = args->flags & I915_EXEC_RING_MASK;
struct intel_engine_cs *engine;
if (user_ring_id > I915_USER_RINGS) { if (user_ring_id > I915_USER_RINGS) {
DRM_DEBUG("execbuf with unknown ring: %u\n", user_ring_id); DRM_DEBUG("execbuf with unknown ring: %u\n", user_ring_id);
return -EINVAL; return NULL;
} }
if ((user_ring_id != I915_EXEC_BSD) && if ((user_ring_id != I915_EXEC_BSD) &&
((args->flags & I915_EXEC_BSD_MASK) != 0)) { ((args->flags & I915_EXEC_BSD_MASK) != 0)) {
DRM_DEBUG("execbuf with non bsd ring but with invalid " DRM_DEBUG("execbuf with non bsd ring but with invalid "
"bsd dispatch flags: %d\n", (int)(args->flags)); "bsd dispatch flags: %d\n", (int)(args->flags));
return -EINVAL; return NULL;
} }
if (user_ring_id == I915_EXEC_BSD && HAS_BSD2(dev_priv)) { if (user_ring_id == I915_EXEC_BSD && HAS_BSD2(dev_priv)) {
...@@ -1412,20 +1412,20 @@ eb_select_ring(struct drm_i915_private *dev_priv, ...@@ -1412,20 +1412,20 @@ eb_select_ring(struct drm_i915_private *dev_priv,
} else { } else {
DRM_DEBUG("execbuf with unknown bsd ring: %u\n", DRM_DEBUG("execbuf with unknown bsd ring: %u\n",
bsd_idx); bsd_idx);
return -EINVAL; return NULL;
} }
*ring = &dev_priv->engine[_VCS(bsd_idx)]; engine = &dev_priv->engine[_VCS(bsd_idx)];
} else { } else {
*ring = &dev_priv->engine[user_ring_map[user_ring_id]]; engine = &dev_priv->engine[user_ring_map[user_ring_id]];
} }
if (!intel_engine_initialized(*ring)) { if (!intel_engine_initialized(engine)) {
DRM_DEBUG("execbuf with invalid ring: %u\n", user_ring_id); DRM_DEBUG("execbuf with invalid ring: %u\n", user_ring_id);
return -EINVAL; return NULL;
} }
return 0; return engine;
} }
static int static int
...@@ -1467,9 +1467,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, ...@@ -1467,9 +1467,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
if (args->flags & I915_EXEC_IS_PINNED) if (args->flags & I915_EXEC_IS_PINNED)
dispatch_flags |= I915_DISPATCH_PINNED; dispatch_flags |= I915_DISPATCH_PINNED;
ret = eb_select_ring(dev_priv, file, args, &engine); engine = eb_select_engine(dev_priv, file, args);
if (ret) if (!engine)
return ret; return -EINVAL;
if (args->buffer_count < 1) { if (args->buffer_count < 1) {
DRM_DEBUG("execbuf with %d buffers\n", args->buffer_count); DRM_DEBUG("execbuf with %d buffers\n", args->buffer_count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment