drm/i915/gem: Honour O_NONBLOCK before throttling execbuf submissions

Check the user's flags on the struct file before deciding whether or not
to stall before submitting a request. This allows us to reasonably
cheaply honour O_NONBLOCK without checking at more critical phases
during request submission.

Suggested-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Steve Carbonari <steven.carbonari@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200225192206.1107336-3-chris@chris-wilson.co.uk
This commit is contained in:
Chris Wilson 2020-02-25 19:22:06 +00:00
parent 88be76cdaf
commit cb4d5dc3e7

View File

@ -2327,15 +2327,22 @@ static int __eb_pin_engine(struct i915_execbuffer *eb, struct intel_context *ce)
intel_context_timeline_unlock(tl); intel_context_timeline_unlock(tl);
if (rq) { if (rq) {
if (i915_request_wait(rq, bool nonblock = eb->file->filp->f_flags & O_NONBLOCK;
I915_WAIT_INTERRUPTIBLE, long timeout;
MAX_SCHEDULE_TIMEOUT) < 0) {
i915_request_put(rq); timeout = MAX_SCHEDULE_TIMEOUT;
err = -EINTR; if (nonblock)
timeout = 0;
timeout = i915_request_wait(rq,
I915_WAIT_INTERRUPTIBLE,
timeout);
i915_request_put(rq);
if (timeout < 0) {
err = nonblock ? -EWOULDBLOCK : timeout;
goto err_exit; goto err_exit;
} }
i915_request_put(rq);
} }
eb->engine = ce->engine; eb->engine = ce->engine;