[PATCH] drm/amdgpu: install ctx entities with cmpxchg

Christian König ckoenig.leichtzumerken at gmail.com
Wed Feb 23 15:20:28 UTC 2022


No, as I wrote in the comment that is not an error and should just be 
ignored.

Regards,
Christian.

Am 23.02.22 um 16:18 schrieb Chen, Guchun:
>
> [Public]
>
>
> Shall we add a print to aware user when failing to install a new ctx 
> entity?
>
> Regards,
>
> Guchun
>
> *From:* amd-gfx <amd-gfx-bounces at lists.freedesktop.org> *On Behalf Of 
> *Deucher, Alexander
> *Sent:* Wednesday, February 23, 2022 11:06 PM
> *To:* Christian König <ckoenig.leichtzumerken at gmail.com>; 
> amd-gfx at lists.freedesktop.org
> *Cc:* Koenig, Christian <Christian.Koenig at amd.com>; Xue, Ken 
> <Ken.Xue at amd.com>
> *Subject:* Re: [PATCH] drm/amdgpu: install ctx entities with cmpxchg
>
> [Public]
>
> [Public]
>
> Acked-by: Alex Deucher <alexander.deucher at amd.com>
>
> ------------------------------------------------------------------------
>
> *From:*amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of 
> Christian König <ckoenig.leichtzumerken at gmail.com>
> *Sent:* Wednesday, February 23, 2022 8:38 AM
> *To:* amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
> *Cc:* Koenig, Christian <Christian.Koenig at amd.com>; Xue, Ken 
> <Ken.Xue at amd.com>
> *Subject:* [PATCH] drm/amdgpu: install ctx entities with cmpxchg
>
> Since we removed the context lock we need to make sure that not two 
> threads
> are trying to install an entity at the same time.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
> Fixes: e68efb27647f ("drm/amdgpu: remove ctx->lock")
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index f522b52725e4..16eb1ee600ed 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -204,9 +204,15 @@ static int amdgpu_ctx_init_entity(struct 
> amdgpu_ctx *ctx, u32 hw_ip,
>          if (r)
>                  goto error_free_entity;
>
> -       ctx->entities[hw_ip][ring] = entity;
> +       /* It's not an error if we fail to install the new entity */
> +       if (cmpxchg(&ctx->entities[hw_ip][ring], NULL, entity))
> +               goto cleanup_entity;
> +
>          return 0;
>
> +cleanup_entity:
> + drm_sched_entity_fini(&entity->entity);
> +
>  error_free_entity:
>          kfree(entity);
>
> -- 
> 2.25.1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20220223/4b62da1f/attachment-0001.htm>


More information about the amd-gfx mailing list