diff options
author | Monk Liu <Monk.Liu@amd.com> | 2017-01-09 02:54:32 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-01-27 11:13:20 -0500 |
commit | 2493664f0594d4140a5025de8e419ca2c16ccee9 (patch) | |
tree | da101f5fd861a50807e137104c89edb42d7d5fcd /drivers/gpu/drm/amd/amdgpu | |
parent | 4e4bbe7343a6d8269342189329b865355fe1bb51 (diff) |
drm/amdgpu:invoke CSA functions (v2)
Make sure the CSA is mapped.
v2: agd: rebase.
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 14 |
3 files changed, 40 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 29d6d84d1c28..8d019ca7d9c7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -771,6 +771,20 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p, | |||
771 | if (r) | 771 | if (r) |
772 | return r; | 772 | return r; |
773 | 773 | ||
774 | if (amdgpu_sriov_vf(adev)) { | ||
775 | struct dma_fence *f; | ||
776 | bo_va = vm->csa_bo_va; | ||
777 | BUG_ON(!bo_va); | ||
778 | r = amdgpu_vm_bo_update(adev, bo_va, false); | ||
779 | if (r) | ||
780 | return r; | ||
781 | |||
782 | f = bo_va->last_pt_update; | ||
783 | r = amdgpu_sync_fence(adev, &p->job->sync, f); | ||
784 | if (r) | ||
785 | return r; | ||
786 | } | ||
787 | |||
774 | if (p->bo_list) { | 788 | if (p->bo_list) { |
775 | for (i = 0; i < p->bo_list->num_entries; i++) { | 789 | for (i = 0; i < p->bo_list->num_entries; i++) { |
776 | struct dma_fence *f; | 790 | struct dma_fence *f; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 85b36edbdd61..121b8440cf40 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1395,6 +1395,15 @@ static int amdgpu_init(struct amdgpu_device *adev) | |||
1395 | return r; | 1395 | return r; |
1396 | } | 1396 | } |
1397 | adev->ip_blocks[i].status.hw = true; | 1397 | adev->ip_blocks[i].status.hw = true; |
1398 | |||
1399 | /* right after GMC hw init, we create CSA */ | ||
1400 | if (amdgpu_sriov_vf(adev)) { | ||
1401 | r = amdgpu_allocate_static_csa(adev); | ||
1402 | if (r) { | ||
1403 | DRM_ERROR("allocate CSA failed %d\n", r); | ||
1404 | return r; | ||
1405 | } | ||
1406 | } | ||
1398 | } | 1407 | } |
1399 | } | 1408 | } |
1400 | 1409 | ||
@@ -1528,6 +1537,9 @@ static int amdgpu_fini(struct amdgpu_device *adev) | |||
1528 | adev->ip_blocks[i].status.late_initialized = false; | 1537 | adev->ip_blocks[i].status.late_initialized = false; |
1529 | } | 1538 | } |
1530 | 1539 | ||
1540 | if (amdgpu_sriov_vf(adev)) | ||
1541 | amdgpu_bo_free_kernel(&adev->virt.csa_obj, &adev->virt.csa_vmid0_addr, NULL); | ||
1542 | |||
1531 | return 0; | 1543 | return 0; |
1532 | } | 1544 | } |
1533 | 1545 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 43169ab61a78..8f852cb152f5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -649,6 +649,12 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
649 | goto out_suspend; | 649 | goto out_suspend; |
650 | } | 650 | } |
651 | 651 | ||
652 | if (amdgpu_sriov_vf(adev)) { | ||
653 | r = amdgpu_map_static_csa(adev, &fpriv->vm); | ||
654 | if (r) | ||
655 | goto out_suspend; | ||
656 | } | ||
657 | |||
652 | mutex_init(&fpriv->bo_list_lock); | 658 | mutex_init(&fpriv->bo_list_lock); |
653 | idr_init(&fpriv->bo_list_handles); | 659 | idr_init(&fpriv->bo_list_handles); |
654 | 660 | ||
@@ -687,6 +693,14 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, | |||
687 | amdgpu_uvd_free_handles(adev, file_priv); | 693 | amdgpu_uvd_free_handles(adev, file_priv); |
688 | amdgpu_vce_free_handles(adev, file_priv); | 694 | amdgpu_vce_free_handles(adev, file_priv); |
689 | 695 | ||
696 | if (amdgpu_sriov_vf(adev)) { | ||
697 | /* TODO: how to handle reserve failure */ | ||
698 | BUG_ON(amdgpu_bo_reserve(adev->virt.csa_obj, false)); | ||
699 | amdgpu_vm_bo_rmv(adev, fpriv->vm.csa_bo_va); | ||
700 | fpriv->vm.csa_bo_va = NULL; | ||
701 | amdgpu_bo_unreserve(adev->virt.csa_obj); | ||
702 | } | ||
703 | |||
690 | amdgpu_vm_fini(adev, &fpriv->vm); | 704 | amdgpu_vm_fini(adev, &fpriv->vm); |
691 | 705 | ||
692 | idr_for_each_entry(&fpriv->bo_list_handles, list, handle) | 706 | idr_for_each_entry(&fpriv->bo_list_handles, list, handle) |