From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: "Goel, Akash" <akash.goel@intel.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects
Date: Fri, 20 Nov 2015 08:06:59 -0800 [thread overview]
Message-ID: <564F4523.3000606@virtuousgeek.org> (raw)
In-Reply-To: <1448029000-10616-1-git-send-email-chris@chris-wilson.co.uk>
On 11/20/2015 06:16 AM, Chris Wilson wrote:
> As we mark the preallocated objects as bound, we should also flag them
> correctly as being map-and-fenceable (if appropriate!) so that later
> users do not get confused and try and rebind the pinned vma in order to
> get a map-and-fenceable binding.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: "Goel, Akash" <akash.goel@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Cc: stable@vger.kernel.org
> ---
> drivers/gpu/drm/i915/i915_drv.h | 1 +
> drivers/gpu/drm/i915/i915_gem.c | 43 +++++++++++++++++++---------------
> drivers/gpu/drm/i915/i915_gem_gtt.c | 1 +
> drivers/gpu/drm/i915/i915_gem_stolen.c | 1 +
> 4 files changed, 27 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index f2b65433ed7d..24143e5273b6 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2844,6 +2844,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
>
> int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
> u32 flags);
> +void __i915_vma_set_map_and_fenceable(struct i915_vma *vma);
> int __must_check i915_vma_unbind(struct i915_vma *vma);
> /*
> * BEWARE: Do not use the function below unless you can _absolutely_
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 3ad198a41c4a..e6a8a52c8a6b 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4092,6 +4092,29 @@ i915_vma_misplaced(struct i915_vma *vma, uint32_t alignment, uint64_t flags)
> return false;
> }
>
> +void __i915_vma_set_map_and_fenceable(struct i915_vma *vma)
> +{
> + struct drm_i915_gem_object *obj = vma->obj;
> + bool mappable, fenceable;
> + u32 fence_size, fence_alignment;
> +
> + fence_size = i915_gem_get_gtt_size(obj->base.dev,
> + obj->base.size,
> + obj->tiling_mode);
> + fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
> + obj->base.size,
> + obj->tiling_mode,
> + true);
> +
> + fenceable = (vma->node.size == fence_size &&
> + (vma->node.start & (fence_alignment - 1)) == 0);
> +
> + mappable = (vma->node.start + fence_size <=
> + to_i915(obj->base.dev)->gtt.mappable_end);
> +
> + obj->map_and_fenceable = mappable && fenceable;
> +}
> +
> static int
> i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
> struct i915_address_space *vm,
> @@ -4159,25 +4182,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,
>
> if (ggtt_view && ggtt_view->type == I915_GGTT_VIEW_NORMAL &&
> (bound ^ vma->bound) & GLOBAL_BIND) {
> - bool mappable, fenceable;
> - u32 fence_size, fence_alignment;
> -
> - fence_size = i915_gem_get_gtt_size(obj->base.dev,
> - obj->base.size,
> - obj->tiling_mode);
> - fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev,
> - obj->base.size,
> - obj->tiling_mode,
> - true);
> -
> - fenceable = (vma->node.size == fence_size &&
> - (vma->node.start & (fence_alignment - 1)) == 0);
> -
> - mappable = (vma->node.start + fence_size <=
> - dev_priv->gtt.mappable_end);
> -
> - obj->map_and_fenceable = mappable && fenceable;
> -
> + __i915_vma_set_map_and_fenceable(vma);
> WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable);
> }
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index a09f8f0510d5..74b26b2d0889 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2704,6 +2704,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
> return ret;
> }
> vma->bound |= GLOBAL_BIND;
> + __i915_vma_set_map_and_fenceable(vma);
> list_add_tail(&vma->mm_list, &ggtt_vm->inactive_list);
> }
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index 598ed2facf85..3476877fc0d6 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -688,6 +688,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
> }
>
> vma->bound |= GLOBAL_BIND;
> + __i915_vma_set_map_and_fenceable(vma);
> list_add_tail(&vma->mm_list, &ggtt->inactive_list);
> }
>
>
Looks important.
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
prev parent reply other threads:[~2015-11-20 16:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 14:16 [PATCH v2 1/2] drm/i915: Set the map-and-fenceable flag for preallocated objects Chris Wilson
2015-11-20 14:16 ` [PATCH v2 2/2] drm/i915: Pin the ifbdev for the info->system_base GGTT mmapping Chris Wilson
2015-11-20 14:34 ` [PATCH v3] " Chris Wilson
2015-11-20 16:15 ` Jesse Barnes
2015-11-20 16:29 ` [PATCH v4] " Chris Wilson
2015-11-20 16:35 ` Jesse Barnes
2015-11-20 16:46 ` [Intel-gfx] " kbuild test robot
2015-11-20 18:01 ` kbuild test robot
2015-11-24 16:46 ` Daniel Vetter
2015-12-01 9:01 ` Jani Nikula
2015-11-24 21:20 ` Lukas Wunner
2015-12-04 16:05 ` [PATCH v5] " Chris Wilson
2015-12-06 20:33 ` Lukas Wunner
2015-12-16 10:52 ` Daniel Vetter
2015-12-17 11:34 ` [Intel-gfx] " Ville Syrjälä
2015-12-10 16:36 ` Ville Syrjälä
2015-12-10 16:41 ` Takashi Iwai
2015-12-17 15:59 ` Daniel Vetter
2015-12-23 11:07 ` Jani Nikula
2015-11-20 16:06 ` Jesse Barnes [this message]
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=564F4523.3000606@virtuousgeek.org \
--to=jbarnes@virtuousgeek.org \
--cc=akash.goel@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).