On Fri, Jun 17, 2016 at 08:09:11AM +0100, Arun Siluvery wrote: > This is a partial port of the following patch from John Harrison's GPU > scheduler patch series: (patch sent to Intel-GFX with the subject line > " [RFC 19/39] drm/i915: Added scheduler support to __wait_request() > calls" on Fri 17 July 2015) > > Author: John Harrison <John.C.Harrison@xxxxxxxxx> > Date: Thu Apr 10 10:48:55 2014 +0100 > Subject: drm/i915: Added scheduler support to __wait_request() calls > > Removed all scheduler references and backported it to this baseline. The reason > we need this is because Chris Wilson has pointed out that threads that don't > hold the struct_mutex should not be thrown out of __i915_wait_request during > TDR hang recovery. Therefore we need a way to determine which threads are > holding the mutex and which are not. > > Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > Cc: Mika Kuoppala <mika.kuoppala@xxxxxxxxxxxxxxx> > Signed-off-by: Tomas Elf <tomas.elf@xxxxxxxxx> > Signed-off-by: John Harrison <john.c.harrison@xxxxxxxxx> > Signed-off-by: Arun Siluvery <arun.siluvery@xxxxxxxxxxxxxxx> > --- > drivers/gpu/drm/i915/i915_drv.h | 7 ++++++- > drivers/gpu/drm/i915/i915_gem.c | 34 ++++++++++++++++++++++----------- > drivers/gpu/drm/i915/intel_display.c | 5 +++-- > drivers/gpu/drm/i915/intel_ringbuffer.c | 8 +++++--- > 4 files changed, 37 insertions(+), 17 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > index b2105bb..3e02b41 100644 > --- a/drivers/gpu/drm/i915/i915_drv.h > +++ b/drivers/gpu/drm/i915/i915_drv.h > @@ -3350,8 +3350,13 @@ void __i915_add_request(struct drm_i915_gem_request *req, > __i915_add_request(req, NULL, true) > #define i915_add_request_no_flush(req) \ > __i915_add_request(req, NULL, false) > + > +/* flags used by users of __i915_wait_request */ > +#define I915_WAIT_REQUEST_INTERRUPTIBLE (1 << 0) > +#define I915_WAIT_REQUEST_LOCKED (1 << 1) > + > int __i915_wait_request(struct drm_i915_gem_request *req, > - bool interruptible, > + u32 flags, > s64 *timeout, > struct intel_rps_client *rps); > int __must_check i915_wait_request(struct drm_i915_gem_request *req); > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > index bc404da..b0c2263 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -1455,7 +1455,9 @@ static int __i915_spin_request(struct drm_i915_gem_request *req, int state) > /** > * __i915_wait_request - wait until execution of request has finished > * @req: duh! > - * @interruptible: do an interruptible wait (normally yes) > + * @flags: flags to define the nature of wait > + * I915_WAIT_INTERRUPTIBLE - do an interruptible wait (normally yes) > + * I915_WAIT_LOCKED - caller is holding struct_mutex > * @timeout: in - how long to wait (NULL forever); out - how much time remaining > * @rps: RPS client > * > @@ -1470,7 +1472,7 @@ static int __i915_spin_request(struct drm_i915_gem_request *req, int state) > * errno with remaining time filled in timeout argument. > */ > int __i915_wait_request(struct drm_i915_gem_request *req, > - bool interruptible, > + u32 flags, > s64 *timeout, > struct intel_rps_client *rps) > { > @@ -1478,6 +1480,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, > struct drm_i915_private *dev_priv = req->i915; > const bool irq_test_in_progress = > ACCESS_ONCE(dev_priv->gpu_error.test_irq_rings) & intel_engine_flag(engine); > + bool interruptible = flags & I915_WAIT_REQUEST_INTERRUPTIBLE; > int state = interruptible ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; > DEFINE_WAIT(wait); > unsigned long timeout_expire; > @@ -1526,6 +1529,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, > for (;;) { > struct timer_list timer; > int reset_pending; > + bool locked = flags & I915_WAIT_REQUEST_LOCKED; > > prepare_to_wait(&engine->irq_queue, &wait, state); > > @@ -1543,7 +1547,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, > > reset_pending = i915_engine_reset_pending(&dev_priv->gpu_error, > NULL); > - if (reset_pending) { > + if (reset_pending || locked) { Very funny! -Chris -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx