diff options
author | Jack Xiao <Jack.Xiao@amd.com> | 2022-03-24 11:35:29 +0800 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2022-05-04 10:43:51 -0400 |
commit | b0306e584004b20d406d8111cb8922b7bb8d8840 (patch) | |
tree | b6d91014d480e78f9707af79e38d829c06e602cc /drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | |
parent | 5d0f619f723d0caa909e99c875a0c813588a0d68 (diff) | |
download | linux-b0306e584004b20d406d8111cb8922b7bb8d8840.tar.bz2 |
drm/amdgpu/mes: implement removing mes gang
Free the mes gang and its resources.
Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c index 74385e4b45c4..07ddf7bf6a3b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c @@ -416,3 +416,33 @@ clean_up: mutex_unlock(&adev->mes.mutex); return r; } + +int amdgpu_mes_remove_gang(struct amdgpu_device *adev, int gang_id) +{ + struct amdgpu_mes_gang *gang; + + mutex_lock(&adev->mes.mutex); + + gang = idr_find(&adev->mes.gang_id_idr, gang_id); + if (!gang) { + DRM_ERROR("gang id %d doesn't exist\n", gang_id); + mutex_unlock(&adev->mes.mutex); + return -EINVAL; + } + + if (!list_empty(&gang->queue_list)) { + DRM_ERROR("queue list is not empty\n"); + mutex_unlock(&adev->mes.mutex); + return -EBUSY; + } + + idr_remove(&adev->mes.gang_id_idr, gang->gang_id); + amdgpu_bo_free_kernel(&gang->gang_ctx_bo, + &gang->gang_ctx_gpu_addr, + &gang->gang_ctx_cpu_ptr); + list_del(&gang->list); + kfree(gang); + + mutex_unlock(&adev->mes.mutex); + return 0; +} |