Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: move VM manager clean into the VM code again

It's not a good idea to duplicate that code.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <davdi1.zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
ea89f8c9 8b4fb00b

+20 -12
+1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 972 972 struct amdgpu_ring *vm_pte_funcs_ring; 973 973 }; 974 974 975 + void amdgpu_vm_manager_fini(struct amdgpu_device *adev); 975 976 int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm); 976 977 void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm); 977 978 struct amdgpu_bo_list_entry *amdgpu_vm_get_bos(struct amdgpu_device *adev,
+15
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 1318 1318 1319 1319 mutex_destroy(&vm->mutex); 1320 1320 } 1321 + 1322 + /** 1323 + * amdgpu_vm_manager_fini - cleanup VM manager 1324 + * 1325 + * @adev: amdgpu_device pointer 1326 + * 1327 + * Cleanup the VM manager and free resources. 1328 + */ 1329 + void amdgpu_vm_manager_fini(struct amdgpu_device *adev) 1330 + { 1331 + unsigned i; 1332 + 1333 + for (i = 0; i < AMDGPU_NUM_VM; ++i) 1334 + fence_put(adev->vm_manager.active[i]); 1335 + }
+2 -6
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
··· 961 961 962 962 static int gmc_v7_0_sw_fini(void *handle) 963 963 { 964 - int i; 965 964 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 966 965 967 966 if (adev->vm_manager.enabled) { 968 - for (i = 0; i < AMDGPU_NUM_VM; ++i) 969 - fence_put(adev->vm_manager.active[i]); 967 + amdgpu_vm_manager_fini(adev); 970 968 gmc_v7_0_vm_fini(adev); 971 969 adev->vm_manager.enabled = false; 972 970 } ··· 1009 1011 1010 1012 static int gmc_v7_0_suspend(void *handle) 1011 1013 { 1012 - int i; 1013 1014 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1014 1015 1015 1016 if (adev->vm_manager.enabled) { 1016 - for (i = 0; i < AMDGPU_NUM_VM; ++i) 1017 - fence_put(adev->vm_manager.active[i]); 1017 + amdgpu_vm_manager_fini(adev); 1018 1018 gmc_v7_0_vm_fini(adev); 1019 1019 adev->vm_manager.enabled = false; 1020 1020 }
+2 -6
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
··· 980 980 981 981 static int gmc_v8_0_sw_fini(void *handle) 982 982 { 983 - int i; 984 983 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 985 984 986 985 if (adev->vm_manager.enabled) { 987 - for (i = 0; i < AMDGPU_NUM_VM; ++i) 988 - fence_put(adev->vm_manager.active[i]); 986 + amdgpu_vm_manager_fini(adev); 989 987 gmc_v8_0_vm_fini(adev); 990 988 adev->vm_manager.enabled = false; 991 989 } ··· 1030 1032 1031 1033 static int gmc_v8_0_suspend(void *handle) 1032 1034 { 1033 - int i; 1034 1035 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1035 1036 1036 1037 if (adev->vm_manager.enabled) { 1037 - for (i = 0; i < AMDGPU_NUM_VM; ++i) 1038 - fence_put(adev->vm_manager.active[i]); 1038 + amdgpu_vm_manager_fini(adev); 1039 1039 gmc_v8_0_vm_fini(adev); 1040 1040 adev->vm_manager.enabled = false; 1041 1041 }