From: Xiangliang Yu <[email protected]>

Allocate MM table for sriov device.

Signed-off-by: Xiangliang Yu <[email protected]>
Signed-off-by: Monk Liu <[email protected]>
Reviewed-by: Alex Deucher <[email protected]>
Reviewed-by: Monk Liu <[email protected]>
Reviewed-by: Christian König <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/vce_v4_0.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
index 21a86d8..b1b887e 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
@@ -294,6 +294,21 @@ static int vce_v4_0_sw_init(void *handle)
                        return r;
        }
 
+       if (amdgpu_sriov_vf(adev)) {
+               r = amdgpu_bo_create_kernel(adev, PAGE_SIZE, PAGE_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &adev->virt.mm_table.bo,
+                                           &adev->virt.mm_table.gpu_addr,
+                                           (void 
*)&adev->virt.mm_table.cpu_addr);
+               if (!r) {
+                       memset((void *)adev->virt.mm_table.cpu_addr, 0, 
PAGE_SIZE);
+                       printk("mm table gpu addr = 0x%llx, cpu addr = %p. \n",
+                              adev->virt.mm_table.gpu_addr,
+                              adev->virt.mm_table.cpu_addr);
+               }
+               return r;
+       }
+
        return r;
 }
 
@@ -302,6 +317,12 @@ static int vce_v4_0_sw_fini(void *handle)
        int r;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       /* free MM table */
+       if (amdgpu_sriov_vf(adev))
+               amdgpu_bo_free_kernel(&adev->virt.mm_table.bo,
+                                     &adev->virt.mm_table.gpu_addr,
+                                     (void *)&adev->virt.mm_table.cpu_addr);
+
        r = amdgpu_vce_suspend(adev);
        if (r)
                return r;
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to