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:13:35 +0000 (19:13 +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 1392e8a72797b942057bf39f3b0d82b16aad5571..556849350f275725726de8fd4bc71f0b9424771d 100644 (file)
@@ -1540,12 +1540,17 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
        if (use_cmdparser(ring, args->batch_len)) {
                struct drm_i915_gem_object *parsed_batch_obj;
 
+               u32 batch_off = args->batch_start_offset;
+               u32 batch_len = args->batch_len;
+               if (batch_len == 0)
+                       batch_len = batch_obj->base.size - batch_off;
+
                parsed_batch_obj = i915_gem_execbuffer_parse(ring,
                                                      &shadow_exec_entry,
                                                      eb, vm,
                                                      batch_obj,
-                                                     args->batch_start_offset,
-                                                     args->batch_len);
+                                                     batch_off,
+                                                     batch_len);
                if (IS_ERR(parsed_batch_obj)) {
                        ret = PTR_ERR(parsed_batch_obj);
                        goto err;