drm/i915: Allow parsing of unsized batches

commit 435e8fc059 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>
This commit is contained in:
Jon Bloomfield
2018-08-01 09:45:50 -07:00
committed by Chris
parent 637dbb0142
commit 24e6857684

View File

@@ -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;
@@ -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);
@@ -1748,6 +1746,10 @@ 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;
@@ -1755,8 +1757,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
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;