shadow page table support V5 ---> shadow bo support
Subsystems (2)
cover shadow page table support V5 ---> shadow bo support
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)
V5:
make it be gerneic shadow bo support. Address Christian comments.
Chunming Zhou (8):
drm/amdgpu: add need backup function V2 drm/amdgpu: add direct submision option for copy_buffer drm/amdgpu: sync bo and shadow V2
drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt V2 drm/amdgpu: link all shadow bo
drm/amdgpu: implement recovery vram bo from shadow drm/amdgpu: recover vram bo from shadow after gpu reset
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 94 ++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++ 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 | 69 ++++++++++++++------ 8 files changed, 215 insertions(+), 33 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): 1471413919-27166-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org
PATCH 1/8 drm/amdgpu: add need backup function V2
V2:
add checking if need backup in amdgpu_bo_create.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -2445,6 +2445,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
@@ -2109,6 +2109,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 *
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -434,7 +434,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,if (r)return r; -if (flags &AMDGPU_GEM_CREATE_SHADOW ) { +if (amdgpu_need_backup (adev) && (flags &AMDGPU_GEM_CREATE_SHADOW )) { r =amdgpu_bo_create_shadow (adev, size, byte_align, (*bo_ptr));if (r)amdgpu_bo_unref (bo_ptr);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/8 drm/amdgpu: add direct submision option for copy_buffer
In reply to a message not in the archive--- 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 3/8 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 4/8 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/8 drm/amdgpu: update pt shadow while updating pt V2
In reply to a message not in the archiveV2:
move shadow parameter to amdgpu_pte_update_params.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12 -2
@@ -66,6 +66,8 @@ struct amdgpu_pte_update_params {dma_addr_t *pages_addr;/* indirect buffer to fill with commands */ struct amdgpu_ib *ib; +/* indicate upodate pt or its shadow */ +bool shadow; };/**
@@ -748,7 +750,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 = params->shadow ? vm->page_tables[pt_idx].entry.robj->shadow : + vm->page_tables[pt_idx].entry.robj;if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;
@@ -767,7 +770,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 = params->shadow ? vm->page_tables[pt_idx].entry.robj->shadow : + vm->page_tables[pt_idx].entry.robj;if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;
@@ -948,6 +952,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;
@@ -967,6 +974,9 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,if (r) goto error_free; + params.shadow = true; +amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags); + params.shadow = false;amdgpu_vm_frag_ptes (¶ms, vm, start, last +1 , addr, flags);amdgpu_ring_pad_ib (ring, params.ib);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/8 drm/amdgpu: link all shadow bo
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 14 +++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -0
@@ -520,6 +520,7 @@ struct amdgpu_bo {struct ttm_bo_kmap_obj dma_buf_vmap;struct amdgpu_mn *mn;struct list_head mn_list; +struct list_head shadow_list; };#define gem_to_amdgpu_bo (gobj) container_of((gobj), struct amdgpu_bo, gem_base)
@@ -2171,6 +2172,10 @@ struct amdgpu_device {struct kfd_dev *kfd;struct amdgpu_virtualization virtualization; + +/* link all shadow bo */ +struct list_head shadow_list; +spinlock_t shadow_list_lock; };bool amdgpu_device_is_px (struct drm_device *dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -1588,6 +1588,9 @@ 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->shadow_list); +spin_lock_init (&adev->shadow_list_lock); + 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_object.c +13 -1
@@ -313,6 +313,7 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, } bo->adev = adev;INIT_LIST_HEAD (&bo->list); +INIT_LIST_HEAD (&bo->shadow_list);INIT_LIST_HEAD (&bo->va); bo->prefered_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT |
@@ -405,8 +406,12 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,NULL , &placement, bo->tbo.resv, &bo->shadow); -if (!r) +if (!r) { bo->shadow->parent =amdgpu_bo_ref (bo); +spin_lock (&adev->shadow_list_lock); +list_add_tail (&bo->shadow_list, &adev->shadow_list); +spin_unlock (&adev->shadow_list_lock); + }return r; }
@@ -541,6 +546,13 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo)if ((*bo) ==NULL )return ; +/* shadow must be freed before bo itself */ +if ((!(*bo)->shadow) && !list_empty (&(*bo)->shadow_list)) { +spin_lock (&(*bo)->adev->shadow_list_lock); +list_del_init (&(*bo)->shadow_list); +spin_unlock (&(*bo)->adev->shadow_list_lock); + + } tbo = &((*bo)->tbo);ttm_bo_unref (&tbo);if (tbo ==NULL )
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/8 drm/amdgpu: implement recovery vram bo from shadow
In reply to a message not in the archiveIt will be used by gpu reset to recover vram bo.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 35 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 4 ++++ 2 files changed, 39 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +35 -0
@@ -491,6 +491,41 @@ err:return r; } +int amdgpu_bo_recover_vram_from_shadow (struct amdgpu_device *adev, +struct amdgpu_ring *ring, +struct amdgpu_bo *bo, +struct fence **fence) +{ +struct fence *f; +uint32_t domain; +int r; + +if (!bo->shadow) +return 0 ; + + r =amdgpu_bo_reserve (bo, false); +if (r) +return r; + domain =amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type); +/* if bo has been evicted, then no need to recover */ +if (domain ==AMDGPU_GEM_DOMAIN_VRAM ) { + bo->backup_shadow =AMDGPU_BO_SHADOW_TO_PARENT ; + r =amdgpu_bo_backup_shadow (adev, ring, bo, +NULL , &f, true); +if (r) { +DRM_ERROR ("recover page table failed!\n" ); + goto err; + } +if (fence) { +fence_put (*fence); + *fence =fence_get (f); + } + } +err: +amdgpu_bo_unreserve (bo); +return r; +} +int amdgpu_bo_kmap (struct amdgpu_bo *bo,void **ptr) {bool is_iomem;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +4 -0
@@ -160,6 +160,10 @@ int amdgpu_bo_backup_shadow(struct amdgpu_device *adev,struct amdgpu_bo *bo, struct reservation_object *resv, struct fence **fence, bool direct); +int amdgpu_bo_recover_vram_from_shadow (struct amdgpu_device *adev, +struct amdgpu_ring *ring, +struct amdgpu_bo *bo, +struct fence **fence);/* * sub allocation
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/8 drm/amdgpu: recover vram bo from shadow after gpu reset
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +27 -1
@@ -2202,13 +2202,39 @@ 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 &&amdgpu_need_backup (adev)) { +struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; +struct amdgpu_bo *bo, *tmp; +struct fence *fence =NULL ; + +DRM_INFO ("recover vram bo from shadow\n" ); +spin_lock (&adev->shadow_list_lock); +list_for_each_entry_safe (bo, tmp, &adev->shadow_list, shadow_list) { +spin_unlock (&adev->shadow_list_lock); +amdgpu_bo_recover_vram_from_shadow (adev, ring, bo, &fence); +spin_lock (&adev->shadow_list_lock); + } +spin_unlock (&adev->shadow_list_lock); +if (fence) { + r =fence_wait (fence, true); +if (r) +WARN (r,"recovery from shadow 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 #1:
Could be that we need to add another module parameter to control this, but I think for now that should be sufficient.
Patch is Reviewed-by: Christian König <[email protected]>
Patch #2:
Review
Quoted 7 lines
(quoted diff) +7
-0+ 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);
When there is an error you should return the code as well.
Review
Quoted 8 lines
(quoted diff) +6
-0+ } else { + r = amdgpu_job_submit(job, ring, &adev->mman.entity, + AMDGPU_FENCE_OWNER_UNDEFINED, fence); + if (r) + goto error_free; + } return 0;
Just changing this to to "return r;" should be sufficient.
With that fixed the patch is Reviewed-by: Christian König <[email protected]> as well.
Patch #3:
You mentioned that this isn't used during command submission but rather during GPU reset, correct?
In this case I would advise not to use a member in the BO structure to note the backup direction and instead have one function for back and one for restoring the content (or note that as a parameter to the function).
Otherwise we could run into trouble when the CS wants to backup something the GPU reset wants to restore at the same time.
Patch #4: Was already reviewed by me.
Patch #5:
Review
Quoted 2 lines
(quoted diff) +2
-0+ pt = params->shadow ? vm->page_tables[pt_idx].entry.robj->shadow : + vm->page_tables[pt_idx].entry.robj;
You need to double check here if shadows are actually allocated or not. Otherwise we will crash on an APU.
Review
Quoted 3 lines
(quoted diff) +3
-0+ /* double ndw, since need to update shadow pt bo as well */ + ndw *= 2; +
We don't need to double the IB size, but only the number of commands in it (ncmds).
The difference is when we want to write scattered GART entries. In this case I've added the PTEs to the end of the IB.
Patch #6:
Review
Quoted 1 line
(quoted diff) +1
-0+ spinlock_t shadow_list_lock;
We might want to use a mutex here instead. Usually I would agree that a spin lock is better for a linked list, but during the restore process in a GPU reset we probably want to sleep here.
Alternatively you could splice the list to a local version on the stack, grab references to the BOs and then drop the lock during the restore process.
Quoted 4 lines
(quoted diff) +0
-0@@ -541,6 +546,13 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo) if ((*bo) == NULL) return;
Review void amdgpu_bo_unref(struct amdgpu_bo **bo) · line 558
Quoted 10 lines
(quoted diff) +7
-0+ /* shadow must be freed before bo itself */ + if ((!(*bo)->shadow) && !list_empty(&(*bo)->shadow_list)) { + spin_lock(&(*bo)->adev->shadow_list_lock); + list_del_init(&(*bo)->shadow_list); + spin_unlock(&(*bo)->adev->shadow_list_lock); + + } tbo = &((*bo)->tbo); ttm_bo_unref(&tbo); if (tbo == NULL)
That would trigger even when we take a temporary reference. I suggest to add a amdgpu_bo_unref_shadow() function instead, unreferencing both the shadow and the normal BO.
This can then be used in the VM code to cleanup the shadow created.
Going to skip patch #7 and #8 for now cause our team call begins in a moment.
Regards,
Christian.
Am 17.08.2016 um 08:05 schrieb Chunming Zhou:
Quoted 33 lines
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)V5:
make it be gerneic shadow bo support. Address Christian comments.Chunming Zhou (8):
drm/amdgpu: add need backup function V2 drm/amdgpu: add direct submision option forcopy_bufferdrm/amdgpu: sync bo and shadow V2
drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt V2 drm/amdgpu: link all shadow bo
drm/amdgpu: implement recovery vram bo from shadow drm/amdgpu: recover vram bo from shadow after gpu reset
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 94 ++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++ 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 | 69 ++++++++++++++------ 8 files changed, 215 insertions(+), 33 deletions(-)
_______________________________________________
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): 3f0da3d7-ac25-fd73-3b84-d913535512ca-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Why not be consistent and add a DRM_ERROR on all paths that include an error? e.g. instead of
if (r)
goto error_free;
Throw a DRM_ERROR("") in there.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Wednesday, August 17, 2016 10:04
To: Zhou, David(ChunMing); [email protected]
Subject: Re: [PATCH 0/8] shadow page table support V5 ---> shadow bo support
Patch #1:
Could be that we need to add another module parameter to control this, but I think for now that should be sufficient.
Patch is Reviewed-by: Christian König <[email protected]>
Patch #2:
Review
Quoted 7 lines
(quoted diff) +7
-0+ 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);
When there is an error you should return the code as well.
Review
Quoted 8 lines
(quoted diff) +6
-0+ } else { + r = amdgpu_job_submit(job, ring, &adev->mman.entity, + AMDGPU_FENCE_OWNER_UNDEFINED, fence); + if (r) + goto error_free; + } return 0;
Just changing this to to "return r;" should be sufficient.
With that fixed the patch is Reviewed-by: Christian König <[email protected]> as well.
Patch #3:
You mentioned that this isn't used during command submission but rather during GPU reset, correct?
In this case I would advise not to use a member in the BO structure to note the backup direction and instead have one function for back and one for restoring the content (or note that as a parameter to the function).
Otherwise we could run into trouble when the CS wants to backup something the GPU reset wants to restore at the same time.
Patch #4: Was already reviewed by me.
Patch #5:
Review
Quoted 2 lines
(quoted diff) +2
-0+ pt = params->shadow ? vm->page_tables[pt_idx].entry.robj->shadow : + vm->page_tables[pt_idx].entry.robj;
You need to double check here if shadows are actually allocated or not. Otherwise we will crash on an APU.
Review
Quoted 3 lines
(quoted diff) +3
-0+ /* double ndw, since need to update shadow pt bo as well */ + ndw *= 2; +
We don't need to double the IB size, but only the number of commands in it (ncmds).
The difference is when we want to write scattered GART entries. In this case I've added the PTEs to the end of the IB.
Patch #6:
Quoted 1 line
+
spinlock_tshadow_list_lock;
We might want to use a mutex here instead. Usually I would agree that a spin lock is better for a linked list, but during the restore process in a GPU reset we probably want to sleep here.
Alternatively you could splice the list to a local version on the stack, grab references to the BOs and then drop the lock during the restore process.
Quoted 4 lines
(quoted diff) +0
-0@@ -541,6 +546,13 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo) if ((*bo) == NULL) return;
Review void amdgpu_bo_unref(struct amdgpu_bo **bo) · line 558
Quoted 10 lines
(quoted diff) +7
-0+ /* shadow must be freed before bo itself */ + if ((!(*bo)->shadow) && !list_empty(&(*bo)->shadow_list)) { + spin_lock(&(*bo)->adev->shadow_list_lock); + list_del_init(&(*bo)->shadow_list); + spin_unlock(&(*bo)->adev->shadow_list_lock); + + } tbo = &((*bo)->tbo); ttm_bo_unref(&tbo); if (tbo == NULL)
That would trigger even when we take a temporary reference. I suggest to add a amdgpu_bo_unref_shadow() function instead, unreferencing both the shadow and the normal BO.
This can then be used in the VM code to cleanup the shadow created.
Going to skip patch #7 and #8 for now cause our team call begins in a moment.
Regards,
Christian.
Am 17.08.2016 um 08:05 schrieb Chunming Zhou:
Quoted 33 lines
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)V5:
make it be gerneic shadow bo support. Address Christian comments.Chunming Zhou (8):
drm/amdgpu: add need backup function V2 drm/amdgpu: add direct submision option forcopy_bufferdrm/amdgpu: sync bo and shadow V2
drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt V2 drm/amdgpu: link all shadow bo
drm/amdgpu: implement recovery vram bo from shadow drm/amdgpu: recover vram bo from shadow after gpu reset
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 94 ++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++ 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 | 69 ++++++++++++++------ 8 files changed, 215 insertions(+), 33 deletions(-)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - lists.freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...
_______________________________________________
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): DM5PR12MB1132177CBD3C3B4630BDE2F9F7140-2J9CzHegvk+UzrhdoDeimQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Errors should actually be reported by the caller, not here.
So we should probably remove that DRM_ERROR here as well.
Christian.
Am 17.08.2016 um 16:10 schrieb StDenis, Tom:
Quoted 171 lines
Why not be consistent and add a
DRM_ERRORon all paths that include an error? e.g. instead ofif (r)
goto error_free;Throw a
DRM_ERROR("")in there.Tom
------------------------------------------------------------------------
*From:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]> *Sent:* Wednesday, August 17, 2016 10:04
*To:* Zhou, David(ChunMing); [email protected]
*Subject:* Re: [PATCH 0/8] shadow page table support V5 ---> shadow bo support
Patch #1:Could be that we need to add another module parameter to control this, but I think for now that should be sufficient.
Patch is Reviewed-by: Christian König <[email protected]>
Patch #2:
Review
Quoted 7 lines
(quoted diff) +7
-0+ 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);When there is an error you should return the code as well.
Review
Quoted 8 lines
(quoted diff) +6
-0+ } else { + r = amdgpu_job_submit(job, ring, &adev->mman.entity, + AMDGPU_FENCE_OWNER_UNDEFINED, fence); + if (r) + goto error_free; + } return 0;Just changing this to to "return r;" should be sufficient.
With that fixed the patch is Reviewed-by: Christian König <[email protected]> as well.
Patch #3:
You mentioned that this isn't used during command submission but rather during GPU reset, correct?
In this case I would advise not to use a member in the BO structure to note the backup direction and instead have one function for back and one for restoring the content (or note that as a parameter to the function).
Otherwise we could run into trouble when the CS wants to backup something the GPU reset wants to restore at the same time.
Patch #4: Was already reviewed by me.
Patch #5:
Quoted 2 lines
+ pt =
params->shadow? vm->page_tables[pt_idx].entry.robj->shadow :
+ vm->page_tables[pt_idx].entry.robj;You need to double check here if shadows are actually allocated or not. Otherwise we will crash on an APU.
Review
Quoted 3 lines
(quoted diff) +3
-0+ /* double ndw, since need to update shadow pt bo as well */ + ndw *= 2; +We don't need to double the IB size, but only the number of commands in it (ncmds).
The difference is when we want to write scattered GART entries. In this case I've added the PTEs to the end of the IB.
Patch #6:
Quoted 1 line
+
spinlock_tshadow_list_lock;We might want to use a mutex here instead. Usually I would agree that a spin lock is better for a linked list, but during the restore process in a GPU reset we probably want to sleep here.
Alternatively you could splice the list to a local version on the stack, grab references to the BOs and then drop the lock during the restore process.
Quoted 4 lines
(quoted diff) +0
-0@@ -541,6 +546,13 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo) if ((*bo) == NULL) return;Review void amdgpu_bo_unref(struct amdgpu_bo **bo) · line 558
Quoted 10 lines
(quoted diff) +7
-0+ /* shadow must be freed before bo itself */ + if ((!(*bo)->shadow) && !list_empty(&(*bo)->shadow_list)) { + spin_lock(&(*bo)->adev->shadow_list_lock); + list_del_init(&(*bo)->shadow_list); + spin_unlock(&(*bo)->adev->shadow_list_lock); + + } tbo = &((*bo)->tbo); ttm_bo_unref(&tbo); if (tbo == NULL)That would trigger even when we take a temporary reference. I suggest to add a
amdgpu_bo_unref_shadow()function instead, unreferencing both the shadow and the normal BO.This can then be used in the VM code to cleanup the shadow created.
Going to skip patch #7 and #8 for now cause our team call begins in a moment.
Regards,
Christian.Am 17.08.2016 um 08:05 schrieb Chunming Zhou:
Quoted 6 lines
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,
Quoted 1 line
and make them the same. After gpu reset, we will need to use SDMA to
copy GTT bo
Quoted 5 lines
content to VRAM bo, then page table will be recoveried.
V2:
Shadow bo uses a shadow entity running on normal run queue, aftergpu reset,
Quoted 1 line
we need to wait for all shadow jobs finished first, then recovery
page table from shadow.
Quoted 20 lines
V3:
Addressed Christian comments for shadow bo part.V4:
Switch back to update page table twice (one of two is for shadow)V5:
make it be gerneic shadow bo support. Address Christian comments.Chunming Zhou (8):
drm/amdgpu: add need backup function V2 drm/amdgpu: add direct submision option forcopy_bufferdrm/amdgpu: sync bo and shadow V2
drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt V2 drm/amdgpu: link all shadow bo
drm/amdgpu: implement recovery vram bo from shadow drm/amdgpu: recover vram bo from shadow after gpu resetQuoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 94++++++++++++++++++++++++++-
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++ 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 | 69++++++++++++++------
Quoted 2 lines
8 files changed, 215 insertions(+), 33 deletions(-)
Quoted 10 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - lists.freedesktop.org <https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...
_______________________________________________
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): 118a152b-7045-880b-26d6-7405b6148b18-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Yup, either way is fine as long as it's consistent.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Wednesday, August 17, 2016 10:16
To: StDenis, Tom; Zhou, David(ChunMing); [email protected]
Subject: Re: [PATCH 0/8] shadow page table support V5 ---> shadow bo support
Errors should actually be reported by the caller, not here.
So we should probably remove that DRM_ERROR here as well.
Christian.
Am 17.08.2016 um 16:10 schrieb StDenis, Tom:
Why not be consistent and add a DRM_ERROR on all paths that include an error? e.g. instead of
if (r)
goto error_free;
Throw a DRM_ERROR("") in there.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org><mailto:[email protected]> on behalf of Christian König <[email protected]><mailto:[email protected]>
Sent: Wednesday, August 17, 2016 10:04
To: Zhou, David(ChunMing); [email protected]<mailto:[email protected]>
Subject: Re: [PATCH 0/8] shadow page table support V5 ---> shadow bo support
Patch #1:
Could be that we need to add another module parameter to control this, but I think for now that should be sufficient.
Patch is Reviewed-by: Christian König <[email protected]><mailto:[email protected]>
Patch #2:
Review
Quoted 7 lines
(quoted diff) +7
-0+ 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);
When there is an error you should return the code as well.
Review
Quoted 8 lines
(quoted diff) +6
-0+ } else { + r = amdgpu_job_submit(job, ring, &adev->mman.entity, + AMDGPU_FENCE_OWNER_UNDEFINED, fence); + if (r) + goto error_free; + } return 0;
Just changing this to to "return r;" should be sufficient.
With that fixed the patch is Reviewed-by: Christian König <[email protected]><mailto:[email protected]> as well.
Patch #3:
You mentioned that this isn't used during command submission but rather during GPU reset, correct?
In this case I would advise not to use a member in the BO structure to note the backup direction and instead have one function for back and one for restoring the content (or note that as a parameter to the function).
Otherwise we could run into trouble when the CS wants to backup something the GPU reset wants to restore at the same time.
Patch #4: Was already reviewed by me.
Patch #5:
Review
Quoted 2 lines
(quoted diff) +2
-0+ pt = params->shadow ? vm->page_tables[pt_idx].entry.robj->shadow : + vm->page_tables[pt_idx].entry.robj;
You need to double check here if shadows are actually allocated or not. Otherwise we will crash on an APU.
Review
Quoted 3 lines
(quoted diff) +3
-0+ /* double ndw, since need to update shadow pt bo as well */ + ndw *= 2; +
We don't need to double the IB size, but only the number of commands in it (ncmds).
The difference is when we want to write scattered GART entries. In this case I've added the PTEs to the end of the IB.
Patch #6:
Quoted 1 line
+
spinlock_tshadow_list_lock;
We might want to use a mutex here instead. Usually I would agree that a spin lock is better for a linked list, but during the restore process in a GPU reset we probably want to sleep here.
Alternatively you could splice the list to a local version on the stack, grab references to the BOs and then drop the lock during the restore process.
Quoted 4 lines
(quoted diff) +0
-0@@ -541,6 +546,13 @@ void amdgpu_bo_unref(struct amdgpu_bo **bo) if ((*bo) == NULL) return;
Review void amdgpu_bo_unref(struct amdgpu_bo **bo) · line 558
Quoted 10 lines
(quoted diff) +7
-0+ /* shadow must be freed before bo itself */ + if ((!(*bo)->shadow) && !list_empty(&(*bo)->shadow_list)) { + spin_lock(&(*bo)->adev->shadow_list_lock); + list_del_init(&(*bo)->shadow_list); + spin_unlock(&(*bo)->adev->shadow_list_lock); + + } tbo = &((*bo)->tbo); ttm_bo_unref(&tbo); if (tbo == NULL)
That would trigger even when we take a temporary reference. I suggest to add a amdgpu_bo_unref_shadow() function instead, unreferencing both the shadow and the normal BO.
This can then be used in the VM code to cleanup the shadow created.
Going to skip patch #7 and #8 for now cause our team call begins in a moment.
Regards,
Christian.
Am 17.08.2016 um 08:05 schrieb Chunming Zhou:
Quoted 33 lines
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)V5:
make it be gerneic shadow bo support. Address Christian comments.Chunming Zhou (8):
drm/amdgpu: add need backup function V2 drm/amdgpu: add direct submision option forcopy_bufferdrm/amdgpu: sync bo and shadow V2
drm/amdgpu: update pd shadow while updating pd drm/amdgpu: update pt shadow while updating pt V2 drm/amdgpu: link all shadow bo
drm/amdgpu: implement recovery vram bo from shadow drm/amdgpu: recover vram bo from shadow after gpu reset
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 94 ++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 9 +++ 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 | 69 ++++++++++++++------ 8 files changed, 215 insertions(+), 33 deletions(-)
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - lists.freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx