From: Ben Widawsky <ben@bwidawsk.net>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 5/7] drm/i915: Initialize the aliasing ppgtt as part of global gtt
Date: Wed, 30 Jul 2014 20:46:11 -0700 [thread overview]
Message-ID: <20140731034610.GA734@bwidawsk.net> (raw)
In-Reply-To: <1406749324-2156-5-git-send-email-daniel.vetter@ffwll.ch>
<1386367941-7131-76-git-send-email-benjamin.widawsky@intel.com>
On Wed, Jul 30, 2014 at 09:42:02PM +0200, Daniel Vetter wrote:
> Stuffing this into the context setup code doesn't make a lot of sense.
> Also reusing the real ppgtt setup code makes even less sense since the
> aliasing ppgtt isn't a real address space. Leaving all that stuff
> unitialized will make sure that we catch any abusers promptly.
>
> This is also a prep work to clean up the context->ppgtt link.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/i915/i915_gem_context.c | 13 +------------
> drivers/gpu/drm/i915/i915_gem_gtt.c | 31 +++++++++++++++++++++++++------
> 2 files changed, 26 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 3b8367aa8404..7a455fcee3a7 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -276,17 +276,6 @@ i915_gem_create_context(struct drm_device *dev,
> goto err_unpin;
> } else
> ctx->vm = &ppgtt->base;
> -
> - /* This case is reserved for the global default context and
> - * should only happen once. */
> - if (is_global_default_ctx) {
> - if (WARN_ON(dev_priv->mm.aliasing_ppgtt)) {
> - ret = -EEXIST;
> - goto err_unpin;
> - }
> -
> - dev_priv->mm.aliasing_ppgtt = ppgtt;
> - }
> } else if (USES_PPGTT(dev)) {
> /* For platforms which only have aliasing PPGTT, we fake the
> * address space and refcounting. */
> @@ -361,7 +350,7 @@ int i915_gem_context_init(struct drm_device *dev)
> }
> }
>
> - ctx = i915_gem_create_context(dev, NULL, USES_PPGTT(dev));
> + ctx = i915_gem_create_context(dev, NULL, USES_FULL_PPGTT(dev));
> if (IS_ERR(ctx)) {
> DRM_ERROR("Failed to create default global context (error %ld)\n",
> PTR_ERR(ctx));
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 4fa7807ed4d5..cb9bb13ff20a 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -1191,23 +1191,27 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
> return 0;
> }
>
> -int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
> +int __hw_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
> {
> struct drm_i915_private *dev_priv = dev->dev_private;
> - int ret = 0;
>
> ppgtt->base.dev = dev;
> ppgtt->base.scratch = dev_priv->gtt.base.scratch;
>
> if (INTEL_INFO(dev)->gen < 8)
> - ret = gen6_ppgtt_init(ppgtt);
> + return gen6_ppgtt_init(ppgtt);
> else if (IS_GEN8(dev))
> - ret = gen8_ppgtt_init(ppgtt, dev_priv->gtt.base.total);
> + return gen8_ppgtt_init(ppgtt, dev_priv->gtt.base.total);
> else
> BUG();
> +}
> +int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
> +{
> + struct drm_i915_private *dev_priv = dev->dev_private;
> + int ret = 0;
>
> + ret = __hw_ppgtt_init(dev, ppgtt);
> if (!ret) {
> - struct drm_i915_private *dev_priv = dev->dev_private;
> kref_init(&ppgtt->ref);
> drm_mm_init(&ppgtt->base.mm, ppgtt->base.start,
> ppgtt->base.total);
> @@ -1728,6 +1732,7 @@ int i915_gem_setup_global_gtt(struct drm_device *dev,
> struct drm_mm_node *entry;
> struct drm_i915_gem_object *obj;
> unsigned long hole_start, hole_end;
> + int ret;
>
> BUG_ON(mappable_end > end);
>
> @@ -1739,7 +1744,7 @@ int i915_gem_setup_global_gtt(struct drm_device *dev,
> /* Mark any preallocated objects as occupied */
> list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
> struct i915_vma *vma = i915_gem_obj_to_vma(obj, ggtt_vm);
> - int ret;
> +
> DRM_DEBUG_KMS("reserving preallocated space: %lx + %zx\n",
> i915_gem_obj_ggtt_offset(obj), obj->base.size);
>
> @@ -1766,6 +1771,20 @@ int i915_gem_setup_global_gtt(struct drm_device *dev,
> /* And finally clear the reserved guard page */
> ggtt_vm->clear_range(ggtt_vm, end - PAGE_SIZE, PAGE_SIZE, true);
>
> + if (HAS_ALIASING_PPGTT(dev) && USES_FULL_PPGTT(dev)) {
> + struct i915_hw_ppgtt *ppgtt;
> +
> + ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
> + if (!ppgtt)
> + return -ENOMEM;
> +
> + ret = __hw_ppgtt_init(dev, ppgtt);
> + if (!ret)
> + return ret;
> +
> + dev_priv->mm.aliasing_ppgtt = ppgtt;
> + }
> +
> return 0;
> }
>
> --
> 1.9.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ben Widawsky, Intel Open Source Technology Center
next prev parent reply other threads:[~2014-07-31 3:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-30 19:41 [PATCH 1/7] drm/i915: Track file_priv, not ctx in the ppgtt structure Daniel Vetter
2014-07-30 19:41 ` [PATCH 2/7] drm/i915: Only refcount ppgtt if it actually is one Daniel Vetter
2014-07-31 6:52 ` Chris Wilson
2014-07-31 7:39 ` Daniel Vetter
2014-07-31 8:18 ` Daniel Vetter
2014-07-30 19:42 ` [PATCH 3/7] drm/i915: Add proper prefix to obj_to_ggtt Daniel Vetter
2014-07-31 11:43 ` Thierry, Michel
2014-07-30 19:42 ` [PATCH 4/7] drm/i915: Allow i915_gem_setup_global_gtt to fail Daniel Vetter
2014-07-31 6:49 ` Chris Wilson
2014-07-30 19:42 ` [PATCH 5/7] drm/i915: Initialize the aliasing ppgtt as part of global gtt Daniel Vetter
2014-07-31 3:46 ` Ben Widawsky [this message]
2014-07-31 3:47 ` Ben Widawsky
2014-07-31 3:48 ` Ben Widawsky
2014-07-31 9:10 ` Daniel Vetter
2014-07-31 15:47 ` Thierry, Michel
2014-07-31 16:15 ` Ville Syrjälä
2014-08-01 9:54 ` Thierry, Michel
2014-08-04 15:38 ` Daniel Vetter
2014-08-04 8:17 ` Daniel Vetter
2014-08-04 14:18 ` [PATCH] " Daniel Vetter
2014-08-06 8:18 ` Thierry, Michel
2014-08-06 8:30 ` Daniel Vetter
2014-08-06 8:44 ` Thierry, Michel
2014-08-06 8:46 ` Daniel Vetter
2014-07-30 19:42 ` [PATCH 6/7] drm/i915: Only track real ppgtt for a context Daniel Vetter
2014-07-30 21:11 ` Daniel Vetter
2014-08-04 14:20 ` [PATCH] " Daniel Vetter
2014-08-04 17:17 ` Thierry, Michel
2014-08-04 17:56 ` Daniel Vetter
2014-07-30 19:42 ` [PATCH 7/7] drm/i915: Drop create_vm argument to i915_gem_create_context Daniel Vetter
2014-07-31 9:33 ` [PATCH 1/7] drm/i915: Track file_priv, not ctx in the ppgtt structure Thierry, Michel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140731034610.GA734@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox