From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 07/19] drm/i915: vma is always backed by an object.
Date: Tue, 31 Aug 2021 10:18:33 +0100 [thread overview]
Message-ID: <80c12456-e409-2455-2f47-bb999468d271@linux.intel.com> (raw)
In-Reply-To: <20210830121006.2978297-8-maarten.lankhorst@linux.intel.com>
On 30/08/2021 13:09, Maarten Lankhorst wrote:
> vma->obj and vma->resv are now never NULL, and some checks can be removed.
Is the direction here compatible with SVM / VM_BIND?
Regards,
Tvrtko
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gt/intel_context.c | 2 +-
> .../gpu/drm/i915/gt/intel_ring_submission.c | 2 +-
> drivers/gpu/drm/i915/i915_vma.c | 48 ++++++++-----------
> drivers/gpu/drm/i915/i915_vma.h | 3 --
> 4 files changed, 22 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
> index 745e84c72c90..d3ad16df3ca2 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context.c
> +++ b/drivers/gpu/drm/i915/gt/intel_context.c
> @@ -219,7 +219,7 @@ int __intel_context_do_pin_ww(struct intel_context *ce,
> */
>
> err = i915_gem_object_lock(ce->timeline->hwsp_ggtt->obj, ww);
> - if (!err && ce->ring->vma->obj)
> + if (!err)
> err = i915_gem_object_lock(ce->ring->vma->obj, ww);
> if (!err && ce->state)
> err = i915_gem_object_lock(ce->state->obj, ww);
> diff --git a/drivers/gpu/drm/i915/gt/intel_ring_submission.c b/drivers/gpu/drm/i915/gt/intel_ring_submission.c
> index 3c65efcb7bed..cc31ccc13bfb 100644
> --- a/drivers/gpu/drm/i915/gt/intel_ring_submission.c
> +++ b/drivers/gpu/drm/i915/gt/intel_ring_submission.c
> @@ -1354,7 +1354,7 @@ int intel_ring_submission_setup(struct intel_engine_cs *engine)
> err = i915_gem_object_lock(timeline->hwsp_ggtt->obj, &ww);
> if (!err && gen7_wa_vma)
> err = i915_gem_object_lock(gen7_wa_vma->obj, &ww);
> - if (!err && engine->legacy.ring->vma->obj)
> + if (!err)
> err = i915_gem_object_lock(engine->legacy.ring->vma->obj, &ww);
> if (!err)
> err = intel_timeline_pin(timeline, &ww);
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index f9ac33e0bac9..ad5d52b33eb6 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -40,12 +40,12 @@
>
> static struct kmem_cache *slab_vmas;
>
> -struct i915_vma *i915_vma_alloc(void)
> +static struct i915_vma *i915_vma_alloc(void)
> {
> return kmem_cache_zalloc(slab_vmas, GFP_KERNEL);
> }
>
> -void i915_vma_free(struct i915_vma *vma)
> +static void i915_vma_free(struct i915_vma *vma)
> {
> return kmem_cache_free(slab_vmas, vma);
> }
> @@ -426,10 +426,8 @@ int i915_vma_bind(struct i915_vma *vma,
>
> work->base.dma.error = 0; /* enable the queue_work() */
>
> - if (vma->obj) {
> - __i915_gem_object_pin_pages(vma->obj);
> - work->pinned = i915_gem_object_get(vma->obj);
> - }
> + __i915_gem_object_pin_pages(vma->obj);
> + work->pinned = i915_gem_object_get(vma->obj);
> } else {
> vma->ops->bind_vma(vma->vm, NULL, vma, cache_level, bind_flags);
> }
> @@ -670,7 +668,7 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
> }
>
> color = 0;
> - if (vma->obj && i915_vm_has_cache_coloring(vma->vm))
> + if (i915_vm_has_cache_coloring(vma->vm))
> color = vma->obj->cache_level;
>
> if (flags & PIN_OFFSET_FIXED) {
> @@ -795,17 +793,14 @@ static bool try_qad_pin(struct i915_vma *vma, unsigned int flags)
> static int vma_get_pages(struct i915_vma *vma)
> {
> int err = 0;
> - bool pinned_pages = false;
> + bool pinned_pages = true;
>
> if (atomic_add_unless(&vma->pages_count, 1, 0))
> return 0;
>
> - if (vma->obj) {
> - err = i915_gem_object_pin_pages(vma->obj);
> - if (err)
> - return err;
> - pinned_pages = true;
> - }
> + err = i915_gem_object_pin_pages(vma->obj);
> + if (err)
> + return err;
>
> /* Allocations ahoy! */
> if (mutex_lock_interruptible(&vma->pages_mutex)) {
> @@ -838,8 +833,8 @@ static void __vma_put_pages(struct i915_vma *vma, unsigned int count)
> if (atomic_sub_return(count, &vma->pages_count) == 0) {
> vma->ops->clear_pages(vma);
> GEM_BUG_ON(vma->pages);
> - if (vma->obj)
> - i915_gem_object_unpin_pages(vma->obj);
> +
> + i915_gem_object_unpin_pages(vma->obj);
> }
> mutex_unlock(&vma->pages_mutex);
> }
> @@ -875,7 +870,7 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
> int err;
>
> #ifdef CONFIG_PROVE_LOCKING
> - if (debug_locks && !WARN_ON(!ww) && vma->resv)
> + if (debug_locks && !WARN_ON(!ww))
> assert_vma_held(vma);
> #endif
>
> @@ -983,7 +978,7 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
>
> GEM_BUG_ON(!vma->pages);
> err = i915_vma_bind(vma,
> - vma->obj ? vma->obj->cache_level : 0,
> + vma->obj->cache_level,
> flags, work);
> if (err)
> goto err_remove;
> @@ -1037,7 +1032,7 @@ int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
> GEM_BUG_ON(!i915_vma_is_ggtt(vma));
>
> #ifdef CONFIG_LOCKDEP
> - WARN_ON(!ww && vma->resv && dma_resv_held(vma->resv));
> + WARN_ON(!ww && dma_resv_held(vma->resv));
> #endif
>
> do {
> @@ -1116,6 +1111,7 @@ void i915_vma_reopen(struct i915_vma *vma)
> void i915_vma_release(struct kref *ref)
> {
> struct i915_vma *vma = container_of(ref, typeof(*vma), ref);
> + struct drm_i915_gem_object *obj = vma->obj;
>
> if (drm_mm_node_allocated(&vma->node)) {
> mutex_lock(&vma->vm->mutex);
> @@ -1126,15 +1122,11 @@ void i915_vma_release(struct kref *ref)
> }
> GEM_BUG_ON(i915_vma_is_active(vma));
>
> - if (vma->obj) {
> - struct drm_i915_gem_object *obj = vma->obj;
> -
> - spin_lock(&obj->vma.lock);
> - list_del(&vma->obj_link);
> - if (!RB_EMPTY_NODE(&vma->obj_node))
> - rb_erase(&vma->obj_node, &obj->vma.tree);
> - spin_unlock(&obj->vma.lock);
> - }
> + spin_lock(&obj->vma.lock);
> + list_del(&vma->obj_link);
> + if (!RB_EMPTY_NODE(&vma->obj_node))
> + rb_erase(&vma->obj_node, &obj->vma.tree);
> + spin_unlock(&obj->vma.lock);
>
> __i915_vma_remove_closed(vma);
> i915_vm_put(vma->vm);
> diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
> index 1c930515ec3d..1ba82bf863a5 100644
> --- a/drivers/gpu/drm/i915/i915_vma.h
> +++ b/drivers/gpu/drm/i915/i915_vma.h
> @@ -409,9 +409,6 @@ static inline void i915_vma_clear_scanout(struct i915_vma *vma)
> list_for_each_entry(V, &(OBJ)->vma.list, obj_link) \
> for_each_until(!i915_vma_is_ggtt(V))
>
> -struct i915_vma *i915_vma_alloc(void);
> -void i915_vma_free(struct i915_vma *vma);
> -
> struct i915_vma *i915_vma_make_unshrinkable(struct i915_vma *vma);
> void i915_vma_make_shrinkable(struct i915_vma *vma);
> void i915_vma_make_purgeable(struct i915_vma *vma);
>
next prev parent reply other threads:[~2021-08-31 9:18 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 12:09 [Intel-gfx] [PATCH 00/19] drm/i915: Short-term pinning and async eviction Maarten Lankhorst
2021-08-30 12:09 ` [Intel-gfx] [PATCH 01/19] drm/i915: Move __i915_gem_free_object to ttm_bo_destroy Maarten Lankhorst
2021-09-16 9:43 ` Thomas Hellström (Intel)
2021-09-16 13:35 ` Maarten Lankhorst
2021-08-30 12:09 ` [Intel-gfx] [PATCH 02/19] drm/i915: Remove unused bits of i915_vma/active api Maarten Lankhorst
2021-09-08 1:37 ` Niranjana Vishwanathapura
2021-08-30 12:09 ` [Intel-gfx] [PATCH 03/19] drm/i915: Slightly rework EXEC_OBJECT_CAPTURE handling Maarten Lankhorst
2021-09-08 1:49 ` Niranjana Vishwanathapura
2021-08-30 12:09 ` [Intel-gfx] [PATCH 04/19] drm/i915: Remove gen6_ppgtt_unpin_all Maarten Lankhorst
2021-09-29 8:07 ` Matthew Auld
2021-08-30 12:09 ` [Intel-gfx] [PATCH 05/19] drm/i915: Create a dummy object for gen6 ppgtt Maarten Lankhorst
2021-08-30 12:09 ` [Intel-gfx] [PATCH 06/19] drm/i915: Create a full object for mock_ring Maarten Lankhorst
2021-08-30 12:09 ` [Intel-gfx] [PATCH 07/19] drm/i915: vma is always backed by an object Maarten Lankhorst
2021-08-31 9:18 ` Tvrtko Ursulin [this message]
2021-08-31 9:34 ` Maarten Lankhorst
2021-08-31 10:29 ` Tvrtko Ursulin
2021-09-03 9:31 ` Maarten Lankhorst
2021-09-03 10:48 ` Tvrtko Ursulin
2021-09-16 13:41 ` Maarten Lankhorst
2021-09-16 14:30 ` Tvrtko Ursulin
2021-09-16 15:05 ` Tvrtko Ursulin
2021-08-30 12:09 ` [Intel-gfx] [PATCH 08/19] drm/i915: Fix runtime pm handling in i915_gem_shrink Maarten Lankhorst
2021-09-08 1:12 ` Niranjana Vishwanathapura
2021-09-29 8:37 ` Matthew Auld
2021-09-29 8:40 ` Matthew Auld
2021-09-29 8:53 ` Maarten Lankhorst
2021-08-30 12:09 ` [Intel-gfx] [PATCH 09/19] drm/i915: Change shrink ordering to use locking around unbinding Maarten Lankhorst
2021-09-08 1:04 ` Niranjana Vishwanathapura
2021-08-30 12:09 ` [Intel-gfx] [PATCH 10/19] Move CONTEXT_VALID_BIT check Maarten Lankhorst
2021-09-08 19:45 ` Niranjana Vishwanathapura
2021-08-30 12:09 ` [Intel-gfx] [PATCH 11/19] drm/i915: Remove resv from i915_vma Maarten Lankhorst
2021-09-08 1:10 ` Niranjana Vishwanathapura
2021-08-30 12:09 ` [Intel-gfx] [PATCH 12/19] drm/i915: Remove pages_mutex and intel_gtt->vma_ops.set/clear_pages members Maarten Lankhorst
2021-08-30 12:10 ` [Intel-gfx] [PATCH 13/19] drm/i915: Take object lock in i915_ggtt_pin if ww is not set Maarten Lankhorst
2021-09-08 3:11 ` Niranjana Vishwanathapura
2021-09-16 13:54 ` Maarten Lankhorst
2021-08-30 12:10 ` [Intel-gfx] [PATCH 14/19] drm/i915: Add i915_vma_unbind_unlocked, and take obj lock for i915_vma_unbind Maarten Lankhorst
2021-09-03 9:33 ` Maarten Lankhorst
2021-08-30 12:10 ` [Intel-gfx] [PATCH 15/19] drm/i915: Remove support for unlocked i915_vma unbind Maarten Lankhorst
2021-09-08 3:35 ` Niranjana Vishwanathapura
2021-08-30 12:10 ` [Intel-gfx] [PATCH 16/19] drm/i915: Remove short-term pins from execbuf Maarten Lankhorst
2021-08-30 12:10 ` [Intel-gfx] [PATCH 17/19] drm/i915: Add functions to set/get moving fence Maarten Lankhorst
2021-09-08 4:08 ` Niranjana Vishwanathapura
2021-09-16 13:49 ` Maarten Lankhorst
2021-09-16 9:48 ` Thomas Hellström
2021-08-30 12:10 ` [Intel-gfx] [PATCH 18/19] drm/i915: Add support for asynchronous moving fence waiting Maarten Lankhorst
2021-09-16 10:01 ` Thomas Hellström (Intel)
2021-08-30 12:10 ` [Intel-gfx] [PATCH 19/19] drm/i915: Add accelerated migration to ttm Maarten Lankhorst
2021-09-16 11:19 ` Thomas Hellström (Intel)
2021-08-30 13:03 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Short-term pinning and async eviction Patchwork
2021-08-30 13:05 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-08-30 13:32 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-09-16 9:40 ` [Intel-gfx] [PATCH 00/19] " Thomas Hellström (Intel)
2021-09-16 11:24 ` Maarten Lankhorst
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=80c12456-e409-2455-2f47-bb999468d271@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.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