Message ID | 20190107115509.12523-5-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/46] drm/i915: Return immediately if trylock fails for direct-reclaim | expand |
Chris Wilson <chris@chris-wilson.co.uk> writes: > Record the wakeref used for keeping the device awake as the GPU is > executing requests and be sure to cancel the tracking upon parking. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> > --- > drivers/gpu/drm/i915/i915_drv.h | 2 +- > drivers/gpu/drm/i915/i915_gem.c | 11 +++++++---- > 2 files changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > index 464ff89d1464..a20bd2ec48de 100644 > --- a/drivers/gpu/drm/i915/i915_drv.h > +++ b/drivers/gpu/drm/i915/i915_drv.h > @@ -1966,7 +1966,7 @@ struct drm_i915_private { > * In order to reduce the effect on performance, there > * is a slight delay before we do so. > */ > - bool awake; > + intel_wakeref_t awake; > > /** > * The number of times we have woken up. > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > index 5ac32ea4c8fa..27f207cbabd9 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -139,6 +139,8 @@ int i915_mutex_lock_interruptible(struct drm_device *dev) > > static u32 __i915_gem_park(struct drm_i915_private *i915) > { > + intel_wakeref_t wakeref; > + > GEM_TRACE("\n"); > > lockdep_assert_held(&i915->drm.struct_mutex); > @@ -169,14 +171,15 @@ static u32 __i915_gem_park(struct drm_i915_private *i915) > i915_pmu_gt_parked(i915); > i915_vma_parked(i915); > > - i915->gt.awake = false; > + wakeref = fetch_and_zero(&i915->gt.awake); > + GEM_BUG_ON(!wakeref); > > if (INTEL_GEN(i915) >= 6) > gen6_rps_idle(i915); > > intel_display_power_put(i915, POWER_DOMAIN_GT_IRQ); > > - intel_runtime_pm_put_unchecked(i915); > + intel_runtime_pm_put(i915, wakeref); > > return i915->gt.epoch; > } > @@ -205,7 +208,8 @@ void i915_gem_unpark(struct drm_i915_private *i915) > if (i915->gt.awake) > return; > > - intel_runtime_pm_get_noresume(i915); > + i915->gt.awake = intel_runtime_pm_get_noresume(i915); > + GEM_BUG_ON(!i915->gt.awake); > > /* > * It seems that the DMC likes to transition between the DC states a lot > @@ -220,7 +224,6 @@ void i915_gem_unpark(struct drm_i915_private *i915) > */ > intel_display_power_get(i915, POWER_DOMAIN_GT_IRQ); > > - i915->gt.awake = true; > if (unlikely(++i915->gt.epoch == 0)) /* keep 0 as invalid */ > i915->gt.epoch = 1; > > -- > 2.20.1 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 464ff89d1464..a20bd2ec48de 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1966,7 +1966,7 @@ struct drm_i915_private { * In order to reduce the effect on performance, there * is a slight delay before we do so. */ - bool awake; + intel_wakeref_t awake; /** * The number of times we have woken up. diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 5ac32ea4c8fa..27f207cbabd9 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -139,6 +139,8 @@ int i915_mutex_lock_interruptible(struct drm_device *dev) static u32 __i915_gem_park(struct drm_i915_private *i915) { + intel_wakeref_t wakeref; + GEM_TRACE("\n"); lockdep_assert_held(&i915->drm.struct_mutex); @@ -169,14 +171,15 @@ static u32 __i915_gem_park(struct drm_i915_private *i915) i915_pmu_gt_parked(i915); i915_vma_parked(i915); - i915->gt.awake = false; + wakeref = fetch_and_zero(&i915->gt.awake); + GEM_BUG_ON(!wakeref); if (INTEL_GEN(i915) >= 6) gen6_rps_idle(i915); intel_display_power_put(i915, POWER_DOMAIN_GT_IRQ); - intel_runtime_pm_put_unchecked(i915); + intel_runtime_pm_put(i915, wakeref); return i915->gt.epoch; } @@ -205,7 +208,8 @@ void i915_gem_unpark(struct drm_i915_private *i915) if (i915->gt.awake) return; - intel_runtime_pm_get_noresume(i915); + i915->gt.awake = intel_runtime_pm_get_noresume(i915); + GEM_BUG_ON(!i915->gt.awake); /* * It seems that the DMC likes to transition between the DC states a lot @@ -220,7 +224,6 @@ void i915_gem_unpark(struct drm_i915_private *i915) */ intel_display_power_get(i915, POWER_DOMAIN_GT_IRQ); - i915->gt.awake = true; if (unlikely(++i915->gt.epoch == 0)) /* keep 0 as invalid */ i915->gt.epoch = 1;
Record the wakeref used for keeping the device awake as the GPU is executing requests and be sure to cancel the tracking upon parking. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jani Nikula <jani.nikula@intel.com> --- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)