[Intel-gfx] [PATCH 2/3] drm/i915: release the GTT mmaps when going into D3

Rodrigo Vivi rodrigo.vivi at gmail.com
Fri Dec 13 19:22:40 CET 2013


When I saw this I was afraid this force could break userspace somehow,
but Paulo explained me the release with pagefault mechanism. Thanks Paulo.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi at gmail.com>

On Fri, Dec 13, 2013 at 3:22 PM, Paulo Zanoni <przanoni at gmail.com> wrote:
> From: Paulo Zanoni <paulo.r.zanoni at intel.com>
>
> So we'll get a fault when someone tries to access the mmap, then we'll
> wake up from D3.
>
> v2: - Rebase
> v3: - Use gtt active/inactive
>
> Testcase: igt/pm_pc8/gem-mmap-gtt
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.c |  2 ++
>  drivers/gpu/drm/i915/i915_drv.h |  1 +
>  drivers/gpu/drm/i915/i915_gem.c | 10 ++++++++++
>  3 files changed, 13 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 70590b0..23f8217 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -920,6 +920,8 @@ static int i915_runtime_suspend(struct device *device)
>
>         DRM_DEBUG_KMS("Suspending device\n");
>
> +       i915_gem_release_all_mmaps(dev_priv);
> +
>         del_timer_sync(&dev_priv->gpu_error.hangcheck_timer);
>         dev_priv->pm.suspended = true;
>         intel_opregion_notify_adapter(dev, PCI_D3cold);
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index fca2eb6..5e036be 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2013,6 +2013,7 @@ void i915_gem_object_unpin(struct drm_i915_gem_object *obj);
>  int __must_check i915_vma_unbind(struct i915_vma *vma);
>  int __must_check i915_gem_object_ggtt_unbind(struct drm_i915_gem_object *obj);
>  int i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
> +void i915_gem_release_all_mmaps(struct drm_i915_private *dev_priv);
>  void i915_gem_release_mmap(struct drm_i915_gem_object *obj);
>  void i915_gem_lastclose(struct drm_device *dev);
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 66f8133..0d7c061 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1465,6 +1465,16 @@ out:
>         return ret;
>  }
>
> +void i915_gem_release_all_mmaps(struct drm_i915_private *dev_priv)
> +{
> +       struct i915_vma *vma;
> +
> +       list_for_each_entry(vma, &dev_priv->gtt.base.active_list, mm_list)
> +               i915_gem_release_mmap(vma->obj);
> +       list_for_each_entry(vma, &dev_priv->gtt.base.inactive_list, mm_list)
> +               i915_gem_release_mmap(vma->obj);
> +}
> +
>  /**
>   * i915_gem_release_mmap - remove physical page mappings
>   * @obj: obj in question
> --
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx



-- 
Rodrigo Vivi
Blog: http://blog.vivi.eng.br



More information about the Intel-gfx mailing list