Skip to content

Commit

Permalink
drm/i915: Allow parsing of unsized batches
Browse files Browse the repository at this point in the history
commit 435e8fc upstream.

In "drm/i915: Add support for mandatory cmdparsing" we introduced the
concept of mandatory parsing. This allows the cmdparser to be invoked
even when user passes batch_len=0 to the execbuf ioctl's.

However, the cmdparser needs to know the extents of the buffer being
scanned. Refactor the code to ensure the cmdparser uses the actual
object size, instead of the incoming length, if user passes 0.

Signed-off-by: Jon Bloomfield <jon.bloomfield@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Tyler Hicks <tyhicks@canonical.com>
Reviewed-by: Chris Wilson <chris.p.wilson@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jon Bloomfield authored and Greg Kroah-Hartman committed Nov 12, 2019
1 parent 9f5fb6f commit 05e5cf1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/gpu/drm/i915/i915_gem_execbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct i915_execbuffer_params {
struct i915_vma *batch;
u32 dispatch_flags;
u32 args_batch_start_offset;
u64 args_batch_len;
struct intel_engine_cs *engine;
struct i915_gem_context *ctx;
struct drm_i915_gem_request *request;
Expand Down Expand Up @@ -1506,13 +1507,10 @@ execbuf_submit(struct i915_execbuffer_params *params,
return ret;
}

exec_len = args->batch_len;
exec_len = params->args_batch_len;
exec_start = params->batch->node.start +
params->args_batch_start_offset;

if (exec_len == 0)
exec_len = params->batch->size - params->args_batch_start_offset;

ret = params->engine->emit_bb_start(params->request,
exec_start, exec_len,
params->dispatch_flags);
Expand Down Expand Up @@ -1748,15 +1746,19 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
}

params->args_batch_start_offset = args->batch_start_offset;
params->args_batch_len = args->batch_len;
if (args->batch_len == 0)
params->args_batch_len = params->batch->size - params->args_batch_start_offset;

if (intel_engine_requires_cmd_parser(engine) ||
(intel_engine_using_cmd_parser(engine) && args->batch_len)) {
struct i915_vma *vma;

vma = i915_gem_execbuffer_parse(engine, &shadow_exec_entry,
params->batch->obj,
eb, vm,
args->batch_start_offset,
args->batch_len);
params->args_batch_start_offset,
params->args_batch_len);
if (IS_ERR(vma)) {
ret = PTR_ERR(vma);
goto err;
Expand Down

0 comments on commit 05e5cf1

Please sign in to comment.