gart table recovery
Subsystems (2)
save gtt info by list, re-bind gtt after gpu reset.
_______________________________________________
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): 1472547264-26992-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org
PATCH 1/2 drm/amdgpu: link all gtt when binding them
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 +++++++++ 3 files changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
@@ -2117,6 +2117,10 @@ struct amdgpu_device {/* link all shadow bo */ struct list_head shadow_list;struct mutex shadow_list_lock; +/* link all gtt */ +struct mutex gtt_list_lock; +struct list_head gtt_list; + };bool amdgpu_device_is_px (struct drm_device *dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -1591,6 +1591,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,INIT_LIST_HEAD (&adev->shadow_list);mutex_init (&adev->shadow_list_lock); +INIT_LIST_HEAD (&adev->gtt_list); +mutex_init (&adev->gtt_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_ttm.c +9 -0
@@ -521,6 +521,7 @@ struct amdgpu_ttm_tt {spinlock_t guptasklock;struct list_head guptasks;atomic_t mmu_invalidations; +struct list_head list; };int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages)
@@ -667,6 +668,9 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, ttm->num_pages, (unsigned)gtt->offset);return r; } +mutex_lock (>t->adev->gtt_list_lock); +list_add_tail (>t->list, >t->adev->gtt_list); +mutex_unlock (>t->adev->gtt_list_lock);return 0 ; }
@@ -681,6 +685,10 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)if (gtt->userptr)amdgpu_ttm_tt_unpin_userptr (ttm); +mutex_lock (>t->adev->gtt_list_lock); +list_del_init (>t->list); +mutex_unlock (>t->adev->gtt_list_lock); +return 0 ; }
@@ -717,6 +725,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev,kfree (gtt);return NULL ; } +INIT_LIST_HEAD (>t->list);return >t->ttm.ttm; }
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): 1472547264-26992-2-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 1/2] drm/amdgpu: link all gtt when binding them
Am 30.08.2016 um 10:54 schrieb Chunming Zhou:
Quoted 13 lines
Change-Id I5dc3f9003e706d3a142aadb559bd85f6e0f2a03fSigned-off-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 +++++++++ 3 files changed, 16 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 2121
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0@@ -2117,6 +2117,10 @@ struct amdgpu_device {/* link all shadow bo */ struct list_head shadow_list;struct mutex shadow_list_lock; +/* link all gtt */ +struct mutex gtt_list_lock;
I think this time a spin lock should clearly be sufficient here. Or do we block somewhere in the GART code path?
Apart from that the patch looks good to me.
Christian.
Quoted 53 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0+struct list_head gtt_list; + };bool amdgpu_device_is_px (struct drm_device *dev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0@@ -1591,6 +1591,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,INIT_LIST_HEAD (&adev->shadow_list);mutex_init (&adev->shadow_list_lock); +INIT_LIST_HEAD (&adev->gtt_list); +mutex_init (&adev->gtt_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_ttm.c +8
-0@@ -521,6 +521,7 @@ struct amdgpu_ttm_tt {spinlock_t guptasklock;struct list_head guptasks;atomic_t mmu_invalidations; +struct list_head list; };int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages)@@ -667,6 +668,9 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, ttm->num_pages, (unsigned)gtt->offset);return r; } +mutex_lock (>t->adev->gtt_list_lock); +list_add_tail (>t->list, >t->adev->gtt_list); +mutex_unlock (>t->adev->gtt_list_lock);return 0 ; }@@ -681,6 +685,10 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)if (gtt->userptr)amdgpu_ttm_tt_unpin_userptr (ttm); +mutex_lock (>t->adev->gtt_list_lock); +list_del_init (>t->list); +mutex_unlock (>t->adev->gtt_list_lock); +return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev, · line 731
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-0@@ -717,6 +725,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev,kfree (gtt);return NULL ; } +INIT_LIST_HEAD (>t->list);return >t->ttm.ttm; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: add gart recovery by gtt list
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 15 +++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 +------------- 4 files changed, 39 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +15 -0
@@ -607,6 +607,20 @@ struct amdgpu_gart {const struct amdgpu_gart_funcs *gart_funcs; }; +struct amdgpu_ttm_tt { +struct ttm_dma_tt ttm; +struct amdgpu_device *adev; +u64 offset; +uint32_t pte_flags; +uint64_t userptr; +struct mm_struct *usermm; +uint32_t userflags; +spinlock_t guptasklock; +struct list_head guptasks; +atomic_t mmu_invalidations; +struct list_head list; +}; +int amdgpu_gart_table_ram_alloc (struct amdgpu_device *adev);void amdgpu_gart_table_ram_free (struct amdgpu_device *adev);int amdgpu_gart_table_vram_alloc (struct amdgpu_device *adev);
@@ -620,6 +634,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset,int amdgpu_gart_bind (struct amdgpu_device *adev,unsigned offset,int pages,struct page **pagelist,dma_addr_t *dma_addr,uint32_t flags); +int amdgpu_gart_recovery (struct amdgpu_device *adev);/* * GPU MC structures, functions & helpers
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -2247,6 +2247,9 @@ retry:struct fence *fence =NULL , *next =NULL ;DRM_INFO ("recover vram bo from shadow\n" ); + r =amdgpu_gart_recovery (adev); +if (r) +DRM_ERROR ("gart recovery failed!!!\n" );mutex_lock (&adev->shadow_list_lock);list_for_each_entry_safe (bo, tmp, &adev->shadow_list, shadow_list) {amdgpu_recover_vram_from_shadow (adev, ring, bo, &next);
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +20 -0
@@ -302,6 +302,26 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset,return 0 ; } +int amdgpu_gart_recovery (struct amdgpu_device *adev) +{ +struct amdgpu_ttm_tt *gtt, *tmp; +int r; + +mutex_lock (&adev->gtt_list_lock); +list_for_each_entry_safe (gtt, tmp, &adev->gtt_list, list) { + r =amdgpu_gart_bind (adev, gtt->offset, gtt->ttm.ttm.num_pages, + gtt->ttm.ttm.pages, gtt->ttm.dma_address, + gtt->pte_flags); +if (r) { +mutex_unlock (&adev->gtt_list_lock); +DRM_ERROR ("failed to bind %lu pages at 0x%08X\n" , + gtt->ttm.ttm.num_pages, (unsigned )gtt->offset); +return r; + } + } +mutex_unlock (&adev->gtt_list_lock); +return 0 ; +}/** * amdgpu_gart_init - init the driver info for managing the gart *
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -13
@@ -511,19 +511,6 @@ struct amdgpu_ttm_gup_task_list {struct task_struct *task; }; -struct amdgpu_ttm_tt { -struct ttm_dma_tt ttm; -struct amdgpu_device *adev; -u64 offset; -uint64_t userptr; -struct mm_struct *usermm; -uint32_t userflags; -spinlock_t guptasklock; -struct list_head guptasks; -atomic_t mmu_invalidations; -struct list_head list; -}; -int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages) {struct amdgpu_ttm_tt *gtt = (void *)ttm;
@@ -668,6 +655,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, ttm->num_pages, (unsigned)gtt->offset);return r; } + gtt->pte_flags = flags;mutex_lock (>t->adev->gtt_list_lock);list_add_tail (>t->list, >t->adev->gtt_list);mutex_unlock (>t->adev->gtt_list_lock);
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): 1472547264-26992-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: add gart recovery by gtt list
Am 30.08.2016 um 10:54 schrieb Chunming Zhou:
Quoted 74 lines
Change-Id I8daf687d43b51d69f9be36cae8b265deb88e5754Signed-off-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 15 +++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 +------------- 4 files changed, 39 insertions(+), 13 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +15
-0@@ -607,6 +607,20 @@ struct amdgpu_gart {const struct amdgpu_gart_funcs *gart_funcs; }; +struct amdgpu_ttm_tt { +struct ttm_dma_tt ttm; +struct amdgpu_device *adev; +u64 offset; +uint32_t pte_flags; +uint64_t userptr; +struct mm_struct *usermm; +uint32_t userflags; +spinlock_t guptasklock; +struct list_head guptasks; +atomic_t mmu_invalidations; +struct list_head list; +}; +int amdgpu_gart_table_ram_alloc (struct amdgpu_device *adev);void amdgpu_gart_table_ram_free (struct amdgpu_device *adev);int amdgpu_gart_table_vram_alloc (struct amdgpu_device *adev);@@ -620,6 +634,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset,int amdgpu_gart_bind (struct amdgpu_device *adev,unsigned offset,int pages,struct page **pagelist,dma_addr_t *dma_addr,uint32_t flags); +int amdgpu_gart_recovery (struct amdgpu_device *adev);/* * GPU MC structures, functions & helpers drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0@@ -2247,6 +2247,9 @@ retry:struct fence *fence =NULL , *next =NULL ;DRM_INFO ("recover vram bo from shadow\n" ); + r =amdgpu_gart_recovery (adev); +if (r) +DRM_ERROR ("gart recovery failed!!!\n" );mutex_lock (&adev->shadow_list_lock);list_for_each_entry_safe (bo, tmp, &adev->shadow_list, shadow_list) {amdgpu_recover_vram_from_shadow (adev, ring, bo, &next);drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +10
-0@@ -302,6 +302,26 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset,return 0 ; } +int amdgpu_gart_recovery (struct amdgpu_device *adev) +{ +struct amdgpu_ttm_tt *gtt, *tmp; +int r; + +mutex_lock (&adev->gtt_list_lock); +list_for_each_entry_safe (gtt, tmp, &adev->gtt_list, list) { + r =amdgpu_gart_bind (adev, gtt->offset, gtt->ttm.ttm.num_pages, + gtt->ttm.ttm.pages, gtt->ttm.dma_address, + gtt->pte_flags);
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset, · line 324
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +10
-0+if (r) { +mutex_unlock (&adev->gtt_list_lock); +DRM_ERROR ("failed to bind %lu pages at 0x%08X\n" , + gtt->ttm.ttm.num_pages, (unsigned )gtt->offset); +return r; + } + } +mutex_unlock (&adev->gtt_list_lock); +return 0 ; +}
This function would better be in amdgpu_ttm.c, cause it uses the TTM handling internal structures for the recovery.
Call it something like amdgpu_ttm_recover_gart(), this way you also don't need to move the structure.
Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0
-0/** * amdgpu_gart_init - init the driver info for managing the gart * drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-13@@ -511,19 +511,6 @@ struct amdgpu_ttm_gup_task_list {struct task_struct *task; }; -struct amdgpu_ttm_tt { -struct ttm_dma_tt ttm; -struct amdgpu_device *adev; -u64 offset; -uint64_t userptr; -struct mm_struct *usermm; -uint32_t userflags; -spinlock_t guptasklock; -struct list_head guptasks; -atomic_t mmu_invalidations; -struct list_head list; -}; -int amdgpu_ttm_tt_get_user_pages (struct ttm_tt *ttm,struct page **pages) {struct amdgpu_ttm_tt *gtt = (void *)ttm;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, · line 658
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-0@@ -668,6 +655,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, ttm->num_pages, (unsigned)gtt->offset);return r; } + gtt->pte_flags = flags;
No need to save the flags here. When the BO is bound we know that it's mem type is TTM_PL_TT.
Just use a fixed ttm_mem_reg in the backup function with the mem_type set accordingly.
Regards,
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, · line 661
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-0mutex_lock (>t->adev->gtt_list_lock);list_add_tail (>t->list, >t->adev->gtt_list);mutex_unlock (>t->adev->gtt_list_lock);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx