drm/amdgpu: SHADOW and VRAM_CONTIGUOUS flags shouldn't be used by userspace
Subsystems (2)
PATCH 1/8 drm/amdgpu: SHADOW and VRAM_CONTIGUOUS flags shouldn't be used by userspace
From: Christian König <[email protected]>
The shadow handling isn't implemented completely for userspace BOs and the kernel sets the VRAM_CONTIGUOUS as necessary.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -3
@@ -225,9 +225,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,if (args->in.domain_flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_NO_CPU_ACCESS |AMDGPU_GEM_CREATE_CPU_GTT_USWC | -AMDGPU_GEM_CREATE_VRAM_CLEARED | -AMDGPU_GEM_CREATE_SHADOW | -AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS )) +AMDGPU_GEM_CREATE_VRAM_CLEARED ))return -EINVAL ;/* reject invalid gem domains */
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1502376647-4519-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
PATCH 2/8 drm/amdgpu: cleanup static CSA handling
From: Christian König <[email protected]>
Move the CSA bo_va from the VM to the fpriv structure.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 25 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 -- 6 files changed, 20 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -750,6 +750,7 @@ void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr);struct amdgpu_fpriv {struct amdgpu_vm vm;struct amdgpu_bo_va *prt_va; +struct amdgpu_bo_va *csa_va;struct mutex bo_list_lock;struct idr bo_list_handles;struct amdgpu_ctx_mgr ctx_mgr;
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -1
@@ -778,7 +778,8 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p)if (amdgpu_sriov_vf (adev)) {struct dma_fence *f; - bo_va = vm->csa_bo_va; + + bo_va = fpriv->csa_va;BUG_ON (!bo_va); r =amdgpu_vm_bo_update (adev, bo_va, false);if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -3
@@ -843,7 +843,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) }if (amdgpu_sriov_vf (adev)) { - r =amdgpu_map_static_csa (adev, &fpriv->vm); + r =amdgpu_map_static_csa (adev, &fpriv->vm, &fpriv->csa_va);if (r) goto out_suspend; }
@@ -896,8 +896,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,if (amdgpu_sriov_vf (adev)) {/* TODO: how to handle reserve failure */ BUG_ON (amdgpu_bo_reserve (adev->virt.csa_obj, true)); -amdgpu_vm_bo_rmv (adev, fpriv->vm.csa_bo_va); - fpriv->vm.csa_bo_va =NULL ; +amdgpu_vm_bo_rmv (adev, fpriv->csa_va); + fpriv->csa_va =NULL ;amdgpu_bo_unreserve (adev->virt.csa_obj); }
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +12 -13
@@ -46,14 +46,14 @@ int amdgpu_allocate_static_csa(struct amdgpu_device *adev)* address within META_DATA init package to support SRIOV gfx preemption. */ -int amdgpu_map_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm) +int amdgpu_map_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amdgpu_bo_va **bo_va) { -int r; -struct amdgpu_bo_va *bo_va;struct ww_acquire_ctx ticket;struct list_head list;struct amdgpu_bo_list_entry pd;struct ttm_validate_buffer csa_tv; +int r;INIT_LIST_HEAD (&list);INIT_LIST_HEAD (&csa_tv.head);
@@ -69,34 +69,33 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm)return r; } - bo_va =amdgpu_vm_bo_add (adev, vm, adev->virt.csa_obj); -if (!bo_va) { + *bo_va =amdgpu_vm_bo_add (adev, vm, adev->virt.csa_obj); +if (!*bo_va) {ttm_eu_backoff_reservation (&ticket, &list);DRM_ERROR ("failed to create bo_va for static CSA\n" );return -ENOMEM ; } - r =amdgpu_vm_alloc_pts (adev, bo_va->vm,AMDGPU_CSA_VADDR , -AMDGPU_CSA_SIZE ); + r =amdgpu_vm_alloc_pts (adev, (*bo_va)->vm,AMDGPU_CSA_VADDR , +AMDGPU_CSA_SIZE );if (r) {DRM_ERROR ("failed to allocate pts for static CSA, err=%d\n" , r); -amdgpu_vm_bo_rmv (adev, bo_va); +amdgpu_vm_bo_rmv (adev, *bo_va);ttm_eu_backoff_reservation (&ticket, &list);return r; } - r =amdgpu_vm_bo_map (adev, bo_va,AMDGPU_CSA_VADDR ,0 ,AMDGPU_CSA_SIZE , -AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE | -AMDGPU_PTE_EXECUTABLE ); + r =amdgpu_vm_bo_map (adev, *bo_va,AMDGPU_CSA_VADDR ,0 ,AMDGPU_CSA_SIZE , +AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE | +AMDGPU_PTE_EXECUTABLE );if (r) {DRM_ERROR ("failed to do bo_map on static CSA, err=%d\n" , r); -amdgpu_vm_bo_rmv (adev, bo_va); +amdgpu_vm_bo_rmv (adev, *bo_va);ttm_eu_backoff_reservation (&ticket, &list);return r; } - vm->csa_bo_va = bo_va;ttm_eu_backoff_reservation (&ticket, &list);return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -1
@@ -90,7 +90,8 @@ static inline bool is_virtual_machine(void)struct amdgpu_vm ;int amdgpu_allocate_static_csa (struct amdgpu_device *adev); -int amdgpu_map_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm); +int amdgpu_map_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amdgpu_bo_va **bo_va);void amdgpu_virt_init_setting (struct amdgpu_device *adev);uint32_t amdgpu_virt_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_virt_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -2
@@ -141,8 +141,6 @@ struct amdgpu_vm {u64 client_id;/* dedicated to vm */ struct amdgpu_vm_id *reserved_vmid[AMDGPU_MAX_VMHUBS ]; -/* each VM will map on CSA */ -struct amdgpu_bo_va *csa_bo_va;/* Flag to indicate if VM tables are updated by CPU or GPU (SDMA) */ bool use_cpu_for_update;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/8 drm/amdgpu: remove superflous amdgpu_bo_kmap in the VM
In reply to a message not in the archiveFrom: Christian König <[email protected]>
We now properly kmap all BOs after validation.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +9 -19
@@ -1264,15 +1264,14 @@ void amdgpu_vm_get_entry(struct amdgpu_pte_update_params *p, uint64_t addr,* * Check if we can update the PD with a huge page. */ -static int amdgpu_vm_handle_huge_pages (struct amdgpu_pte_update_params *p, -struct amdgpu_vm_pt *entry, -struct amdgpu_vm_pt *parent, -unsigned nptes,uint64_t dst, -uint64_t flags) +static void amdgpu_vm_handle_huge_pages (struct amdgpu_pte_update_params *p, +struct amdgpu_vm_pt *entry, +struct amdgpu_vm_pt *parent, +unsigned nptes,uint64_t dst, +uint64_t flags) {bool use_cpu_update = (p->func == amdgpu_vm_cpu_set_ptes);uint64_t pd_addr, pde; -int r;/* In the case of a mixed PT the PDE must point to it*/ if (p->adev->asic_type < CHIP_VEGA10 ||
@@ -1289,16 +1288,13 @@ static int amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p,if (entry->addr == dst && entry->huge_page == !!(flags &AMDGPU_PDE_PTE )) -return 0 ; +return ; entry->addr = dst; entry->huge_page = !!(flags &AMDGPU_PDE_PTE );if (use_cpu_update) { - r =amdgpu_bo_kmap (parent->bo, (void *)&pd_addr); -if (r) -return r; - + pd_addr = (unsigned long )amdgpu_bo_kptr (parent->bo); pde = pd_addr + (entry - parent->entries) *8 ;amdgpu_vm_cpu_set_ptes (p, pde, dst,1 ,0 , flags); }else {
@@ -1311,8 +1307,6 @@ static int amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, pde = pd_addr + (entry - parent->entries) *8 ;amdgpu_vm_do_set_ptes (p, pde, dst,1 ,0 , flags); } - -return 0 ; }/**
@@ -1339,7 +1333,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,struct amdgpu_bo *pt;unsigned nptes;bool use_cpu_update = (params->func == amdgpu_vm_cpu_set_ptes); -int r;/* walk over the address space and update the page tables */ for (addr = start; addr < end; addr += nptes,
@@ -1355,11 +1348,8 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,else nptes =AMDGPU_VM_PTE_COUNT (adev) - (addr & mask); - r =amdgpu_vm_handle_huge_pages (params, entry, parent, - nptes, dst, flags); -if (r) -return r; - +amdgpu_vm_handle_huge_pages (params, entry, parent, + nptes, dst, flags);if (entry->huge_page)continue ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/8 drm/amdgpu: drop the extra VM huge page flag
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Just add the flags to the addr field as well.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 ++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 - 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -9
@@ -330,7 +330,6 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, entry->bo = pt; entry->addr =0 ; - entry->huge_page = false; }if (level < adev->vm_manager.num_level) {
@@ -1082,11 +1081,11 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev, pt =amdgpu_bo_gpu_offset (bo); pt =amdgpu_gart_get_vm_pde (adev, pt); -if (parent->entries[pt_idx].addr == pt || - parent->entries[pt_idx].huge_page) +if ((parent->entries[pt_idx].addr &AMDGPU_PDE_PTE ) || + parent->entries[pt_idx].addr == (pt |AMDGPU_PTE_VALID ))continue ; - parent->entries[pt_idx].addr = pt; + parent->entries[pt_idx].addr = pt |AMDGPU_PTE_VALID ; pde = pd_addr + pt_idx *8 ; if (((last_pde + 8 * count) != pde) ||
@@ -1286,12 +1285,10 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, flags |=AMDGPU_PDE_PTE ; } -if (entry->addr == dst && - entry->huge_page == !!(flags &AMDGPU_PDE_PTE )) +if (entry->addr == (dst | flags))return ; - entry->addr = dst; - entry->huge_page = !!(flags &AMDGPU_PDE_PTE ); + entry->addr = (dst | flags);if (use_cpu_update) { pd_addr = (unsigned long )amdgpu_bo_kptr (parent->bo);
@@ -1350,7 +1347,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,amdgpu_vm_handle_huge_pages (params, entry, parent, nptes, dst, flags); -if (entry->huge_page) +if (entry->addr &AMDGPU_PDE_PTE )continue ; pt = entry->bo;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -1
@@ -103,7 +103,6 @@ struct amdgpu_bo_list_entry;struct amdgpu_vm_pt {struct amdgpu_bo *bo;uint64_t addr; -bool huge_page;/* array of page tables, one for each directory entry */ struct amdgpu_vm_pt *entries;
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1502376647-4519-4-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherRE: [PATCH 4/8] drm/amdgpu: drop the extra VM huge page flag
Quoted 10 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Thursday, August 10, 2017 10:51 AM
To: [email protected]
Subject: [PATCH 4/8] drm/amdgpu: drop the extra VM huge page flagFrom: Christian König <[email protected]>
Just add the flags to the addr field as well.
The flag makes it easier to understand what is going on. Can you add some comments to the code when you set the flags to describe that this is for huge pages? That should make it clear why we need to set them the way we do. With that fixed:
Quoted 80 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 ++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 - 2 files changed, 6 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-1@@ -330,7 +330,6 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, entry->bo = pt; entry->addr =0 ; - entry->huge_page = false; }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3
-3if (level < adev->vm_manager.num_level) {@@ -1082,11 +1081,11 @@ static int amdgpu_vm_update_level(structamdgpu_device *adev, pt =amdgpu_bo_gpu_offset (bo); pt =amdgpu_gart_get_vm_pde (adev, pt); -if (parent->entries[pt_idx].addr == pt || - parent->entries[pt_idx].huge_page) +if ((parent->entries[pt_idx].addr &AMDGPU_PDE_PTE ) || + parent->entries[pt_idx].addr == (pt |AMDGPU_PTE_VALID ))continue ; - parent->entries[pt_idx].addr = pt; + parent->entries[pt_idx].addr = pt |AMDGPU_PTE_VALID ;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-4pde = pd_addr + pt_idx *8 ; if (((last_pde + 8 * count) != pde) ||@@ -1286,12 +1285,10 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, flags |= AMDGPU_PDE_PTE; } -if (entry->addr == dst && - entry->huge_page == !!(flags &AMDGPU_PDE_PTE )) +if (entry->addr == (dst | flags))return ; - entry->addr = dst; - entry->huge_page = !!(flags &AMDGPU_PDE_PTE ); + entry->addr = (dst | flags);if (use_cpu_update) {drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1pd_addr = (unsigned long )amdgpu_bo_kptr (parent->bo);@@ -1350,7 +1347,7 @@ static int amdgpu_vm_update_ptes(structamdgpu_pte_update_params *params,amdgpu_vm_handle_huge_pages (params ,entry ,parent ,nptes ,dst ,flags ); -if (entry->huge_page) +if (entry->addr &AMDGPU_PDE_PTE )continue ;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0pt = entry->bo;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0
-2@@ -103,7 +103,6 @@ struct amdgpu_bo_list_entry;struct amdgpu_vm_pt {struct amdgpu_bo *bo;uint64_t addr; -bool huge_page;/* array of page tables, one for each directory entry */ struct amdgpu_vm_pt *entries; --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/8 drm/amdgpu: separate bo_va structure
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Split that into vm_bo_base and bo_va to allow other uses as well.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 14 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 81 ++++++++++++++++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 12 +++++ 7 files changed, 66 insertions(+), 55 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
@@ -1402,7 +1402,7 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, addr > mapping->last)continue ; - *bo = lobj->bo_va->bo; + *bo = lobj->bo_va->base.bo;return mapping; }
@@ -1411,7 +1411,7 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, addr > mapping->last)continue ; - *bo = lobj->bo_va->bo; + *bo = lobj->bo_va->base.bo;return mapping; } }
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -2
@@ -621,7 +621,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,switch (args->operation) {case AMDGPU_VA_OP_MAP : - r =amdgpu_vm_alloc_pts (adev, bo_va->vm, args->va_address, + r =amdgpu_vm_alloc_pts (adev, bo_va->base.vm, args->va_address, args->map_size);if (r) goto error_backoff;
@@ -641,7 +641,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, args->map_size);break ;case AMDGPU_VA_OP_REPLACE : - r =amdgpu_vm_alloc_pts (adev, bo_va->vm, args->va_address, + r =amdgpu_vm_alloc_pts (adev, bo_va->base.vm, args->va_address, args->map_size);if (r) goto error_backoff;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +4 -10
@@ -33,6 +33,7 @@#define AMDGPU_BO_INVALID_OFFSET LONG_MAX +/* bo virtual addresses in a vm */ struct amdgpu_bo_va_mapping {struct list_head list;struct rb_node rb;
@@ -43,26 +44,19 @@ struct amdgpu_bo_va_mapping {uint64_t flags; }; -/* bo virtual addresses in a specific vm */ +/* User space allocated BO in a VM */ struct amdgpu_bo_va { +struct amdgpu_vm_bo_base base; +/* protected by bo being reserved */ -struct list_head bo_list;struct dma_fence *last_pt_update;unsigned ref_count; -/* protected by vm mutex and spinlock */ -struct list_head vm_status; -/* mappings for this bo_va */ struct list_head invalids;struct list_head valids; - -/* constant after initialization */ -struct amdgpu_vm *vm; -struct amdgpu_bo *bo; }; -struct amdgpu_bo {/* Protected by tbo.reserved */ u32 preferred_domains;
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -2
@@ -284,7 +284,7 @@ TRACE_EVENT(amdgpu_vm_bo_map, ),TP_fast_assign ( - __entry->bo = bo_va ? bo_va->bo : NULL; + __entry->bo = bo_va ? bo_va->base.bo : NULL; __entry->start = mapping->start; __entry->last = mapping->last; __entry->offset = mapping->offset;
@@ -308,7 +308,7 @@ TRACE_EVENT(amdgpu_vm_bo_unmap, ), TP_fast_assign( - __entry->bo = bo_va->bo; + __entry->bo = bo_va->base.bo; __entry->start = mapping->start; __entry->last = mapping->last; __entry->offset = mapping->offset;
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -1
@@ -76,7 +76,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,return -ENOMEM ; } - r =amdgpu_vm_alloc_pts (adev, (*bo_va)->vm,AMDGPU_CSA_VADDR , + r =amdgpu_vm_alloc_pts (adev, (*bo_va)->base.vm,AMDGPU_CSA_VADDR ,AMDGPU_CSA_SIZE );if (r) {DRM_ERROR ("failed to allocate pts for static CSA, err=%d\n" , r);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +43 -38
198 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +12 -0
@@ -99,6 +99,18 @@ struct amdgpu_bo_list_entry;#define AMDGPU_VM_USE_CPU_FOR_GFX (1 << 0)#define AMDGPU_VM_USE_CPU_FOR_COMPUTE (1 << 1) +/* base structure for tracking BO usage in a VM */ +struct amdgpu_vm_bo_base { +/* constant after initialization */ +struct amdgpu_vm *vm; +struct amdgpu_bo *bo; + +/* protected by bo being reserved */ +struct list_head bo_list; + +/* protected by spinlock */ +struct list_head vm_status; +};struct amdgpu_vm_pt {struct amdgpu_bo *bo;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/8 drm/amdgpu: rename VM invalidated to moved
In reply to a message not in the archiveFrom: Christian König <[email protected]>
That better describes what happens here with the BO.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 ++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -816,7 +816,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p) } - r =amdgpu_vm_clear_invalids (adev, vm, &p->job->sync); + r =amdgpu_vm_clear_moved (adev, vm, &p->job->sync);if (amdgpu_vm_debug && p->bo_list) {/* Invalidate all BOs to test for userspace bugs */
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -8
@@ -1979,25 +1979,25 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, }/** -* amdgpu_vm_clear_invalids - clear invalidated BOs in the PT +* amdgpu_vm_clear_moved - clear moved BOs in the PT * * @adev: amdgpu_device pointer * @vm: requested vm * -* Make sure all invalidated BOs are cleared in the PT. +* Make sure all moved BOs are cleared in the PT. * Returns 0 for success. * * PTs have to be reserved and mutex must be locked! */ -int amdgpu_vm_clear_invalids (struct amdgpu_device *adev, -struct amdgpu_vm *vm,struct amdgpu_sync *sync) +int amdgpu_vm_clear_moved (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amdgpu_sync *sync) {struct amdgpu_bo_va *bo_va =NULL ;int r =0 ;spin_lock (&vm->status_lock); -while (!list_empty (&vm->invalidated)) { - bo_va =list_first_entry (&vm->invalidated, +while (!list_empty (&vm->moved)) { + bo_va =list_first_entry (&vm->moved, struct amdgpu_bo_va, base.vm_status);spin_unlock (&vm->status_lock);
@@ -2392,7 +2392,7 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,spin_lock (&bo_base->vm->status_lock);if (list_empty (&bo_base->vm_status))list_add (&bo_base->vm_status, - &bo_base->vm->invalidated); + &bo_base->vm->moved);spin_unlock (&bo_base->vm->status_lock); } }
@@ -2461,7 +2461,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,for (i =0 ; i <AMDGPU_MAX_VMHUBS ; i++) vm->reserved_vmid[i] =NULL ;spin_lock_init (&vm->status_lock); -INIT_LIST_HEAD (&vm->invalidated); +INIT_LIST_HEAD (&vm->moved);INIT_LIST_HEAD (&vm->cleared);INIT_LIST_HEAD (&vm->freed);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3 -3
@@ -129,7 +129,7 @@ struct amdgpu_vm {spinlock_t status_lock;/* BOs moved, but not yet updated in the PT */ -struct list_head invalidated; +struct list_head moved;/* BOs cleared in the PT because of a move */ struct list_head cleared;
@@ -247,8 +247,8 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev,int amdgpu_vm_clear_freed (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct dma_fence **fence); -int amdgpu_vm_clear_invalids (struct amdgpu_device *adev,struct amdgpu_vm *vm, -struct amdgpu_sync *sync); +int amdgpu_vm_clear_moved (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct amdgpu_sync *sync);int amdgpu_vm_bo_update (struct amdgpu_device *adev,struct amdgpu_bo_va *bo_va,bool clear);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/8 drm/amdgpu: track evicted page tables
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Instead of validating all page tables when one was evicted, track which one needs a validation.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 7 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 217 ++++++++++++++--------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 14 +- 4 files changed, 116 insertions(+), 124 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -5
@@ -632,9 +632,6 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,amdgpu_cs_report_moved_bytes (p->adev, p->bytes_moved, p->bytes_moved_vis); - fpriv->vm.last_eviction_counter = -atomic64_read (&p->adev->num_evictions); -if (p->bo_list) {struct amdgpu_bo *gds = p->bo_list->gds_obj;struct amdgpu_bo *gws = p->bo_list->gws_obj;
@@ -826,7 +823,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p)if (!bo)continue ; -amdgpu_vm_bo_invalidate (adev, bo); +amdgpu_vm_bo_invalidate (adev, bo, false); } }
@@ -851,7 +848,7 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev, }if (p->job->vm) { - p->job->vm_pd_addr =amdgpu_bo_gpu_offset (vm->root.bo); + p->job->vm_pd_addr =amdgpu_bo_gpu_offset (vm->root.base.bo); r =amdgpu_bo_vm_update_pte (p);if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -929,7 +929,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,return ; abo = container_of(bo, struct amdgpu_bo, tbo); -amdgpu_vm_bo_invalidate (adev, abo); +amdgpu_vm_bo_invalidate (adev, abo, evict);amdgpu_bo_kunmap (abo);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +105 -112
411 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +8 -6
@@ -113,12 +113,12 @@ struct amdgpu_vm_bo_base { };struct amdgpu_vm_pt { -struct amdgpu_bo *bo; -uint64_t addr; +struct amdgpu_vm_bo_base base; +uint64_t addr;/* array of page tables, one for each directory entry */ -struct amdgpu_vm_pt *entries; -unsigned last_entry_used; +struct amdgpu_vm_pt *entries; +unsigned last_entry_used; };struct amdgpu_vm {
@@ -128,6 +128,9 @@ struct amdgpu_vm {/* protecting invalidated */ spinlock_t status_lock; +/* BOs who needs a validation */ +struct list_head evicted; +/* BOs moved, but not yet updated in the PT */ struct list_head moved;
@@ -140,7 +143,6 @@ struct amdgpu_vm {/* contains the page directory */ struct amdgpu_vm_pt root;struct dma_fence *last_dir_update; -uint64_t last_eviction_counter;/* protecting freed */ spinlock_t freed_lock;
@@ -253,7 +255,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,struct amdgpu_bo_va *bo_va, bool clear);void amdgpu_vm_bo_invalidate (struct amdgpu_device *adev, -struct amdgpu_bo *bo); +struct amdgpu_bo *bo,bool evicted);struct amdgpu_bo_va *amdgpu_vm_bo_find (struct amdgpu_vm *vm,struct amdgpu_bo *bo); struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1502376647-4519-7-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 7/8] drm/amdgpu: track evicted page tables
Quoted 13 lines · Christian König
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-1@@ -2384,11 +2360,24 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,* Mark @bo as invalid. */ void amdgpu_vm_bo_invalidate (struct amdgpu_device *adev, -struct amdgpu_bo *bo) +struct amdgpu_bo *bo,bool evicted) {struct amdgpu_vm_bo_base *bo_base;list_for_each_entry (bo_base, &bo->va, bo_list) { +struct amdgpu_vm *vm = bo_base->vm; + +if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, · line 2380
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10
-0+spin_lock (&bo_base->vm->status_lock); +list_move (&bo_base->vm_status, &vm->evicted); +spin_unlock (&bo_base->vm->status_lock); +continue ; + } + +/* Don't add page tables to the moved state */ +if (bo->tbo.type == ttm_bo_type_kernel) +continue ; +
It looks like you're using two different conditions to detect page tables. When evicted is true, you use (bo->tbo.resv == vm->root.base.bo->tbo.resv). Otherwise you use (bo->tbo.type == ttm_bo_type_kernel). Are these really the same or is there a subtle difference I'm missing? I'd find the following logic easier to read, but I'm not sure if that's really your intention:
if (bo->tbo.resv == vm->root.base.bo->tbo.resv) {
spin_lock(&bo_base->vm->status_lock);
if (evicted)
list_move(&bo_base->vm_status, &vm->evicted);
else if (list_empty(&bo_base->vm_status))
/* this is from the next commit */
list_add(&bo_base->vm_status, &vm->relocated);
spin_unlock(&bo_base->vm->status_lock);
continue;
}Regards,
Felix
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, · line 2383
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0spin_lock (&bo_base->vm->status_lock);if (list_empty (&bo_base->vm_status)) list_add(&bo_base->vm_status,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/8 drm/amdgpu: rework page directory filling
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Keep track off relocated PDs/PTs instead of walking and checking all PDs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 85 ++++++++++++++++++++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 ++ 2 files changed, 59 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +56 -29
@@ -204,7 +204,10 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, }spin_lock (&vm->status_lock); -list_del_init (&bo_base->vm_status); +if (bo->parent) +list_move (&bo_base->vm_status, &vm->relocated); +else +list_del_init (&bo_base->vm_status); }spin_unlock (&vm->status_lock);
@@ -303,8 +306,10 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, entry->base.vm = vm; entry->base.bo = pt;list_add_tail (&entry->base.bo_list, &pt->va); -INIT_LIST_HEAD (&entry->base.vm_status); - entry->addr =0 ; +spin_lock (&vm->status_lock); +list_add (&entry->base.vm_status, &vm->relocated); +spin_unlock (&vm->status_lock); + entry->addr = ~0ULL ; }if (level < adev->vm_manager.num_level) {
@@ -989,18 +994,17 @@ static int amdgpu_vm_wait_pd(struct amdgpu_device *adev, struct amdgpu_vm *vm,*/ static int amdgpu_vm_update_level (struct amdgpu_device *adev,struct amdgpu_vm *vm, -struct amdgpu_vm_pt *parent, -unsigned level) +struct amdgpu_vm_pt *parent) {struct amdgpu_bo *shadow;struct amdgpu_ring *ring =NULL ;uint64_t pd_addr, shadow_addr =0 ; -uint32_t incr =amdgpu_vm_bo_size (adev, level +1 );uint64_t last_pde = ~0 , last_pt = ~0 , last_shadow = ~0 ;unsigned count =0 , pt_idx, ndw =0 ;struct amdgpu_job *job;struct amdgpu_pte_update_params params;struct dma_fence *fence =NULL ; +uint32_t incr;int r;
@@ -1048,12 +1052,17 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,/* walk over the address space and update the directory */ for (pt_idx =0 ; pt_idx <= parent->last_entry_used; ++pt_idx) { -struct amdgpu_bo *bo = parent->entries[pt_idx].base.bo; +struct amdgpu_vm_pt *entry = &parent->entries[pt_idx]; +struct amdgpu_bo *bo = entry->base.bo;uint64_t pde, pt;if (bo ==NULL )continue ; +spin_lock (&vm->status_lock); +list_del_init (&entry->base.vm_status); +spin_unlock (&vm->status_lock); + pt =amdgpu_bo_gpu_offset (bo); pt =amdgpu_gart_get_vm_pde (adev, pt); if ((parent->entries[pt_idx].addr & AMDGPU_PDE_PTE) ||
@@ -1063,6 +1072,7 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev, parent->entries[pt_idx].addr = pt |AMDGPU_PTE_VALID ; pde = pd_addr + pt_idx *8 ; + incr =amdgpu_bo_size (bo);if (((last_pde +8 * count) != pde) || ((last_pt + incr * count) != pt) || (count ==AMDGPU_VM_MAX_UPDATE_SIZE )) {
@@ -1123,20 +1133,6 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,dma_fence_put (fence); } } -/* -* Recurse into the subdirectories. This recursion is harmless because -* we only have a maximum of 5 layers. -*/ -for (pt_idx =0 ; pt_idx <= parent->last_entry_used; ++pt_idx) { -struct amdgpu_vm_pt *entry = &parent->entries[pt_idx]; - -if (!entry->base.bo) -continue ; - - r =amdgpu_vm_update_level (adev, vm, entry, level +1 ); -if (r) -return r; - }return 0 ;
@@ -1152,7 +1148,8 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,* * Mark all PD level as invalid after an error. */ -static void amdgpu_vm_invalidate_level (struct amdgpu_vm_pt *parent) +static void amdgpu_vm_invalidate_level (struct amdgpu_vm *vm, +struct amdgpu_vm_pt *parent) {unsigned pt_idx;
@@ -1167,7 +1164,10 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_vm_pt *parent)continue ; entry->addr = ~0ULL ; -amdgpu_vm_invalidate_level (entry); +spin_lock (&vm->status_lock); +list_move (&entry->base.vm_status, &vm->relocated); +spin_unlock (&vm->status_lock); +amdgpu_vm_invalidate_level (vm, entry); } }
@@ -1185,9 +1185,31 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, {int r; - r =amdgpu_vm_update_level (adev, vm, &vm->root,0 ); -if (r) -amdgpu_vm_invalidate_level (&vm->root); +spin_lock (&vm->status_lock); +while (!list_empty (&vm->relocated)) { +struct amdgpu_vm_bo_base *bo_base, *parent; +struct amdgpu_vm_pt *pt; +struct amdgpu_bo *bo; + + bo_base =list_first_entry (&vm->relocated, + struct amdgpu_vm_bo_base, + vm_status); +spin_unlock (&vm->status_lock); + + bo = bo_base->bo->parent; + parent = list_first_entry(&bo->va, struct amdgpu_vm_bo_base, + bo_list); + pt = container_of(parent, struct amdgpu_vm_pt, base); + + r =amdgpu_vm_update_level (adev, vm, pt); +if (r) { +amdgpu_vm_invalidate_level (vm, &vm->root); +break ; + } + +spin_lock (&vm->status_lock); + } +spin_unlock (&vm->status_lock);if (vm->use_cpu_for_update) {/* Flush HDP */
@@ -1575,7 +1597,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, error_free:amdgpu_job_free (job); -amdgpu_vm_invalidate_level (&vm->root); +amdgpu_vm_invalidate_level (vm, &vm->root);return r; }
@@ -2374,9 +2396,13 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,continue ; } -/* Don't add page tables to the moved state */ -if (bo->tbo.type == ttm_bo_type_kernel) +if (bo->tbo.type == ttm_bo_type_kernel) { +spin_lock (&bo_base->vm->status_lock); +if (list_empty (&bo_base->vm_status)) +list_add (&bo_base->vm_status, &vm->relocated); +spin_unlock (&bo_base->vm->status_lock);continue ; + }spin_lock (&bo_base->vm->status_lock);if (list_empty (&bo_base->vm_status))
@@ -2451,6 +2477,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, vm->reserved_vmid[i] =NULL ;spin_lock_init (&vm->status_lock);INIT_LIST_HEAD (&vm->evicted); +INIT_LIST_HEAD (&vm->relocated);INIT_LIST_HEAD (&vm->moved);INIT_LIST_HEAD (&vm->cleared);INIT_LIST_HEAD (&vm->freed);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3 -0
@@ -131,6 +131,9 @@ struct amdgpu_vm {/* BOs who needs a validation */ struct list_head evicted; +/* PT BOs which relocated and their parent need an update */ +struct list_head relocated; +/* BOs moved, but not yet updated in the PT */ struct list_head moved;
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1502376647-4519-8-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherRE: [PATCH 8/8] drm/amdgpu: rework page directory filling
Quoted 7 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Thursday, August 10, 2017 10:51 AM
To: [email protected]
Subject: [PATCH 8/8] drm/amdgpu: rework page directory filling
Quoted 5 lines
From: Christian König <[email protected]>
Keep track off relocated PDs/PTs instead of walking and checking all PDs.
Signed-off-by Christian König <[email protected]>
Some comments on patch 4. The rest are:
Quoted 227 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 85 ++++++++++++++++++++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 ++ 2 files changed, 59 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-3@@ -204,7 +204,10 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, } spin_lock(&vm->status_lock); -list_del_init (&bo_base->vm_status); +if (bo->parent) +list_move (&bo_base->vm_status, &vm->relocated); +else +list_del_init (&bo_base->vm_status); }spin_unlock (&vm->status_lock);@@ -303,8 +306,10 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, entry->base.vm = vm; entry->base.bo = pt;list_add_tail (&entry->base.bo_list, &pt->va); -INIT_LIST_HEAD (&entry->base.vm_status); - entry->addr =0 ; +spin_lock (&vm->status_lock); +list_add (&entry->base.vm_status, &vm->relocated); +spin_unlock (&vm->status_lock); + entry->addr = ~0ULL ; }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-4if (level < adev->vm_manager.num_level) {@@ -989,18 +994,17 @@ static int amdgpu_vm_wait_pd(structamdgpu_device *adev, struct amdgpu_vm *vm, */ static int amdgpu_vm_update_level (struct amdgpu_device *adev,struct amdgpu_vm *vm, -struct amdgpu_vm_pt *parent, -unsigned level) +struct amdgpu_vm_pt *parent) {struct amdgpu_bo *shadow;struct amdgpu_ring *ring =NULL ;uint64_t pd_addr, shadow_addr =0 ; -uint32_t incr =amdgpu_vm_bo_size (adev, level +1 );uint64_t last_pde = ~0 , last_pt = ~0 , last_shadow = ~0 ;unsigned count =0 , pt_idx, ndw =0 ;struct amdgpu_job *job;struct amdgpu_pte_update_params params;struct dma_fence *fence =NULL ; +uint32_t incr;int r;@@ -1048,12 +1052,17 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,/* walk over the address space and update the directory */ for (pt_idx = 0; pt_idx <= parent->last_entry_used; ++pt_idx) { -struct amdgpu_bo *bo = parent->entries[pt_idx].base.bo; +struct amdgpu_vm_pt *entry = &parent->entries[pt_idx]; +struct amdgpu_bo *bo = entry->base.bo;uint64_t pde, pt;if (bo ==NULL )continue ; +spin_lock (&vm->status_lock); +list_del_init (&entry->base.vm_status); +spin_unlock (&vm->status_lock); + pt =amdgpu_bo_gpu_offset (bo); pt =amdgpu_gart_get_vm_pde (adev, pt);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0if ((parent->entries[pt_idx].addr & AMDGPU_PDE_PTE) ||@@ -1063,6 +1072,7 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev, parent->entries[pt_idx].addr = pt |AMDGPU_PTE_VALID ; pde = pd_addr + pt_idx *8 ; + incr =amdgpu_bo_size (bo); if (((last_pde + 8 * count) != pde) || ((last_pt + incr * count) != pt) ||drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +31
-19(count == AMDGPU_VM_MAX_UPDATE_SIZE)) {@@ -1123,20 +1133,6 @@ static int amdgpu_vm_update_level(structamdgpu_device *adev,dma_fence_put (fence ); } } -/* -* Recurse into the subdirectories. This recursion is harmless because -* we only have a maximum of 5 layers. -*/ -for (pt_idx =0 ; pt_idx <= parent->last_entry_used; ++pt_idx) { -struct amdgpu_vm_pt *entry = &parent->entries[pt_idx]; - -if (!entry->base.bo) -continue ; - - r =amdgpu_vm_update_level (adev, vm, entry, level +1 ); -if (r) -return r; - }return 0 ;@@ -1152,7 +1148,8 @@ static int amdgpu_vm_update_level(structamdgpu_device *adev, * * Mark all PD level as invalid after an error. */ -static void amdgpu_vm_invalidate_level (struct amdgpu_vm_pt *parent) +static void amdgpu_vm_invalidate_level (struct amdgpu_vm *vm, +struct amdgpu_vm_pt *parent) {unsigned pt_idx;@@ -1167,7 +1164,10 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_vm_pt *parent) continue; entry->addr = ~0ULL ; -amdgpu_vm_invalidate_level (entry); +spin_lock (&vm->status_lock); +list_move (&entry->base.vm_status, &vm->relocated); +spin_unlock (&vm->status_lock); +amdgpu_vm_invalidate_level (vm, entry); } }@@ -1185,9 +1185,31 @@ int amdgpu_vm_update_directories(structamdgpu_device *adev, { int r; - r =amdgpu_vm_update_level (adev, vm, &vm->root,0 ); -if (r) -amdgpu_vm_invalidate_level (&vm->root); +spin_lock (&vm->status_lock); +while (!list_empty (&vm->relocated)) { +struct amdgpu_vm_bo_base *bo_base, *parent; +struct amdgpu_vm_pt *pt; +struct amdgpu_bo *bo; + + bo_base =list_first_entry (&vm->relocated, + struct amdgpu_vm_bo_base, + vm_status); +spin_unlock (&vm->status_lock); + + bo = bo_base->bo->parent; + parent = list_first_entry(&bo->va, struct amdgpu_vm_bo_base, + bo_list); + pt = container_of(parent, struct amdgpu_vm_pt, base); + + r =amdgpu_vm_update_level (adev, vm, pt); +if (r) { +amdgpu_vm_invalidate_level (vm, &vm->root); +break ; + } + +spin_lock (&vm->status_lock); + } +spin_unlock (&vm->status_lock);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7
-3if (vm->use_cpu_for_update) {/* Flush HDP */ @@ -1575,7 +1597,7 @@ static int amdgpu_vm_bo_update_mapping(structamdgpu_device *adev, error_free:amdgpu_job_free (job ); -amdgpu_vm_invalidate_level (&vm->root); +amdgpu_vm_invalidate_level (vm, &vm->root);return r; }@@ -2374,9 +2396,13 @@ void amdgpu_vm_bo_invalidate(structamdgpu_device *adev, continue; } -/* Don't add page tables to the moved state */ -if (bo->tbo.type == ttm_bo_type_kernel) +if (bo->tbo.type == ttm_bo_type_kernel) { +spin_lock (&bo_base->vm->status_lock); +if (list_empty (&bo_base->vm_status)) +list_add (&bo_base->vm_status, &vm- >relocated); +spin_unlock (&bo_base->vm->status_lock);continue ; + }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0spin_lock (&bo_base->vm->status_lock);if (list_empty (&bo_base->vm_status))@@ -2451,6 +2477,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev,struct amdgpu_vm *vm, vm->reserved_vmid[i] = NULL;spin_lock_init (&vm->status_lock);INIT_LIST_HEAD (&vm->evicted); +INIT_LIST_HEAD (&vm->relocated);INIT_LIST_HEAD (&vm->moved);INIT_LIST_HEAD (&vm->cleared);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0INIT_LIST_HEAD (&vm->freed);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3
-1@@ -131,6 +131,9 @@ struct amdgpu_vm {/* BOs who needs a validation */ struct list_head evicted; +/* PT BOs which relocated and their parent need an update */ +struct list_head relocated; +/* BOs moved, but not yet updated in the PT */ struct list_head moved; --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 8/8] drm/amdgpu: rework page directory filling
In reply to a message not in the archiveQuoted 9 lines · Christian König
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-3@@ -1185,9 +1185,31 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, {int r; - r =amdgpu_vm_update_level (adev, vm, &vm->root,0 ); -if (r) -amdgpu_vm_invalidate_level (&vm->root); +spin_lock (&vm->status_lock); +while (!list_empty (&vm->relocated)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_update_directories(struct amdgpu_device *adev, · line 1199
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10
-0+struct amdgpu_vm_bo_base *bo_base, *parent; +struct amdgpu_vm_pt *pt; +struct amdgpu_bo *bo; + + bo_base =list_first_entry (&vm->relocated, + struct amdgpu_vm_bo_base, + vm_status); +spin_unlock (&vm->status_lock); + + bo = bo_base->bo->parent;
For the root page directory I think parent bo->parent will be NULL. Can the root page directory be relocated. If yes, this needs to be handled as a special case here.
Regards,
Felix
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6
-0+ parent = list_first_entry(&bo->va, struct amdgpu_vm_bo_base, + bo_list); + pt = container_of(parent, struct amdgpu_vm_pt, base); + + r =amdgpu_vm_update_level (adev, vm, pt); +if (r) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_update_directories(struct amdgpu_device *adev, · line 1215
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7
-0+amdgpu_vm_invalidate_level (vm, &vm->root); +break ; + } + +spin_lock (&vm->status_lock); + } +spin_unlock (&vm->status_lock);if (vm->use_cpu_for_update) {/* Flush HDP */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx