aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-08-22 08:11:19 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-08-27 16:19:42 -0400
commit24a8d289d532003a167b8f52f97c50430db76ca3 (patch)
tree92b5f81145f3de5a4659dc814a65ca0d9a386e02 /drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
parentbbc9fb10e581c5463961506df7504356b3bd0a61 (diff)
drm/amdgpu: add amdgpu_gmc_get_pde_for_bo helper v2
Helper to get the PDE for a PD/PT. v2: improve documentation Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 36058feac64f..a249931ef512 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -27,6 +27,38 @@
27#include "amdgpu.h" 27#include "amdgpu.h"
28 28
29/** 29/**
30 * amdgpu_gmc_get_pde_for_bo - get the PDE for a BO
31 *
32 * @bo: the BO to get the PDE for
33 * @level: the level in the PD hirarchy
34 * @addr: resulting addr
35 * @flags: resulting flags
36 *
37 * Get the address and flags to be used for a PDE (Page Directory Entry).
38 */
39void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,
40 uint64_t *addr, uint64_t *flags)
41{
42 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
43 struct ttm_dma_tt *ttm;
44
45 switch (bo->tbo.mem.mem_type) {
46 case TTM_PL_TT:
47 ttm = container_of(bo->tbo.ttm, struct ttm_dma_tt, ttm);
48 *addr = ttm->dma_address[0];
49 break;
50 case TTM_PL_VRAM:
51 *addr = amdgpu_bo_gpu_offset(bo);
52 break;
53 default:
54 *addr = 0;
55 break;
56 }
57 *flags = amdgpu_ttm_tt_pde_flags(bo->tbo.ttm, &bo->tbo.mem);
58 amdgpu_gmc_get_vm_pde(adev, level, addr, flags);
59}
60
61/**
30 * amdgpu_gmc_pd_addr - return the address of the root directory 62 * amdgpu_gmc_pd_addr - return the address of the root directory
31 * 63 *
32 */ 64 */
@@ -35,13 +67,14 @@ uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)
35 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 67 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
36 uint64_t pd_addr; 68 uint64_t pd_addr;
37 69
38 pd_addr = amdgpu_bo_gpu_offset(bo);
39 /* TODO: move that into ASIC specific code */ 70 /* TODO: move that into ASIC specific code */
40 if (adev->asic_type >= CHIP_VEGA10) { 71 if (adev->asic_type >= CHIP_VEGA10) {
41 uint64_t flags = AMDGPU_PTE_VALID; 72 uint64_t flags = AMDGPU_PTE_VALID;
42 73
43 amdgpu_gmc_get_vm_pde(adev, -1, &pd_addr, &flags); 74 amdgpu_gmc_get_pde_for_bo(bo, -1, &pd_addr, &flags);
44 pd_addr |= flags; 75 pd_addr |= flags;
76 } else {
77 pd_addr = amdgpu_bo_gpu_offset(bo);
45 } 78 }
46 return pd_addr; 79 return pd_addr;
47} 80}