Skip to content

Commit

Permalink
drm/i915: Allow parsing of unsized batches
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jon Bloomfield committed Nov 5, 2019
1 parent 4f7af19 commit 435e8fc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ static inline u64 gen8_noncanonical_addr(u64 address)
static inline bool eb_use_cmdparser(const struct i915_execbuffer *eb)
{
return intel_engine_requires_cmd_parser(eb->engine) ||
(intel_engine_using_cmd_parser(eb->engine) && eb->batch_len);
(intel_engine_using_cmd_parser(eb->engine) &&
eb->args->batch_len);
}

static int eb_create(struct i915_execbuffer *eb)
Expand Down Expand Up @@ -2577,6 +2578,9 @@ i915_gem_do_execbuffer(struct drm_device *dev,
goto err_vma;
}

if (eb.batch_len == 0)
eb.batch_len = eb.batch->size - eb.batch_start_offset;

if (eb_use_cmdparser(&eb)) {
struct i915_vma *vma;

Expand All @@ -2587,9 +2591,6 @@ i915_gem_do_execbuffer(struct drm_device *dev,
}
}

if (eb.batch_len == 0)
eb.batch_len = eb.batch->size - eb.batch_start_offset;

/*
* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
* batch" bit. Hence we need to pin secure batches into the global gtt.
Expand Down

0 comments on commit 435e8fc

Please sign in to comment.