Commit d18b8ead authored by Christian König's avatar Christian König Committed by Alex Deucher
Browse files

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: default avatarChristian König <christian.koenig@amd.com>
Fixes: 461fa7b0 ("drm/amdgpu: remove ctx->lock")
Reviewed-by: default avatarAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent b664a56e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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);