From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: paulo.r.zanoni@intel.com, jani.nikula@intel.com,
thomas.hellstrom@intel.com, matthew.auld@intel.com,
daniel.vetter@intel.com, christian.koenig@amd.com
Subject: Re: [Intel-gfx] [PATCH 04/16] drm/i915/vm_bind: Add support to create persistent vma
Date: Wed, 28 Sep 2022 08:38:39 +0100 [thread overview]
Message-ID: <7e4e626d-4f7f-f802-693f-07ded7673c35@linux.intel.com> (raw)
In-Reply-To: <20220928061918.6340-5-niranjana.vishwanathapura@intel.com>
On 28/09/2022 07:19, Niranjana Vishwanathapura wrote:
> Add i915_vma_instance_persistent() to create persistent vmas.
> Persistent vmas will use i915_gtt_view to support partial binding.
>
> vma_lookup is tied to segment of the object instead of section
> of VA space. Hence, it do not support aliasing. ie., multiple
> mappings (at different VA) point to the same gtt_view of object.
> Skip vma_lookup for persistent vmas to support aliasing.
>
> Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_vma.c | 39 ++++++++++++++++++++++++---
> drivers/gpu/drm/i915/i915_vma.h | 16 +++++++++--
> drivers/gpu/drm/i915/i915_vma_types.h | 7 +++++
> 3 files changed, 57 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index f17c09ead7d7..5839e1f55f00 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -109,7 +109,8 @@ static void __i915_vma_retire(struct i915_active *ref)
> static struct i915_vma *
> vma_create(struct drm_i915_gem_object *obj,
> struct i915_address_space *vm,
> - const struct i915_gtt_view *view)
> + const struct i915_gtt_view *view,
> + bool skip_lookup_cache)
> {
> struct i915_vma *pos = ERR_PTR(-E2BIG);
> struct i915_vma *vma;
> @@ -196,6 +197,9 @@ vma_create(struct drm_i915_gem_object *obj,
> __set_bit(I915_VMA_GGTT_BIT, __i915_vma_flags(vma));
> }
>
> + if (skip_lookup_cache)
> + goto skip_rb_insert;
> +
> rb = NULL;
> p = &obj->vma.tree.rb_node;
> while (*p) {
> @@ -220,6 +224,7 @@ vma_create(struct drm_i915_gem_object *obj,
> rb_link_node(&vma->obj_node, rb, p);
> rb_insert_color(&vma->obj_node, &obj->vma.tree);
>
> +skip_rb_insert:
> if (i915_vma_is_ggtt(vma))
> /*
> * We put the GGTT vma at the start of the vma-list, followed
> @@ -299,7 +304,34 @@ i915_vma_instance(struct drm_i915_gem_object *obj,
>
> /* vma_create() will resolve the race if another creates the vma */
> if (unlikely(!vma))
> - vma = vma_create(obj, vm, view);
> + vma = vma_create(obj, vm, view, false);
> +
> + GEM_BUG_ON(!IS_ERR(vma) && i915_vma_compare(vma, vm, view));
> + return vma;
> +}
> +
> +/**
> + * i915_vma_create_persistent - create a persistent VMA
> + * @obj: parent &struct drm_i915_gem_object to be mapped
> + * @vm: address space in which the mapping is located
> + * @view: additional mapping requirements
> + *
> + * Creates a persistent vma.
> + *
> + * Returns the vma, or an error pointer.
> + */
> +struct i915_vma *
> +i915_vma_create_persistent(struct drm_i915_gem_object *obj,
> + struct i915_address_space *vm,
> + const struct i915_gtt_view *view)
> +{
> + struct i915_vma *vma;
> +
> + GEM_BUG_ON(!kref_read(&vm->ref));
> +
> + vma = vma_create(obj, vm, view, true);
> + if (!IS_ERR(vma))
> + i915_vma_set_persistent(vma);
>
> GEM_BUG_ON(!IS_ERR(vma) && i915_vma_compare(vma, vm, view));
> return vma;
> @@ -1666,7 +1698,8 @@ static void release_references(struct i915_vma *vma, struct intel_gt *gt,
>
> spin_lock(&obj->vma.lock);
> list_del(&vma->obj_link);
> - if (!RB_EMPTY_NODE(&vma->obj_node))
> + if (!i915_vma_is_persistent(vma) &&
Thinking out loud - maybe you don't need the extra condition? But it is
good for self-documenting purposes in any case.
> + !RB_EMPTY_NODE(&vma->obj_node))
> rb_erase(&vma->obj_node, &obj->vma.tree);
>
> spin_unlock(&obj->vma.lock);
> diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
> index aecd9c64486b..51e712de380a 100644
> --- a/drivers/gpu/drm/i915/i915_vma.h
> +++ b/drivers/gpu/drm/i915/i915_vma.h
> @@ -44,6 +44,10 @@ struct i915_vma *
> i915_vma_instance(struct drm_i915_gem_object *obj,
> struct i915_address_space *vm,
> const struct i915_gtt_view *view);
> +struct i915_vma *
> +i915_vma_create_persistent(struct drm_i915_gem_object *obj,
> + struct i915_address_space *vm,
> + const struct i915_gtt_view *view);
>
> void i915_vma_unpin_and_release(struct i915_vma **p_vma, unsigned int flags);
> #define I915_VMA_RELEASE_MAP BIT(0)
> @@ -138,6 +142,16 @@ static inline u32 i915_ggtt_pin_bias(struct i915_vma *vma)
> return i915_vm_to_ggtt(vma->vm)->pin_bias;
> }
>
> +static inline bool i915_vma_is_persistent(const struct i915_vma *vma)
> +{
> + return test_bit(I915_VMA_PERSISTENT_BIT, __i915_vma_flags(vma));
> +}
> +
> +static inline void i915_vma_set_persistent(struct i915_vma *vma)
> +{
> + set_bit(I915_VMA_PERSISTENT_BIT, __i915_vma_flags(vma));
> +}
> +
> static inline struct i915_vma *i915_vma_get(struct i915_vma *vma)
> {
> i915_gem_object_get(vma->obj);
> @@ -164,8 +178,6 @@ i915_vma_compare(struct i915_vma *vma,
> {
> ptrdiff_t cmp;
>
> - GEM_BUG_ON(view && !i915_is_ggtt_or_dpt(vm));
Or explicitly add persistent?
Regards,
Tvrtko
> -
> cmp = ptrdiff(vma->vm, vm);
> if (cmp)
> return cmp;
> diff --git a/drivers/gpu/drm/i915/i915_vma_types.h b/drivers/gpu/drm/i915/i915_vma_types.h
> index ec0f6c9f57d0..2200f1f103ba 100644
> --- a/drivers/gpu/drm/i915/i915_vma_types.h
> +++ b/drivers/gpu/drm/i915/i915_vma_types.h
> @@ -264,6 +264,13 @@ struct i915_vma {
> #define I915_VMA_SCANOUT_BIT 17
> #define I915_VMA_SCANOUT ((int)BIT(I915_VMA_SCANOUT_BIT))
>
> +/**
> + * I915_VMA_PERSISTENT_BIT:
> + * The vma is persistent (created with VM_BIND call).
> + */
> +#define I915_VMA_PERSISTENT_BIT 19
> +#define I915_VMA_PERSISTENT ((int)BIT(I915_VMA_PERSISTENT_BIT))
> +
> struct i915_active active;
>
> #define I915_VMA_PAGES_BIAS 24
next prev parent reply other threads:[~2022-09-28 7:38 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 6:19 [Intel-gfx] [PATCH 00/16] drm/i915/vm_bind: Add VM_BIND functionality Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 01/16] drm/i915/vm_bind: Expose vm lookup function Niranjana Vishwanathapura
2022-09-28 17:28 ` Matthew Auld
2022-09-28 6:19 ` [Intel-gfx] [PATCH 02/16] drm/i915/vm_bind: Add __i915_sw_fence_await_reservation() Niranjana Vishwanathapura
2022-09-28 17:39 ` Matthew Auld
2022-09-29 5:20 ` Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 03/16] drm/i915/vm_bind: Expose i915_gem_object_max_page_size() Niranjana Vishwanathapura
2022-09-28 17:40 ` Matthew Auld
2022-09-29 5:20 ` Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 04/16] drm/i915/vm_bind: Add support to create persistent vma Niranjana Vishwanathapura
2022-09-28 7:38 ` Tvrtko Ursulin [this message]
2022-09-28 17:05 ` Niranjana Vishwanathapura
2022-09-28 14:44 ` Andi Shyti
2022-09-28 17:07 ` Niranjana Vishwanathapura
2022-09-29 17:04 ` Matthew Auld
2022-09-28 6:19 ` [Intel-gfx] [PATCH 05/16] drm/i915/vm_bind: Implement bind and unbind of object Niranjana Vishwanathapura
2022-09-28 9:43 ` kernel test robot
2022-09-28 17:52 ` Matthew Auld
2022-09-29 5:24 ` Niranjana Vishwanathapura
2022-09-29 9:03 ` Matthew Auld
2022-09-29 10:51 ` Matthew Auld
2022-09-29 14:24 ` Niranjana Vishwanathapura
2022-09-28 20:06 ` Welty, Brian
2022-09-29 5:25 ` Niranjana Vishwanathapura
2022-09-29 10:49 ` Matthew Auld
2022-09-29 16:38 ` Niranjana Vishwanathapura
2022-09-29 17:28 ` Matthew Auld
2022-09-29 17:49 ` Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 06/16] drm/i915/vm_bind: Support for VM private BOs Niranjana Vishwanathapura
2022-09-28 17:54 ` Matthew Auld
2022-09-29 14:28 ` Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 07/16] drm/i915/vm_bind: Add support to handle object evictions Niranjana Vishwanathapura
2022-09-29 17:13 ` Matthew Auld
2022-09-28 6:19 ` [Intel-gfx] [PATCH 08/16] drm/i915/vm_bind: Support persistent vma activeness tracking Niranjana Vishwanathapura
2022-09-30 12:00 ` Andi Shyti
2022-09-28 6:19 ` [Intel-gfx] [PATCH 09/16] drm/i915/vm_bind: Add out fence support Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 10/16] drm/i915/vm_bind: Abstract out common execbuf functions Niranjana Vishwanathapura
2022-09-30 10:45 ` Matthew Auld
2022-09-30 16:26 ` Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 11/16] drm/i915/vm_bind: Use common execbuf functions in execbuf path Niranjana Vishwanathapura
2022-09-30 10:47 ` Matthew Auld
2022-09-28 6:19 ` [Intel-gfx] [PATCH 12/16] drm/i915/vm_bind: Implement I915_GEM_EXECBUFFER3 ioctl Niranjana Vishwanathapura
2022-09-29 15:00 ` Matthew Auld
2022-09-29 16:02 ` Niranjana Vishwanathapura
2022-10-03 21:12 ` Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 13/16] drm/i915/vm_bind: Update i915_vma_verify_bind_complete() Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 14/16] drm/i915/vm_bind: Handle persistent vmas in execbuf3 Niranjana Vishwanathapura
2022-09-30 9:47 ` Matthew Auld
2022-10-02 6:28 ` Niranjana Vishwanathapura
2022-10-03 8:36 ` Matthew Auld
2022-10-05 5:38 ` Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 15/16] drm/i915/vm_bind: userptr dma-resv changes Niranjana Vishwanathapura
2022-09-28 6:19 ` [Intel-gfx] [PATCH 16/16] drm/i915/vm_bind: Add uapi for user to enable vm_bind_mode Niranjana Vishwanathapura
2022-09-30 10:01 ` Matthew Auld
2022-09-30 16:13 ` Niranjana Vishwanathapura
2022-09-28 13:34 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/vm_bind: Add VM_BIND functionality (rev4) Patchwork
2022-09-28 13:34 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-09-28 13:57 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
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=7e4e626d-4f7f-f802-693f-07ded7673c35@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=matthew.auld@intel.com \
--cc=niranjana.vishwanathapura@intel.com \
--cc=paulo.r.zanoni@intel.com \
--cc=thomas.hellstrom@intel.com \
/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