Skip to contentSkip to conversation

gart table recovery V2

PATCH New Chunming Zhou 2 participants 4 messages Aug 30, 2016 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1472549549-18987-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/2 drm/amdgpu: link all gtt when binding them V2

V2:
spin lock instead of mutex for gtt list

Change-Id I5dc3f9003e706d3a142aadb559bd85f6e0f2a03f
---
 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
index b17916d..6f0af25 100644
@@ -2117,6 +2117,10 @@ struct amdgpu_device {
 	/* link all shadow bo */
 	struct list_head                shadow_list;
 	struct mutex                    shadow_list_lock;
+	/* link all gtt */
+	spinlock_t			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
index 9a6a1a9..a968fc6 100644
@@ -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);
+	spin_lock_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
index 2ba3c8d..0c561c6 100644
@@ -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;
 	}
+	spin_lock(&gtt->adev->gtt_list_lock);
+	list_add_tail(&gtt->list, &gtt->adev->gtt_list);
+	spin_unlock(&gtt->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);
 
+	spin_lock(&gtt->adev->gtt_list_lock);
+	list_del_init(&gtt->list);
+	spin_unlock(&gtt->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(&gtt->list);
 	return &gtt->ttm.ttm;
 }
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 2/2 drm/amdgpu: add gart recovery by gtt list V2

In reply to a message not in the archive

V2:
a. gart recovery should be ahead of ring test.
b. rename to amdgpu_ttm_recover_gart

Change-Id I8daf687d43b51d69f9be36cae8b265deb88e5754
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  5 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 25 +++++++++++++++++++++++++
 3 files changed, 31 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 6f0af25..ddd03d0 100644
@@ -620,6 +620,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_ttm_recover_gart(struct amdgpu_device *adev);
 
 /*
  * GPU MC structures, functions & helpers
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
index a968fc6..3ba17e8 100644
@@ -2230,6 +2230,11 @@ retry:
 	}
 	if (!r) {
 		amdgpu_irq_gpu_reset_resume_helper(adev);
+		if (need_full_reset && amdgpu_need_backup(adev)) {
+			r = amdgpu_ttm_recover_gart(adev);
+			if (r)
+				DRM_ERROR("gart recovery failed!!!\n");
+		}
 		r = amdgpu_ib_ring_tests(adev);
 		if (r) {
 			dev_err(adev->dev, "ib ring test failed (%d).\n", r);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +25 -0
index 0c561c6..45f6c39 100644
@@ -674,6 +674,31 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
 	return 0;
 }
 
+int amdgpu_ttm_recover_gart(struct amdgpu_device *adev)
+{
+	struct amdgpu_ttm_tt *gtt, *tmp;
+	struct ttm_mem_reg bo_mem;
+	uint32_t flags;
+	int r;
+
+	bo_mem.mem_type = TTM_PL_TT;
+	spin_lock(&adev->gtt_list_lock);
+	list_for_each_entry_safe(gtt, tmp, &adev->gtt_list, list) {
+		flags = amdgpu_ttm_tt_pte_flags(gtt->adev, &gtt->ttm.ttm, &bo_mem);
+		r = amdgpu_gart_bind(adev, gtt->offset, gtt->ttm.ttm.num_pages,
+				     gtt->ttm.ttm.pages, gtt->ttm.dma_address,
+				     flags);
+		if (r) {
+			spin_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;
+		}
+	}
+	spin_unlock(&adev->gtt_list_lock);
+	return 0;
+}
+
 static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)
 {
 	struct amdgpu_ttm_tt *gtt = (void *)ttm;
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#4 lore raw
In reply to a message not in the archive

Regards,
Christian.

Am 30.08.2016 um 11:32 schrieb Chunming Zhou:

Quoted 10 lines

save gtt info by list, re-bind gtt after gpu reset. V2:
spinlock instead of mutex.
rename function name.
recover gart table ahead of ring test.

_______________________________________________
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