diff options
author | 2022-02-23 14:35:31 +0100 | |
---|---|---|
committer | 2022-03-04 13:03:30 -0500 | |
commit | d18b8eadd83e3d8d63a45f9479478640dbcfca02 (patch) | |
tree | 8f2a8ce9b4f32f9a0ad8d60cdd4d0f206eaf35c1 | |
parent | drm/amdkfd: implement get_atc_vmid_pasid_mapping_info for gfx10.3 (diff) | |
download | wireguard-linux-d18b8eadd83e3d8d63a45f9479478640dbcfca02.tar.xz wireguard-linux-d18b8eadd83e3d8d63a45f9479478640dbcfca02.zip |
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@amd.com>
Fixes: 461fa7b0ac565e ("drm/amdgpu: remove ctx->lock")
Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 2d2dceab4c39..5981c7d9bd48 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -205,9 +205,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); |