From: Luben Tuikov <luben.tuikov@amd.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: "Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH 08/13] drm/amdgpu: use scheduler depenencies for VM updates
Date: Mon, 24 Oct 2022 01:50:44 -0400 [thread overview]
Message-ID: <200e5ee6-52e4-e3eb-6ac3-74134b60ee0c@amd.com> (raw)
In-Reply-To: <20221014084641.128280-9-christian.koenig@amd.com>
"dependencies" in the title.
The rest looks good. I like pulling that sync free code into its own function.
Regards,
Luben
On 2022-10-14 04:46, Christian König wrote:
> Instead of putting that into the job sync object.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 56 +++++++++++++++------
> drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h | 2 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 10 +++-
> 3 files changed, 52 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> index 090e66a1b284..bac7976975bd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> @@ -259,6 +259,14 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct amdgpu_sync *sync,
> return 0;
> }
>
> +/* Free the entry back to the slab */
> +static void amdgpu_sync_entry_free(struct amdgpu_sync_entry *e)
> +{
> + hash_del(&e->node);
> + dma_fence_put(e->fence);
> + kmem_cache_free(amdgpu_sync_slab, e);
> +}
> +
> /**
> * amdgpu_sync_peek_fence - get the next fence not signaled yet
> *
> @@ -280,9 +288,7 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
> struct drm_sched_fence *s_fence = to_drm_sched_fence(f);
>
> if (dma_fence_is_signaled(f)) {
> - hash_del(&e->node);
> - dma_fence_put(f);
> - kmem_cache_free(amdgpu_sync_slab, e);
> + amdgpu_sync_entry_free(e);
> continue;
> }
> if (ring && s_fence) {
> @@ -355,15 +361,42 @@ int amdgpu_sync_clone(struct amdgpu_sync *source, struct amdgpu_sync *clone)
> if (r)
> return r;
> } else {
> - hash_del(&e->node);
> - dma_fence_put(f);
> - kmem_cache_free(amdgpu_sync_slab, e);
> + amdgpu_sync_entry_free(e);
> }
> }
>
> return 0;
> }
>
> +/**
> + * amdgpu_sync_push_to_job - push fences into job
> + * @sync: sync object to get the fences from
> + * @job: job to push the fences into
> + *
> + * Add all unsignaled fences from sync to job.
> + */
> +int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job)
> +{
> + struct amdgpu_sync_entry *e;
> + struct hlist_node *tmp;
> + struct dma_fence *f;
> + int i, r;
> +
> + hash_for_each_safe(sync->fences, i, tmp, e, node) {
> + f = e->fence;
> + if (dma_fence_is_signaled(f)) {
> + amdgpu_sync_entry_free(e);
> + continue;
> + }
> +
> + dma_fence_get(f);
> + r = drm_sched_job_add_dependency(&job->base, f);
> + if (r)
> + return r;
> + }
> + return 0;
> +}
> +
> int amdgpu_sync_wait(struct amdgpu_sync *sync, bool intr)
> {
> struct amdgpu_sync_entry *e;
> @@ -375,9 +408,7 @@ int amdgpu_sync_wait(struct amdgpu_sync *sync, bool intr)
> if (r)
> return r;
>
> - hash_del(&e->node);
> - dma_fence_put(e->fence);
> - kmem_cache_free(amdgpu_sync_slab, e);
> + amdgpu_sync_entry_free(e);
> }
>
> return 0;
> @@ -396,11 +427,8 @@ void amdgpu_sync_free(struct amdgpu_sync *sync)
> struct hlist_node *tmp;
> unsigned int i;
>
> - hash_for_each_safe(sync->fences, i, tmp, e, node) {
> - hash_del(&e->node);
> - dma_fence_put(e->fence);
> - kmem_cache_free(amdgpu_sync_slab, e);
> - }
> + hash_for_each_safe(sync->fences, i, tmp, e, node)
> + amdgpu_sync_entry_free(e);
> }
>
> /**
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h
> index 2d5c613cda10..cf1e9e858efd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h
> @@ -30,6 +30,7 @@ struct dma_fence;
> struct dma_resv;
> struct amdgpu_device;
> struct amdgpu_ring;
> +struct amdgpu_job;
>
> enum amdgpu_sync_mode {
> AMDGPU_SYNC_ALWAYS,
> @@ -54,6 +55,7 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
> struct amdgpu_ring *ring);
> struct dma_fence *amdgpu_sync_get_fence(struct amdgpu_sync *sync);
> int amdgpu_sync_clone(struct amdgpu_sync *source, struct amdgpu_sync *clone);
> +int amdgpu_sync_push_to_job(struct amdgpu_sync *sync, struct amdgpu_job *job);
> int amdgpu_sync_wait(struct amdgpu_sync *sync, bool intr);
> void amdgpu_sync_free(struct amdgpu_sync *sync);
> int amdgpu_sync_init(void);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
> index 126364882d09..59cf64216fbb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
> @@ -87,6 +87,7 @@ static int amdgpu_vm_sdma_prepare(struct amdgpu_vm_update_params *p,
> struct dma_resv *resv,
> enum amdgpu_sync_mode sync_mode)
> {
> + struct amdgpu_sync sync;
> int r;
>
> r = amdgpu_vm_sdma_alloc_job(p, 0);
> @@ -96,7 +97,12 @@ static int amdgpu_vm_sdma_prepare(struct amdgpu_vm_update_params *p,
> if (!resv)
> return 0;
>
> - return amdgpu_sync_resv(p->adev, &p->job->sync, resv, sync_mode, p->vm);
> + amdgpu_sync_create(&sync);
> + r = amdgpu_sync_resv(p->adev, &sync, resv, sync_mode, p->vm);
> + if (!r)
> + r = amdgpu_sync_push_to_job(&sync, p->job);
> + amdgpu_sync_free(&sync);
> + return r;
> }
>
> /**
> @@ -232,7 +238,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
> /* Wait for PD/PT moves to be completed */
> dma_resv_iter_begin(&cursor, bo->tbo.base.resv, DMA_RESV_USAGE_KERNEL);
> dma_resv_for_each_fence_unlocked(&cursor, fence) {
> - r = amdgpu_sync_fence(&p->job->sync, fence);
> + r = drm_sched_job_add_dependency(&p->job->base, fence);
> if (r) {
> dma_resv_iter_end(&cursor);
> return r;
next prev parent reply other threads:[~2022-10-24 5:50 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 8:46 Fixes for scheduler hang when killing a process Christian König
2022-10-14 8:46 ` [PATCH 01/13] drm/scheduler: fix fence ref counting Christian König
2022-10-25 3:23 ` Luna Nova
2022-10-25 11:35 ` Christian König
2022-10-14 8:46 ` [PATCH 02/13] drm/scheduler: add drm_sched_job_add_resv_dependencies Christian König
2022-10-14 8:46 ` [PATCH 03/13] drm/amdgpu: use drm_sched_job_add_resv_dependencies for moves Christian König
2022-10-14 8:46 ` [PATCH 04/13] drm/amdgpu: drop the fence argument from amdgpu_vmid_grab Christian König
2022-10-14 8:46 ` [PATCH 05/13] drm/amdgpu: drop amdgpu_sync " Christian König
2022-10-23 1:25 ` Luben Tuikov
2022-10-24 10:54 ` Christian König
2022-10-14 8:46 ` [PATCH 06/13] drm/amdgpu: cleanup scheduler job initialization Christian König
2022-10-23 1:50 ` Luben Tuikov
2022-10-14 8:46 ` [PATCH 07/13] drm/amdgpu: move explicit sync check into the CS Christian König
2022-10-14 8:46 ` [PATCH 08/13] drm/amdgpu: use scheduler depenencies for VM updates Christian König
2022-10-24 5:50 ` Luben Tuikov [this message]
2022-10-14 8:46 ` [PATCH 09/13] drm/amdgpu: use scheduler depenencies for UVD msgs Christian König
2022-10-24 5:53 ` Luben Tuikov
2022-10-14 8:46 ` [PATCH 10/13] drm/amdgpu: use scheduler depenencies for CS Christian König
2022-10-24 5:55 ` Luben Tuikov
2022-12-21 15:34 ` Mike Lothian
2022-12-21 15:47 ` Mike Lothian
2022-12-21 15:52 ` Luben Tuikov
2022-12-21 15:55 ` Mike Lothian
2022-10-14 8:46 ` [PATCH 11/13] drm/scheduler: remove drm_sched_dependency_optimized Christian König
2022-10-14 8:46 ` [PATCH 12/13] drm/scheduler: rework entity flush, kill and fini Christian König
2022-11-17 2:36 ` Dmitry Osipenko
2022-11-17 9:53 ` Christian König
2022-11-17 12:47 ` Dmitry Osipenko
2022-11-17 12:55 ` Christian König
2022-11-17 12:59 ` Dmitry Osipenko
2022-11-17 13:00 ` Dmitry Osipenko
2022-11-17 13:11 ` Christian König
2022-11-17 14:41 ` Dmitry Osipenko
2022-11-17 15:09 ` Christian König
2022-11-17 15:11 ` Dmitry Osipenko
2022-12-28 16:27 ` Rob Clark
2022-12-28 16:52 ` Rob Clark
2023-01-01 18:29 ` youling257
2023-01-02 9:24 ` Dmitry Osipenko
2023-01-02 14:17 ` youling 257
2023-01-02 15:08 ` Dmitry Osipenko
2022-10-14 8:46 ` [PATCH 13/13] drm/scheduler: rename dependency callback into prepare_job Christian König
2022-10-23 1:35 ` Fixes for scheduler hang when killing a process Luben Tuikov
2022-10-24 7:00 ` Luben Tuikov
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=200e5ee6-52e4-e3eb-6ac3-74134b60ee0c@amd.com \
--to=luben.tuikov@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@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