Re: [PATCH] drm/i915: Accurately track when we mark the hardware as idle/busy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2014-02-21 14:55 GMT-03:00 Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>:
> We currently call intel_mark_idle() too often, as we do so as a
> side-effect of processing the request queue. However, we the calls to
> intel_mark_idle() are expected to be paired with a call to
> intel_mark_busy() (or else we try to idle the hardware by accessing
> registers that are already disabled). Make the idle/busy tracking
> explicit to prevent the multiple calls.
>
> v2: We can drop some of the complexity in __i915_add_request() as
> queue_delayed_work() already behaves as we want (not requeuing the item
> if it is already in the queue) and mark_busy/mark_idle imply that the
> idle task is inactive.
>
> v3: We do still need to cancel the pending idle task so that it is sent
> again after the current busy load completes (not in the middle of it).
>
> Reported-by: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx>
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx>

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx>
Tested-by: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx> (ran the pm_pc8
test suite on HSW)

> ---
>  drivers/gpu/drm/i915/i915_drv.h      |  8 ++++++++
>  drivers/gpu/drm/i915/i915_gem.c      | 14 +++++---------
>  drivers/gpu/drm/i915/intel_display.c |  9 +++++++++
>  3 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 00222ccc0708..8441c8ac7cc8 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1134,6 +1134,14 @@ struct i915_gem_mm {
>          */
>         bool interruptible;
>
> +       /**
> +        * Is the GPU currently considered idle, or busy executing userspace
> +        * requests?  Whilst idle, we attempt to power down the hardware and
> +        * display clocks. In order to reduce the effect on performance, there
> +        * is a slight delay before we do so.
> +        */
> +       bool busy;
> +
>         /** Bit 6 swizzling required for X tiling */
>         uint32_t bit_6_swizzle_x;
>         /** Bit 6 swizzling required for Y tiling */
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 979c6b5ac6a3..293018392ac1 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2255,7 +2255,6 @@ int __i915_add_request(struct intel_ring_buffer *ring,
>         drm_i915_private_t *dev_priv = ring->dev->dev_private;
>         struct drm_i915_gem_request *request;
>         u32 request_ring_position, request_start;
> -       int was_empty;
>         int ret;
>
>         request_start = intel_ring_get_tail(ring);
> @@ -2306,7 +2305,6 @@ int __i915_add_request(struct intel_ring_buffer *ring,
>                 i915_gem_context_reference(request->ctx);
>
>         request->emitted_jiffies = jiffies;
> -       was_empty = list_empty(&ring->request_list);
>         list_add_tail(&request->list, &ring->request_list);
>         request->file_priv = NULL;
>
> @@ -2327,13 +2325,11 @@ int __i915_add_request(struct intel_ring_buffer *ring,
>         if (!dev_priv->ums.mm_suspended) {
>                 i915_queue_hangcheck(ring->dev);
>
> -               if (was_empty) {
> -                       cancel_delayed_work_sync(&dev_priv->mm.idle_work);
> -                       queue_delayed_work(dev_priv->wq,
> -                                          &dev_priv->mm.retire_work,
> -                                          round_jiffies_up_relative(HZ));
> -                       intel_mark_busy(dev_priv->dev);
> -               }
> +               cancel_delayed_work_sync(&dev_priv->mm.idle_work);
> +               queue_delayed_work(dev_priv->wq,
> +                                  &dev_priv->mm.retire_work,
> +                                  round_jiffies_up_relative(HZ));
> +               intel_mark_busy(dev_priv->dev);
>         }
>
>         if (out_seqno)
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index e127b23f0c31..b3b2576a32fc 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -8220,8 +8220,12 @@ void intel_mark_busy(struct drm_device *dev)
>  {
>         struct drm_i915_private *dev_priv = dev->dev_private;
>
> +       if (dev_priv->mm.busy)
> +               return;
> +
>         hsw_package_c8_gpu_busy(dev_priv);
>         i915_update_gfx_val(dev_priv);
> +       dev_priv->mm.busy = true;
>  }
>
>  void intel_mark_idle(struct drm_device *dev)
> @@ -8229,6 +8233,11 @@ void intel_mark_idle(struct drm_device *dev)
>         struct drm_i915_private *dev_priv = dev->dev_private;
>         struct drm_crtc *crtc;
>
> +       if (!dev_priv->mm.busy)
> +               return;
> +
> +       dev_priv->mm.busy = false;
> +
>         hsw_package_c8_gpu_idle(dev_priv);
>
>         if (!i915.powersave)
> --
> 1.9.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx



-- 
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux