drm/i915: Allow parsing of unsized batches
authorJon Bloomfield <jon.bloomfield@intel.com>
Wed, 1 Aug 2018 16:45:50 +0000 (09:45 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Nov 2019 18:16:21 +0000 (19:16 +0100)
commit 435e8fc059dbe0eec823a75c22da2972390ba9e0 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>
drivers/gpu/drm/i915/i915_gem_execbuffer.c

index dbfab0b..2240aba 100644 (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;