Skip to content

Commit

Permalink
drm/i915: Improve execbuf debug
Browse files Browse the repository at this point in the history
Convert i915_gem_check_execbuffer to return the error code instead of
a boolean so our neat EINVAL debugging trick works within this function.

Signed-off-by: Tvrtko Ursulin <[email protected]>
Reviewed-by: Chris Wilson <[email protected]>
Signed-off-by: Chris Wilson <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
tursulin authored and ickle committed Dec 11, 2019
1 parent c81471f commit 00aff3f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,28 +1915,28 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
return err;
}

static bool i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
static int i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
{
if (exec->flags & __I915_EXEC_ILLEGAL_FLAGS)
return false;
return -EINVAL;

/* Kernel clipping was a DRI1 misfeature */
if (!(exec->flags & I915_EXEC_FENCE_ARRAY)) {
if (exec->num_cliprects || exec->cliprects_ptr)
return false;
return -EINVAL;
}

if (exec->DR4 == 0xffffffff) {
DRM_DEBUG("UXA submitting garbage DR4, fixing up\n");
exec->DR4 = 0;
}
if (exec->DR1 || exec->DR4)
return false;
return -EINVAL;

if ((exec->batch_start_offset | exec->batch_len) & 0x7)
return false;
return -EINVAL;

return true;
return 0;
}

static int i915_reset_gen7_sol_offsets(struct i915_request *rq)
Expand Down Expand Up @@ -2768,8 +2768,9 @@ i915_gem_execbuffer_ioctl(struct drm_device *dev, void *data,
exec2.flags = I915_EXEC_RENDER;
i915_execbuffer2_set_context_id(exec2, 0);

if (!i915_gem_check_execbuffer(&exec2))
return -EINVAL;
err = i915_gem_check_execbuffer(&exec2);
if (err)
return err;

/* Copy in the exec list from userland */
exec_list = kvmalloc_array(count, sizeof(*exec_list),
Expand Down Expand Up @@ -2846,8 +2847,9 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data,
return -EINVAL;
}

if (!i915_gem_check_execbuffer(args))
return -EINVAL;
err = i915_gem_check_execbuffer(args);
if (err)
return err;

/* Allocate an extra slot for use by the command parser */
exec2_list = kvmalloc_array(count + 1, eb_element_size(),
Expand Down

0 comments on commit 00aff3f

Please sign in to comment.