drm/amdgpu: remove extra root PD alignment
Subsystems (2)
PATCH 1/5 drm/amdgpu: remove extra root PD alignment
Just another leftover from radeon.
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -3
@@ -2566,8 +2566,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, {struct amdgpu_bo_param bp;struct amdgpu_bo *root; -const unsigned align =min (AMDGPU_VM_PTB_ALIGN_SIZE , -AMDGPU_VM_PTE_COUNT (adev) *8 );unsigned long size;uint64_t flags;int r, i;
@@ -2615,7 +2613,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, size =amdgpu_vm_bo_size (adev, adev->vm_manager.root_level);memset (&bp,0 ,sizeof (bp)); bp.size = size; - bp.byte_align = align; + bp.byte_align =AMDGPU_GPU_PAGE_SIZE ; bp.domain =AMDGPU_GEM_DOMAIN_VRAM ; bp.flags = flags; bp.type = ttm_bo_type_kernel;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -3
@@ -48,9 +48,6 @@ struct amdgpu_bo_list_entry;/* number of entries in page table */ #define AMDGPU_VM_PTE_COUNT (adev) (1 << (adev)->vm_manager.block_size) -/* PTBs (Page Table Blocks) need to be aligned to 32K */ -#define AMDGPU_VM_PTB_ALIGN_SIZE 32768 -#define AMDGPU_PTE_VALID (1ULL << 0)#define AMDGPU_PTE_SYSTEM (1ULL << 1)#define AMDGPU_PTE_SNOOPED (1ULL << 2)
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180823123338.1911-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/5 drm/amdgpu: add helper for VM PD/PT allocation parameters
Add a helper function to figure them out only once.
Signed-off-by Christian König <[email protected]>
Reviewed-by Junwei Zhang <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 61 ++++++++++++-------------- 1 file changed, 28 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +28 -33
@@ -446,6 +446,31 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,return r; } +/** +* amdgpu_vm_bo_param - fill in parameters for PD/PT allocation +* +* @adev: amdgpu_device pointer +* @vm: requesting vm +* @bp: resulting BO allocation parameters +*/ +static void amdgpu_vm_bo_param (struct amdgpu_device *adev,struct amdgpu_vm *vm, +int level,struct amdgpu_bo_param *bp) +{ +memset (&bp,0 ,sizeof (bp)); + + bp->size =amdgpu_vm_bo_size (adev, level); + bp->byte_align =AMDGPU_GPU_PAGE_SIZE ; + bp->domain =AMDGPU_GEM_DOMAIN_VRAM ; + bp->flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; +if (vm->use_cpu_for_update) + bp->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; +else + bp->flags |=AMDGPU_GEM_CREATE_SHADOW ; + bp->type = ttm_bo_type_kernel; +if (vm->root.base.bo) + bp->resv = vm->root.base.bo->tbo.resv; +} +/** * amdgpu_vm_alloc_levels - allocate the PD/PT levels *
@@ -469,8 +494,8 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, unsigned level, bool ats) { unsigned shift = amdgpu_vm_level_shift(adev, level); +struct amdgpu_bo_param bp;unsigned pt_idx, from, to; -u64 flags;int r;if (!parent->entries) {
@@ -494,29 +519,14 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, saddr = saddr & ((1 << shift) -1 ); eaddr = eaddr & ((1 << shift) -1 ); - flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; -if (vm->use_cpu_for_update) - flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; -else - flags |= (AMDGPU_GEM_CREATE_NO_CPU_ACCESS | -AMDGPU_GEM_CREATE_SHADOW ); +amdgpu_vm_bo_param (adev, vm, level, &bp);/* walk over the address space and allocate the page tables */ for (pt_idx = from; pt_idx <= to; ++pt_idx) { -struct reservation_object *resv = vm->root.base.bo->tbo.resv;struct amdgpu_vm_pt *entry = &parent->entries[pt_idx];struct amdgpu_bo *pt;if (!entry->base.bo) { -struct amdgpu_bo_param bp; - -memset (&bp,0 ,sizeof (bp)); - bp.size =amdgpu_vm_bo_size (adev, level); - bp.byte_align =AMDGPU_GPU_PAGE_SIZE ; - bp.domain =AMDGPU_GEM_DOMAIN_VRAM ; - bp.flags = flags; - bp.type = ttm_bo_type_kernel; - bp.resv = resv; r =amdgpu_bo_create (adev, &bp, &pt);if (r)return r;
@@ -2566,8 +2576,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, {struct amdgpu_bo_param bp;struct amdgpu_bo *root; -unsigned long size; -uint64_t flags;int r, i; vm->va =RB_ROOT_CACHED ;
@@ -2604,20 +2612,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, "CPU update of VM recommended only for large BAR system\n"); vm->last_update =NULL ; - flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; -if (vm->use_cpu_for_update) - flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; -else - flags |=AMDGPU_GEM_CREATE_SHADOW ; - - size =amdgpu_vm_bo_size (adev, adev->vm_manager.root_level); -memset (&bp,0 ,sizeof (bp)); - bp.size = size; - bp.byte_align =AMDGPU_GPU_PAGE_SIZE ; - bp.domain =AMDGPU_GEM_DOMAIN_VRAM ; - bp.flags = flags; - bp.type = ttm_bo_type_kernel; - bp.resv =NULL ; +amdgpu_vm_bo_param (adev, vm, adev->vm_manager.root_level, &bp); r =amdgpu_bo_create (adev, &bp, &root);if (r) goto error_free_sched_entity;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/5 drm/amdgpu: add GMC9 support for PDs/PTs in system memory
In reply to a message not in the archiveAdd the necessary handling.
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -560,7 +560,7 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,static void gmc_v9_0_get_vm_pde (struct amdgpu_device *adev,int level,uint64_t *addr,uint64_t *flags) { -if (!(*flags &AMDGPU_PDE_PTE )) +if (!(*flags &AMDGPU_PDE_PTE ) && !(*flags &AMDGPU_PTE_SYSTEM )) *addr = adev->vm_manager.vram_base_offset + *addr - adev->gmc.vram_start;BUG_ON (*addr &0xFFFF00000000003FULL );
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/5 drm/amdgpu: add amdgpu_gmc_get_pde_for_bo helper
In reply to a message not in the archiveHelper to get the PDE for a PD/PT.
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 37 +++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 ++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 +-- 5 files changed, 57 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +35 -2
@@ -26,6 +26,38 @@#include "amdgpu.h" +/** +* amdgpu_gmc_get_pde_for_bo - get the PDE for a BO +* +* @bo: the BO to get the PDE for +* @level: the level in the PD hirarchy +* @addr: resulting addr +* @flags: resulting flags +* +* Get the address and flags to be used for a PDE. +*/ +void amdgpu_gmc_get_pde_for_bo (struct amdgpu_bo *bo,int level, +uint64_t *addr,uint64_t *flags) +{ +struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); +struct ttm_dma_tt *ttm; + +switch (bo->tbo.mem.mem_type) { +case TTM_PL_TT : + ttm = container_of(bo->tbo.ttm, struct ttm_dma_tt, ttm); + *addr = ttm->dma_address[0 ]; +break ; +case TTM_PL_VRAM : + *addr =amdgpu_bo_gpu_offset (bo); +break ; +default : + *addr =0 ; +break ; + } + *flags =amdgpu_ttm_tt_pde_flags (bo->tbo.ttm, &bo->tbo.mem); +amdgpu_gmc_get_vm_pde (adev, level, addr, flags); +} +/** * amdgpu_gmc_pd_addr - return the address of the root directory *
@@ -35,13 +67,14 @@ uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);uint64_t pd_addr; - pd_addr =amdgpu_bo_gpu_offset (bo);/* TODO: move that into ASIC specific code */ if (adev->asic_type >=CHIP_VEGA10 ) {uint64_t flags =AMDGPU_PTE_VALID ; -amdgpu_gmc_get_vm_pde (adev,-1 , &pd_addr, &flags); +amdgpu_gmc_get_pde_for_bo (bo,-1 , &pd_addr, &flags); pd_addr |= flags; + }else { + pd_addr =amdgpu_bo_gpu_offset (bo); }return pd_addr; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +2 -0
@@ -131,6 +131,8 @@ static inline bool amdgpu_gmc_vram_full_visible(struct amdgpu_gmc *gmc) return (gmc->real_vram_size == gmc->visible_vram_size); } +void amdgpu_gmc_get_pde_for_bo (struct amdgpu_bo *bo,int level, +uint64_t *addr,uint64_t *flags);uint64_t amdgpu_gmc_pd_addr (struct amdgpu_bo *bo);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +18 -3
@@ -1428,13 +1428,14 @@ bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm) }/** -* amdgpu_ttm_tt_pte_flags - Compute PTE flags for ttm_tt object +* amdgpu_ttm_tt_pde_flags - Compute PDE flags for ttm_tt object * * @ttm: The ttm_tt object to compute the flags for * @mem: The memory registry backing this ttm_tt object +* +* Figure out the flags to use for a VM PDE. */ -uint64_t amdgpu_ttm_tt_pte_flags (struct amdgpu_device *adev,struct ttm_tt *ttm, -struct ttm_mem_reg *mem) +uint64_t amdgpu_ttm_tt_pde_flags (struct ttm_tt *ttm,struct ttm_mem_reg *mem) {uint64_t flags =0 ;
@@ -1448,6 +1449,20 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, flags |=AMDGPU_PTE_SNOOPED ; } +return flags; +} + +/** +* amdgpu_ttm_tt_pte_flags - Compute PTE flags for ttm_tt object +* +* @ttm: The ttm_tt object to compute the flags for +* @mem: The memory registry backing this ttm_tt object +*/ +uint64_t amdgpu_ttm_tt_pte_flags (struct amdgpu_device *adev,struct ttm_tt *ttm, +struct ttm_mem_reg *mem) +{ +uint64_t flags =amdgpu_ttm_tt_pde_flags (ttm, mem); + flags |= adev->gart.gart_pte_flags; flags |=AMDGPU_PTE_READABLE ;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -116,6 +116,7 @@ bool amdgpu_ttm_tt_userptr_invalidated(struct ttm_tt *ttm, int *last_invalidated);bool amdgpu_ttm_tt_userptr_needs_pages (struct ttm_tt *ttm);bool amdgpu_ttm_tt_is_readonly (struct ttm_tt *ttm); +uint64_t amdgpu_ttm_tt_pde_flags (struct ttm_tt *ttm,struct ttm_mem_reg *mem);uint64_t amdgpu_ttm_tt_pte_flags (struct amdgpu_device *adev,struct ttm_tt *ttm,struct ttm_mem_reg *mem);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -3
@@ -992,9 +992,7 @@ static void amdgpu_vm_update_pde(struct amdgpu_pte_update_params *params, pbo = pbo->parent; level += params->adev->vm_manager.root_level; - pt =amdgpu_bo_gpu_offset (entry->base.bo); - flags =AMDGPU_PTE_VALID ; -amdgpu_gmc_get_vm_pde (params->adev, level, &pt, &flags); +amdgpu_gmc_get_pde_for_bo (entry->base.bo, level, &pt, &flags); pde = (entry - parent->entries) *8 ;if (bo->shadow) params->func (params, bo->shadow, pde, pt,1 ,0 , flags);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/5 drm/amdgpu: enable GTT PD/PT for raven v2
In reply to a message not in the archiveShould work on Vega10 as well, but with an obvious performance hit.
Older APUs can be enabled as well, but will probably be more work.
v2: fix error checking
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12 -1
@@ -308,6 +308,9 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,list_move (&bo_base->vm_status, &vm->moved);spin_unlock (&vm->moved_lock); }else { + r =amdgpu_ttm_alloc_gart (&bo->tbo); +if (r) +break ;list_move (&bo_base->vm_status, &vm->relocated); } }
@@ -396,6 +399,10 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r) goto error; + r =amdgpu_ttm_alloc_gart (&bo->tbo); +if (r) +return r; + r =amdgpu_job_alloc_with_ib (adev,64 , &job);if (r) goto error;
@@ -461,7 +468,11 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm, bp->size =amdgpu_vm_bo_size (adev, level); bp->byte_align =AMDGPU_GPU_PAGE_SIZE ; bp->domain =AMDGPU_GEM_DOMAIN_VRAM ; - bp->flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; +if (bp->size <=PAGE_SIZE && adev->asic_type ==CHIP_RAVEN ) + bp->domain |=AMDGPU_GEM_DOMAIN_GTT ; + bp->domain =amdgpu_bo_get_preferred_pin_domain (adev, bp->domain); + bp->flags =AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | +AMDGPU_GEM_CREATE_CPU_GTT_USWC ;if (vm->use_cpu_for_update) bp->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;else
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx