shadow page table support V4
Subsystems (2)
cover shadow page table support V4
Since we cannot ensure VRAM is consistent after a GPU reset, page table shadowing is necessary. Shadowed page tables are, in a sense, a method to recover the consistent state of the page tables before the reset occurred.
We need to allocate GTT bo as the shadow of VRAM bo when creating page table, and make them the same. After gpu reset, we will need to use SDMA to copy GTT bo content to VRAM bo, then page table will be recoveried.
V2:
Shadow bo uses a shadow entity running on normal run queue, after gpu reset, we need to wait for all shadow jobs finished first, then recovery page table from shadow.
V3:
Addressed Christian comments for shadow bo part.
V4:
Switch back to update page table twice (one of two is for shadow)
Chunming Zhou (10):
drm/amdgpu: add direct submision option for copy_buffer drm/amdgpu: sync bo and shadow V2
drm/amdgpu: implement vm recovery function from shadow V2 drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt drm/amdgpu: link all vm clients
drm/amdgpu: add vm_list_lock
drm/amdgpu: recover page tables after gpu reset drm/amdgpu: add need backup function
drm/amdgpu: add backup condition for vm
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 38 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 43 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 163 +++++++++++++++++++++----- 9 files changed, 257 insertions(+), 40 deletions(-)
Signature · 6 lines
1.9.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): 1471241202-11463-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org
PATCH 1/10 drm/amdgpu: add direct submision option for copy_buffer
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 +++++++++++++++------ 4 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -437,7 +437,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,uint64_t dst_offset, uint32_t byte_count, struct reservation_object *resv, - struct fence **fence); + struct fence **fence, bool direct_submit); int amdgpu_fill_buffer(struct amdgpu_bo *bo, uint32_t src_data, struct reservation_object *resv,
drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +2 -1
@@ -39,7 +39,8 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size, start_jiffies = jiffies;for (i =0 ; i < n; i++) {struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; - r =amdgpu_copy_buffer (ring, saddr, daddr, size,NULL , &fence); + r =amdgpu_copy_buffer (ring, saddr, daddr, size,NULL , &fence, + false);if (r) goto exit_do_move; r =fence_wait (fence, false);
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +2 -2
@@ -111,7 +111,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)amdgpu_bo_kunmap (gtt_obj[i]); r =amdgpu_copy_buffer (ring, gtt_addr, vram_addr, - size,NULL , &fence); + size,NULL , &fence, false);if (r) {DRM_ERROR ("Failed GTT->VRAM copy %d\n" , i);
@@ -156,7 +156,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)amdgpu_bo_kunmap (vram_obj); r =amdgpu_copy_buffer (ring, vram_addr, gtt_addr, - size,NULL , &fence); + size,NULL , &fence, false);if (r) {DRM_ERROR ("Failed VRAM->GTT copy %d\n" , i);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +15 -6
@@ -286,7 +286,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, r =amdgpu_copy_buffer (ring, old_start, new_start, new_mem->num_pages *PAGE_SIZE ,/* bytes */ - bo->resv, &fence); + bo->resv, &fence, false);if (r)return r;
@@ -1148,7 +1148,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,uint64_t dst_offset, uint32_t byte_count, struct reservation_object *resv, - struct fence **fence) + struct fence **fence, bool direct_submit) { struct amdgpu_device *adev = ring->adev;struct amdgpu_job *job;
@@ -1192,10 +1192,19 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,amdgpu_ring_pad_ib (ring, &job->ibs[0 ]);WARN_ON (job->ibs[0 ].length_dw > num_dw); - r =amdgpu_job_submit (job, ring, &adev->mman.entity, -AMDGPU_FENCE_OWNER_UNDEFINED , fence); -if (r) - goto error_free; +if (direct_submit) { + r =amdgpu_ib_schedule (ring, job->num_ibs, job->ibs, +NULL ,NULL , fence); + job->fence =fence_get (*fence); +if (r) +DRM_ERROR ("Error scheduling IBs (%d)\n" , r); +amdgpu_job_free (job); + }else { + r =amdgpu_job_submit (job, ring, &adev->mman.entity, +AMDGPU_FENCE_OWNER_UNDEFINED , fence); +if (r) + goto error_free; + }return 0 ;
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/10 drm/amdgpu: sync bo and shadow V2
In reply to a message not in the archiveUse shadow flag to judge which direction to sync.
V2:
Don't need bo pin, so remove it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 43 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 ++++ 2 files changed, 48 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +43 -0
@@ -443,6 +443,49 @@ int amdgpu_bo_create(struct amdgpu_device *adev,return r; } +int amdgpu_bo_backup_shadow (struct amdgpu_device *adev, +struct amdgpu_ring *ring, +struct amdgpu_bo *bo, +struct reservation_object *resv, +struct fence **fence, +bool direct) + +{ +struct amdgpu_bo *shadow = bo->shadow; +uint64_t bo_addr, shadow_addr; +int r; + +if (!shadow) +return -EINVAL ; + +if (bo->backup_shadow ==AMDGPU_BO_SHADOW_TO_NONE ) { +DRM_INFO ("No need to backup bo and shadow\n" ); +return 0 ; + } + bo_addr =amdgpu_bo_gpu_offset (bo); + shadow_addr =amdgpu_bo_gpu_offset (bo->shadow); + + r =reservation_object_reserve_shared (bo->tbo.resv); +if (r) + goto err; + +if (bo->backup_shadow &AMDGPU_BO_SHADOW_TO_PARENT ) + r =amdgpu_copy_buffer (ring, shadow_addr, bo_addr, +amdgpu_bo_size (bo), resv, fence, + direct); +else + r =amdgpu_copy_buffer (ring, bo_addr, shadow_addr, +amdgpu_bo_size (bo), resv, fence, + direct); +if (!r) { +amdgpu_bo_fence (bo, *fence, true); + bo->backup_shadow =AMDGPU_BO_SHADOW_TO_NONE ; + } +err: + +return r; +} +int amdgpu_bo_kmap (struct amdgpu_bo *bo,void **ptr) {bool is_iomem;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +5 -0
@@ -155,6 +155,11 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);void amdgpu_bo_fence (struct amdgpu_bo *bo,struct fence *fence,bool shared);u64 amdgpu_bo_gpu_offset (struct amdgpu_bo *bo); +int amdgpu_bo_backup_shadow (struct amdgpu_device *adev, +struct amdgpu_ring *ring, +struct amdgpu_bo *bo, +struct reservation_object *resv, +struct fence **fence,bool direct);/* * sub allocation
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/10 drm/amdgpu: implement vm recovery function from shadow V2
In reply to a message not in the archiveV2:
a. check the pt/pd if evicted, no need to recover for evicted pt/pd bo. b. return fence to caller.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -1010,6 +1010,9 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev, uint64_t addr);void amdgpu_vm_bo_rmv (struct amdgpu_device *adev,struct amdgpu_bo_va *bo_va); +int amdgpu_vm_recover_page_table_from_shadow (struct amdgpu_device *adev, +struct amdgpu_vm *vm, +struct fence **fence);/* * context related structures
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +59 -0
65 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/10 drm/amdgpu: update pd shadow while updating pd
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 55 +++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -882,6 +882,7 @@ struct amdgpu_ring {struct amdgpu_vm_pt {struct amdgpu_bo_list_entry entry;uint64_t addr; +uint64_t shadow_addr; };struct amdgpu_vm {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +37 -18
75 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/10 drm/amdgpu: update pt shadow while updating pt
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +21 -9
@@ -787,13 +787,15 @@ err:* @end: end of GPU address range * @dst: destination address to map to, the next dst inside the function * @flags: mapping flags +* @shadow: update shadow or not * * Update the page tables in the range @start - @end. */ static void amdgpu_vm_update_ptes (struct amdgpu_pte_update_params *params,struct amdgpu_vm *vm,uint64_t start,uint64_t end, -uint64_t dst,uint32_t flags) +uint64_t dst,uint32_t flags, +bool shadow) {const uint64_t mask =AMDGPU_VM_PTE_COUNT -1 ;
@@ -807,7 +809,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,/* initialize the variables */ addr = start; pt_idx = addr >> amdgpu_vm_block_size; - pt = vm->page_tables[pt_idx].entry.robj; + pt = shadow ? vm->page_tables[pt_idx].entry.robj->shadow : + vm->page_tables[pt_idx].entry.robj;if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;
@@ -826,7 +829,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,/* walk over the address space and update the page tables */ while (addr < end) { pt_idx = addr >> amdgpu_vm_block_size; - pt = vm->page_tables[pt_idx].entry.robj; + pt = shadow ? vm->page_tables[pt_idx].entry.robj->shadow : + vm->page_tables[pt_idx].entry.robj;if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;
@@ -870,11 +874,13 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,* @end: last PTE to handle * @dst: addr those PTEs should point to * @flags: hw mapping flags +* @shadow: update shaow or not */ static void amdgpu_vm_frag_ptes (struct amdgpu_pte_update_params *params,struct amdgpu_vm *vm,uint64_t start,uint64_t end, -uint64_t dst,uint32_t flags) +uint64_t dst,uint32_t flags, +bool shadow) {/** * The MC L1 TLB supports variable sized pages, based on a fragment
@@ -906,7 +912,8 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,if (params->src || params->pages_addr || !(flags &AMDGPU_PTE_VALID ) || (frag_start >= frag_end)) { -amdgpu_vm_update_ptes (params, vm, start, end, dst, flags); +amdgpu_vm_update_ptes (params, vm, start, end, dst, + flags, shadow);return ; }
@@ -917,18 +924,19 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,/* handle the 4K area at the beginning */ if (start != frag_start) {amdgpu_vm_update_ptes (params, vm, start, frag_start, - dst, flags); + dst, flags, shadow); dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; }/* handle the area in the middle */ amdgpu_vm_update_ptes (params, vm, frag_start, frag_end, dst, - flags |AMDGPU_PTE_FRAG (frag)); + flags |AMDGPU_PTE_FRAG (frag), shadow);/* handle the 4K area at the end */ if (frag_end != end) { dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; -amdgpu_vm_update_ptes (params, vm, frag_end, end, dst, flags); +amdgpu_vm_update_ptes (params, vm, frag_end, end, dst, + flags, shadow); } }
@@ -1007,6 +1015,9 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, ndw +=2 *10 ; } +/* double ndw, since need to update shadow pt bo as well */ + ndw *=2 ; + r =amdgpu_job_alloc_with_ib (adev, ndw *4 , &job);if (r)return r;
@@ -1026,7 +1037,8 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,if (r) goto error_free; -amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags); +amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags, true); +amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags, false);amdgpu_ring_pad_ib (ring, params.ib);WARN_ON (params.ib->length_dw > ndw);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/10 drm/amdgpu: link all vm clients
In reply to a message not in the archiveAdd vm client to list tail when creating it, move to head while submit to scheduler.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +++ 4 files changed, 15 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +6 -0
@@ -901,6 +901,9 @@ struct amdgpu_vm {/* BO mappings freed, but not yet updated in the PT */ struct list_head freed; +/* vm itself list */ +struct list_head list; +/* contains the page directory */ struct amdgpu_bo *page_directory;unsigned max_pde_used;
@@ -2174,6 +2177,9 @@ struct amdgpu_device {struct kfd_dev *kfd;struct amdgpu_virtualization virtualization; + +/* link all vm clients */ +struct list_head vm_list; };bool amdgpu_device_is_px (struct drm_device *dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +4 -0
@@ -860,7 +860,10 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,static int amdgpu_cs_submit (struct amdgpu_cs_parser *p,union drm_amdgpu_cs *cs) { +struct amdgpu_fpriv *fpriv = p->filp->driver_priv; +struct amdgpu_vm *vm = &fpriv->vm;struct amdgpu_ring *ring = p->job->ring; +struct amdgpu_device *adev = ring->adev;struct amd_sched_entity *entity = &p->ctx->rings[ring->idx].entity;struct amdgpu_job *job;int r;
@@ -883,6 +886,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,trace_amdgpu_cs_ioctl (job);amd_sched_entity_push_job (&job->base); +list_move (&vm->list, &adev->vm_list);return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -1588,6 +1588,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,spin_lock_init (&adev->gc_cac_idx_lock);spin_lock_init (&adev->audio_endpt_idx_lock); +INIT_LIST_HEAD (&adev->vm_list); + adev->rmmio_base =pci_resource_start (adev->pdev,5 ); adev->rmmio_size =pci_resource_len (adev->pdev,5 ); adev->rmmio =ioremap (adev->rmmio_base, adev->rmmio_size);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -0
@@ -1591,6 +1591,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)INIT_LIST_HEAD (&vm->invalidated);INIT_LIST_HEAD (&vm->cleared);INIT_LIST_HEAD (&vm->freed); +INIT_LIST_HEAD (&vm->list); pd_size =amdgpu_vm_directory_size (adev); pd_entries =amdgpu_vm_num_pdes (adev);
@@ -1632,6 +1633,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)if (r) goto error_free_page_directory; vm->last_eviction_counter =atomic64_read (&adev->num_evictions); +list_add_tail (&vm->list, &adev->vm_list);return 0 ;
@@ -1662,6 +1664,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)struct amdgpu_bo_va_mapping *mapping, *tmp;int i; +list_del (&vm->list);amd_sched_entity_fini (vm->entity.sched, &vm->entity);if (!RB_EMPTY_ROOT (&vm->va)) {
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/10 drm/amdgpu: add vm_list_lock
In reply to a message not in the archiveTo lock adev->vm_list.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++++ 4 files changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -2180,6 +2180,7 @@ struct amdgpu_device {/* link all vm clients */ struct list_head vm_list; +spinlock_t vm_list_lock; };bool amdgpu_device_is_px (struct drm_device *dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -886,7 +886,9 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,trace_amdgpu_cs_ioctl (job);amd_sched_entity_push_job (&job->base); +spin_lock (&adev->vm_list_lock);list_move (&vm->list, &adev->vm_list); +spin_unlock (&adev->vm_list_lock);return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
@@ -1589,6 +1589,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,spin_lock_init (&adev->audio_endpt_idx_lock);INIT_LIST_HEAD (&adev->vm_list); +spin_lock_init (&adev->vm_list_lock); adev->rmmio_base =pci_resource_start (adev->pdev,5 ); adev->rmmio_size =pci_resource_len (adev->pdev,5 );
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -0
@@ -1633,7 +1633,9 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)if (r) goto error_free_page_directory; vm->last_eviction_counter =atomic64_read (&adev->num_evictions); +spin_lock (&adev->vm_list_lock);list_add_tail (&vm->list, &adev->vm_list); +spin_unlock (&adev->vm_list_lock);return 0 ;
@@ -1664,7 +1666,9 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)struct amdgpu_bo_va_mapping *mapping, *tmp;int i; +spin_lock (&adev->vm_list_lock);list_del (&vm->list); +spin_unlock (&adev->vm_list_lock);amd_sched_entity_fini (vm->entity.sched, &vm->entity);if (!RB_EMPTY_ROOT (&vm->va)) {
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/10 drm/amdgpu: recover page tables after gpu reset
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +26 -1
@@ -2194,13 +2194,38 @@ retry:if (r) {dev_err (adev->dev,"ib ring test failed (%d).\n" , r); r =amdgpu_suspend (adev); + need_full_reset = true; goto retry; } - +/** +* recovery vm page tables, since we cannot depend on VRAM is +* consistent after gpu full reset. +*/ +if (need_full_reset && !(adev->flags &AMD_IS_APU )) { +struct amdgpu_vm *vm, *tmp; +struct fence *fence =NULL ; + +DRM_INFO ("recover page table from shadow\n" ); +spin_lock (&adev->vm_list_lock); +list_for_each_entry_safe (vm, tmp, &adev->vm_list, list) { +spin_unlock (&adev->vm_list_lock); +amdgpu_vm_recover_page_table_from_shadow (adev, vm, &fence); +spin_lock (&adev->vm_list_lock); + } +spin_unlock (&adev->vm_list_lock); +if (fence) { + r =fence_wait (fence, true); +if (r) +WARN (r,"pt recovery isn't comleted\n" ); + } +fence_put (fence); + }for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) {struct amdgpu_ring *ring = adev->rings[i];if (!ring)continue ; + +DRM_INFO ("ring:%d recover jobs\n" , ring->idx);amd_sched_job_recovery (&ring->sched);kthread_unpark (ring->sched.thread); }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/10 drm/amdgpu: add need backup function
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++++++ 2 files changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -2456,6 +2456,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)/* Common functions */ int amdgpu_gpu_reset (struct amdgpu_device *adev); +bool amdgpu_need_backup (struct amdgpu_device *adev);void amdgpu_pci_config_reset (struct amdgpu_device *adev);bool amdgpu_card_posted (struct amdgpu_device *adev);void amdgpu_update_display_priority (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -0
@@ -2112,6 +2112,14 @@ static int amdgpu_post_soft_reset(struct amdgpu_device *adev)return 0 ; } +bool amdgpu_need_backup (struct amdgpu_device *adev) +{ +if (adev->flags &AMD_IS_APU ) +return false; + +return amdgpu_lockup_timeout >0 ? true : false; +} +/** * amdgpu_gpu_reset - reset the asic *
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/10 drm/amdgpu: add backup condition for vm
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +14 -6
@@ -713,9 +713,11 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev, {int r; - r =amdgpu_vm_update_pd_or_shadow (adev, vm, true); -if (r) -return r; +if (amdgpu_need_backup (adev)) { + r =amdgpu_vm_update_pd_or_shadow (adev, vm, true); +if (r) +return r; + }return amdgpu_vm_update_pd_or_shadow (adev, vm, false); }
@@ -729,6 +731,9 @@ int amdgpu_vm_recover_page_table_from_shadow(struct amdgpu_device *adev,uint32_t domain;int r; +if (!amdgpu_need_backup (adev)) +return 0 ; +if (!vm->page_directory->shadow)return 0 ;
@@ -1037,7 +1042,8 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,if (r) goto error_free; -amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags, true); +if (amdgpu_need_backup (adev)) +amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags, true);amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags, false);amdgpu_ring_pad_ib (ring, params.ib);
@@ -1418,7 +1424,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,AMDGPU_GPU_PAGE_SIZE , true,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_NO_CPU_ACCESS | -AMDGPU_GEM_CREATE_SHADOW , + (amdgpu_need_backup (adev) ? +AMDGPU_GEM_CREATE_SHADOW :0 ), NULL, resv, &pt);if (r) goto error_free;
@@ -1619,7 +1626,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) r =amdgpu_bo_create (adev, pd_size, align, true,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_NO_CPU_ACCESS | -AMDGPU_GEM_CREATE_SHADOW , + (amdgpu_need_backup (adev) ? +AMDGPU_GEM_CREATE_SHADOW :0 ),NULL ,NULL , &vm->page_directory);if (r) goto error_free_sched_entity;
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Ping...
Quoted 51 lines
-----Original Message-----
From: Chunming Zhou [mailto:[email protected]]
Sent: Monday, August 15, 2016 2:07 PM
To: [email protected]
Cc: Zhou, David(ChunMing) <[email protected]>
Subject: [PATCH 00/10] shadow page table support V4Since we cannot ensure VRAM is consistent after a GPU reset, page table shadowing is necessary. Shadowed page tables are, in a sense, a method to recover the consistent state of the page tables before the reset occurred.
We need to allocate GTT bo as the shadow of VRAM bo when creating page table, and make them the same. After gpu reset, we will need to use SDMA to copy GTT bo content to VRAM bo, then page table will be recoveried.
V2:
Shadow bo uses a shadow entity running on normal run queue, after gpu reset, we need to wait for all shadow jobs finished first, then recovery page table from shadow.V3:
Addressed Christian comments for shadow bo part.V4:
Switch back to update page table twice (one of two is for shadow)Chunming Zhou (10):
drm/amdgpu: add direct submision option forcopy_bufferdrm/amdgpu: sync bo and shadow V2
drm/amdgpu: implement vm recovery function from shadow V2 drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt drm/amdgpu: link all vm clients
drm/amdgpu: addvm_list_lock
drm/amdgpu: recover page tables after gpu reset drm/amdgpu: add need backup function
drm/amdgpu: add backup condition for vmdrivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 38 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 43 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 163 +++++++++++++++++++++----- 9 files changed, 257 insertions(+), 40 deletions(-)
Quoted 2 lines
--
1.9.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): BY2PR12MB0632F1E417D92B9A50CD4A80B4130-K//h7OWB4q7Oa05ISQ/[email protected]
Patch #1, #2 and #4 are Reviewed-by: Christian König <[email protected]>.
For patch #5:
Review
Quoted 7 lines
static void amdgpu_vm_update_ptes(struct
amdgpu_pte_update_params*params,
structamdgpu_vm*vm,
uint64_tstart,uint64_tend,(quoted diff) +2
-1- uint64_t dst, uint32_t flags) + uint64_t dst, uint32_t flags, + bool shadow) {
Just put the new parameter into the amdgpu_pte_update_params structur. This way we don't need to change this so much.
Patch #3, #6, #7:
Well first of all you need to squash patch #6 and #7, adding the linked list first and then the lock isn't such a good idea when somebody would bisect this patchset.
Additional to that I wouldn't link the VMs, instead just link all the BOs which have a shadow.
This way we can then later on also use the functionality for user space BOs.
Patch #8: Looks good to me, but need to be rebased on linking the BOs instead of the VM.
Patch #9 and #10: Please reorder those to be at the beginning of the patchset.
And I would add this directly into amdgpu_bo_create_shadow() and then make all other functions depend on if the shadow is allocated or not.
Regards,
Christian.
Am 16.08.2016 um 08:12 schrieb Zhou, David(ChunMing):
Quoted 53 lines
Ping...
Quoted 51 lines
-----Original Message-----
From: Chunming Zhou [mailto:[email protected]]
Sent: Monday, August 15, 2016 2:07 PM
To: [email protected]
Cc: Zhou, David(ChunMing) <[email protected]>
Subject: [PATCH 00/10] shadow page table support V4Since we cannot ensure VRAM is consistent after a GPU reset, page table shadowing is necessary. Shadowed page tables are, in a sense, a method to recover the consistent state of the page tables before the reset occurred.
We need to allocate GTT bo as the shadow of VRAM bo when creating page table, and make them the same. After gpu reset, we will need to use SDMA to copy GTT bo content to VRAM bo, then page table will be recoveried.
V2:
Shadow bo uses a shadow entity running on normal run queue, after gpu reset, we need to wait for all shadow jobs finished first, then recovery page table from shadow.V3:
Addressed Christian comments for shadow bo part.V4:
Switch back to update page table twice (one of two is for shadow)Chunming Zhou (10):
drm/amdgpu: add direct submision option forcopy_bufferdrm/amdgpu: sync bo and shadow V2
drm/amdgpu: implement vm recovery function from shadow V2 drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt drm/amdgpu: link all vm clients
drm/amdgpu: addvm_list_lock
drm/amdgpu: recover page tables after gpu reset drm/amdgpu: add need backup function drm/amdgpu: add backup condition for vmdrivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 38 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 43 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 163 +++++++++++++++++++++----- 9 files changed, 257 insertions(+), 40 deletions(-)
Quoted 6 lines
Quoted 2 lines
--
1.9.1_______________________________________________
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