aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2017-03-13 05:13:36 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-03-29 23:53:59 -0400
commit4388fc2ab0e83fd6247c48c7e97064cc75511848 (patch)
treeaaed2442332d9ecfe63488799b40db40184405db /drivers
parentd319c2bcc6b5d716e10f5cb3efe0adf43d3b06ed (diff)
drm/amdgpu: make set_prt callback optional and fix error handling
PRT support is completely implemented now and we left it turned on accidentially in the error path. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index a45de6e6a0f7..f9f4e2055084 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1194,10 +1194,13 @@ static void amdgpu_vm_update_prt_state(struct amdgpu_device *adev)
1194} 1194}
1195 1195
1196/** 1196/**
1197 * amdgpu_vm_prt_put - add a PRT user 1197 * amdgpu_vm_prt_get - add a PRT user
1198 */ 1198 */
1199static void amdgpu_vm_prt_get(struct amdgpu_device *adev) 1199static void amdgpu_vm_prt_get(struct amdgpu_device *adev)
1200{ 1200{
1201 if (!adev->gart.gart_funcs->set_prt)
1202 return;
1203
1201 if (atomic_inc_return(&adev->vm_manager.num_prt_users) == 1) 1204 if (atomic_inc_return(&adev->vm_manager.num_prt_users) == 1)
1202 amdgpu_vm_update_prt_state(adev); 1205 amdgpu_vm_update_prt_state(adev);
1203} 1206}
@@ -1228,9 +1231,12 @@ static void amdgpu_vm_prt_cb(struct dma_fence *fence, struct dma_fence_cb *_cb)
1228static void amdgpu_vm_add_prt_cb(struct amdgpu_device *adev, 1231static void amdgpu_vm_add_prt_cb(struct amdgpu_device *adev,
1229 struct dma_fence *fence) 1232 struct dma_fence *fence)
1230{ 1233{
1231 struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct amdgpu_prt_cb), 1234 struct amdgpu_prt_cb *cb;
1232 GFP_KERNEL);
1233 1235
1236 if (!adev->gart.gart_funcs->set_prt)
1237 return;
1238
1239 cb = kmalloc(sizeof(struct amdgpu_prt_cb), GFP_KERNEL);
1234 if (!cb) { 1240 if (!cb) {
1235 /* Last resort when we are OOM */ 1241 /* Last resort when we are OOM */
1236 if (fence) 1242 if (fence)
@@ -1445,14 +1451,6 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
1445 size == 0 || size & AMDGPU_GPU_PAGE_MASK) 1451 size == 0 || size & AMDGPU_GPU_PAGE_MASK)
1446 return -EINVAL; 1452 return -EINVAL;
1447 1453
1448 if (flags & AMDGPU_PTE_PRT) {
1449 /* Check if we have PRT hardware support */
1450 if (!adev->gart.gart_funcs->set_prt)
1451 return -EINVAL;
1452
1453 amdgpu_vm_prt_get(adev);
1454 }
1455
1456 /* make sure object fit at this offset */ 1454 /* make sure object fit at this offset */
1457 eaddr = saddr + size - 1; 1455 eaddr = saddr + size - 1;
1458 if (saddr >= eaddr || 1456 if (saddr >= eaddr ||
@@ -1533,6 +1531,9 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
1533 vm->page_tables[pt_idx].addr = 0; 1531 vm->page_tables[pt_idx].addr = 0;
1534 } 1532 }
1535 1533
1534 if (flags & AMDGPU_PTE_PRT)
1535 amdgpu_vm_prt_get(adev);
1536
1536 return 0; 1537 return 0;
1537 1538
1538error_free: 1539error_free:
@@ -1753,7 +1754,7 @@ err:
1753void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) 1754void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
1754{ 1755{
1755 struct amdgpu_bo_va_mapping *mapping, *tmp; 1756 struct amdgpu_bo_va_mapping *mapping, *tmp;
1756 bool prt_fini_called = false; 1757 bool prt_fini_needed = !!adev->gart.gart_funcs->set_prt;
1757 int i; 1758 int i;
1758 1759
1759 amd_sched_entity_fini(vm->entity.sched, &vm->entity); 1760 amd_sched_entity_fini(vm->entity.sched, &vm->entity);
@@ -1767,9 +1768,9 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
1767 kfree(mapping); 1768 kfree(mapping);
1768 } 1769 }
1769 list_for_each_entry_safe(mapping, tmp, &vm->freed, list) { 1770 list_for_each_entry_safe(mapping, tmp, &vm->freed, list) {
1770 if (mapping->flags & AMDGPU_PTE_PRT && !prt_fini_called) { 1771 if (mapping->flags & AMDGPU_PTE_PRT && prt_fini_needed) {
1771 amdgpu_vm_prt_fini(adev, vm); 1772 amdgpu_vm_prt_fini(adev, vm);
1772 prt_fini_called = true; 1773 prt_fini_needed = false;
1773 } 1774 }
1774 1775
1775 list_del(&mapping->list); 1776 list_del(&mapping->list);