Skip to contentSkip to conversation

drm/amdgpu: remove gart.ready flag

PATCH In review Christian König 4 participants 15 messages Jan 18, 2022 – Jan 21, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
 11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +10 -25
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
  * replaces them with the dummy page (all asics).
  * Returns 0 for success, -EINVAL for failure.
  */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
 			int pages)
 {
 	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
 	uint64_t flags = 0;
 	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
 	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
 	t = offset / AMDGPU_GPU_PAGE_SIZE;
 	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE;
@@ -188,7 +186,6 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
 		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
 
 	drm_dev_exit(idx);
-	return 0;
 }
 
 /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  * Map the dma_addresses into GART entries (all asics).
  * Returns 0 for success, -EINVAL for failure.
  */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
 		    int pages, dma_addr_t *dma_addr, uint64_t flags,
 		    void *dst)
 {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
 	unsigned i, j, t;
 	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
 	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
 	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
 		}
 	}
 	drm_dev_exit(idx);
-	return 0;
 }
 
 /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  * (all asics).
  * Returns 0 for success, -EINVAL for failure.
  */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
 		     int pages, dma_addr_t *dma_addr,
 		     uint64_t flags)
 {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags, adev->gart.ptr);
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -8
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
 	unsigned			num_gpu_pages;
 	unsigned			num_cpu_pages;
 	unsigned			table_size;
-	bool				ready;
 
 	/* Asic default pte flags */
 	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);
 void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);
 int amdgpu_gart_init(struct amdgpu_device *adev);
 void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev);
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
 void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
index 9151950e0cc3..babdd915c4c3 100644
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
  *
  * Re-init the gart for each known BO in the GTT.
  */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
 {
 	struct amdgpu_gtt_node *node;
 	struct drm_mm_node *mm_node;
 	struct amdgpu_device *adev;
-	int r = 0;
 
 	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
 	spin_lock(&mgr->lock);
 	drm_mm_for_each_node(mm_node, &mgr->mm) {
 		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
 	}
 	spin_unlock(&mgr->lock);
 
 	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +22 -55

157 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -2
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
 
 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);
 uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr);
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
 uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
 
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
 			struct dma_fence **fence);
 
 int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo);
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
 uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, uint32_t type);
 
 #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
 		return -EINVAL;
 	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	r = adev->gfxhub.funcs->gart_enable(adev);
 	if (r)
 		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)
 static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
 {
 	uint64_t table_addr;
-	int r, i;
 	u32 field;
+	int i;
 
 	if (adev->gart.bo == NULL) {
 		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
 		return -EINVAL;
 	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
 	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
 	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)
 static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
 {
 	uint64_t table_addr;
-	int r, i;
 	u32 tmp, field;
+	int i;
 
 	if (adev->gart.bo == NULL) {
 		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
 		return -EINVAL;
 	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
 	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
 	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)
 static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
 {
 	uint64_t table_addr;
-	int r, i;
 	u32 tmp, field;
+	int i;
 
 	if (adev->gart.bo == NULL) {
 		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
 		return -EINVAL;
 	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
 	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
 	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
 		return -EINVAL;
 	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	r = adev->gfxhub.funcs->gart_enable(adev);
 	if (r)
 		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
 	DRM_INFO("PTB located at 0x%016llX\n",
 			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring, uint64_t npages,
 
 	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
 	r = amdgpu_job_submit(job, &adev->mman.entity,
 			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
 	if (r)
Signature · 1 line
2.25.1
#1 lore raw

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
- goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
- return r;
-
-skip_pin_bo:

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
 11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +10 -25
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
  * replaces them with the dummy page (all asics).
  * Returns 0 for success, -EINVAL for failure.
  */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
 			int pages)
 {
 	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
 	uint64_t flags = 0;
 	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
 	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
 	t = offset / AMDGPU_GPU_PAGE_SIZE;
 	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE;
@@ -188,7 +186,6 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
 		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
 
 	drm_dev_exit(idx);
-	return 0;
 }
 
 /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  * Map the dma_addresses into GART entries (all asics).
  * Returns 0 for success, -EINVAL for failure.
  */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
 		    int pages, dma_addr_t *dma_addr, uint64_t flags,
 		    void *dst)
 {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
 	unsigned i, j, t;
 	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
 	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
 	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
 		}
 	}
 	drm_dev_exit(idx);
-	return 0;
 }
 
 /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  * (all asics).
  * Returns 0 for success, -EINVAL for failure.
  */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
 		     int pages, dma_addr_t *dma_addr,
 		     uint64_t flags)
 {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags, adev->gart.ptr);
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -7
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
 	unsigned			num_gpu_pages;
 	unsigned			num_cpu_pages;
 	unsigned			table_size;
-	bool				ready;
 
 	/* Asic default pte flags */
 	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);  void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);  int amdgpu_gart_init(struct amdgpu_device *adev);  void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
 void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);  #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
  *
  * Re-init the gart for each known BO in the GTT.
  */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
 {
 	struct amdgpu_gtt_node *node;
 	struct drm_mm_node *mm_node;
 	struct amdgpu_device *adev;
-	int r = 0;
 
 	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
 	spin_lock(&mgr->lock);
 	drm_mm_for_each_node(mm_node, &mgr->mm) {
 		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
 	}
 	spin_unlock(&mgr->lock);
 
 	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -17
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
 		dma_addr_t *dma_addr;
 
 		dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT];
-		r = amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
-				    cpu_addr);
-		if (r)
-			goto error_free;
+		amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags, cpu_addr);
 	} else {
 		dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
 		dma_address += adev->vm_manager.vram_base_offset;
 
 		for (i = 0; i < num_pages; ++i) {
-			r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-					    &dma_address, flags, cpu_addr);
-			if (r)
-				goto error_free;
-
+			amdgpu_gart_map(adev, i << PAGE_SHIFT, 1, &dma_address,
+					flags, cpu_addr);
 			dma_address += PAGE_SIZE;
 		}
 	}
@@ -826,14 +820,13 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-				struct ttm_buffer_object *tbo,
-				uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+				 struct ttm_buffer_object *tbo,
+				 uint64_t flags)
 {
 	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
 	struct ttm_tt *ttm = tbo->ttm;
 	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
 	if (amdgpu_bo_encrypted(abo))
 		flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
 	if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
 		uint64_t page_idx = 1;
 
-		r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-				gtt->ttm.dma_address, flags);
-		if (r)
-			goto gart_bind_fail;
+		amdgpu_gart_bind(adev, gtt->offset, page_idx,
+				 gtt->ttm.dma_address, flags);
 
 		/* The memory type of the first page defaults to UC. Now
 		 * modify the memory type to NC from the second page of @@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,

flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK; flags |= AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

- r = amdgpu_gart_bind(adev,
- gtt->offset + (page_idx << PAGE_SHIFT),
- ttm->num_pages - page_idx,
- &(gtt->ttm.dma_address[page_idx]), flags);
+ amdgpu_gart_bind(adev, gtt->offset + (page_idx << PAGE_SHIFT),
+ ttm->num_pages - page_idx,
+ &(gtt->ttm.dma_address[page_idx]), flags);
} else {
- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
- gtt->ttm.dma_address, flags);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+ gtt->ttm.dma_address, flags);
}
-
-gart_bind_fail:
- if (r)
- DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
- ttm->num_pages, gtt->offset);
-
- return r;
}

/*
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
struct amdgpu_ttm_tt *gtt = (void*)ttm;
uint64_t flags;
- int r = 0;
+ int r;

if (!bo_mem)
return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,

/* bind pages into GART page tables */ gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
- gtt->ttm.dma_address, flags);
-
- if (r)
- DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
- ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+ gtt->ttm.dma_address, flags);
gtt->bound = true;
- return r;
+ return 0;
}

/*
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)

/* Bind pages */
gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
- ttm_resource_free(bo, &tmp);
- return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
amdgpu_gart_invalidate_tlb(adev);
ttm_resource_free(bo, &bo->resource); ttm_bo_assign_mem(bo, tmp);
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
* Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to
* rebind GTT pages during a GPU reset.
*/
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
{
struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); uint64_t flags;
- int r;

if (!tbo->ttm)
- return 0;
+ return;

flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;
+ amdgpu_ttm_gart_bind(adev, tbo, flags);
}

/*
@@ -1032,7 +1003,6 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {
struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;

/* if the pages have userptr pinning then clear that first */ if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
return;

/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
- DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
- gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
gtt->bound = false;
}

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
 
 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);  uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
 uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
 
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
 			struct dma_fence **fence);
 
 int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
 uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, uint32_t type);
 
 #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
 		return -EINVAL;
 	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	r = adev->gfxhub.funcs->gart_enable(adev);
 	if (r)
 		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)  {
 	uint64_t table_addr;
-	int r, i;
 	u32 field;
+	int i;
 
 	if (adev->gart.bo == NULL) {
 		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
 		return -EINVAL;
 	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
 	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
 	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)  {
 	uint64_t table_addr;
-	int r, i;
 	u32 tmp, field;
+	int i;
 
 	if (adev->gart.bo == NULL) {
 		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
 		return -EINVAL;
 	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
 	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
 	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)  {
 	uint64_t table_addr;
-	int r, i;
 	u32 tmp, field;
+	int i;
 
 	if (adev->gart.bo == NULL) {
 		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
 		return -EINVAL;
 	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
 	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
 	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
 		 (unsigned)(adev->gmc.gart_size >> 20),
 		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
 		return -EINVAL;
 	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 	r = adev->gfxhub.funcs->gart_enable(adev);
 	if (r)
 		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
 	DRM_INFO("PTB located at 0x%016llX\n",
 			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
 	return 0;
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring, uint64_t npages,
 
 	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
 	r = amdgpu_job_submit(job, &adev->mman.entity,
 			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
 	if (r)

--
2.25.1

#2 lore raw

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -8
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 534 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
  drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
  11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +10 -25
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
   * replaces them with the dummy page (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  			int pages)
  {
  	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  	uint64_t flags = 0;
  	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
  	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
  	t = offset / AMDGPU_GPU_PAGE_SIZE;
  	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE;
@@ -188,7 +186,6 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
 
  	drm_dev_exit(idx);
-	return 0;
  }
 
  /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   * Map the dma_addresses into GART entries (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  		    int pages, dma_addr_t *dma_addr, uint64_t flags,
  		    void *dst)
  {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  	unsigned i, j, t;
  	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
  	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
  	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  		}
  	}
  	drm_dev_exit(idx);
-	return 0;
  }
 
  /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   * (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
  		     int pages, dma_addr_t *dma_addr,
  		     uint64_t flags)
  {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags, adev->gart.ptr);
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -7
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
  	unsigned			num_gpu_pages;
  	unsigned			num_cpu_pages;
  	unsigned			table_size;
-	bool				ready;
 
  	/* Asic default pte flags */
  	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);  void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);  int amdgpu_gart_init(struct amdgpu_device *adev);  void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
  void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);  #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
   *
   * Re-init the gart for each known BO in the GTT.
   */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
  {
  	struct amdgpu_gtt_node *node;
  	struct drm_mm_node *mm_node;
  	struct amdgpu_device *adev;
-	int r = 0;
 
  	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
  	spin_lock(&mgr->lock);
  	drm_mm_for_each_node(mm_node, &mgr->mm) {
  		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
  	}
  	spin_unlock(&mgr->lock);
 
  	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -17
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
  		dma_addr_t *dma_addr;
 
  		dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT];
-		r = amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
-				    cpu_addr);
-		if (r)
-			goto error_free;
+		amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags, cpu_addr);
  	} else {
  		dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
  		dma_address += adev->vm_manager.vram_base_offset;
 
  		for (i = 0; i < num_pages; ++i) {
-			r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-					    &dma_address, flags, cpu_addr);
-			if (r)
-				goto error_free;
-
+			amdgpu_gart_map(adev, i << PAGE_SHIFT, 1, &dma_address,
+					flags, cpu_addr);
  			dma_address += PAGE_SIZE;
  		}
  	}
@@ -826,14 +820,13 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-				struct ttm_buffer_object *tbo,
-				uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+				 struct ttm_buffer_object *tbo,
+				 uint64_t flags)
  {
  	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
  	struct ttm_tt *ttm = tbo->ttm;
  	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
  	if (amdgpu_bo_encrypted(abo))
  		flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
  	if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
  		uint64_t page_idx = 1;
 
-		r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-				gtt->ttm.dma_address, flags);
-		if (r)
-			goto gart_bind_fail;
+		amdgpu_gart_bind(adev, gtt->offset, page_idx,
+				 gtt->ttm.dma_address, flags);
 
  		/* The memory type of the first page defaults to UC. Now
  		 * modify the memory type to NC from the second page of @@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
  		flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
  		flags |= AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +14 -38
-		r = amdgpu_gart_bind(adev,
-				gtt->offset + (page_idx << PAGE_SHIFT),
-				ttm->num_pages - page_idx,
-				&(gtt->ttm.dma_address[page_idx]), flags);
+		amdgpu_gart_bind(adev, gtt->offset + (page_idx << PAGE_SHIFT),
+				 ttm->num_pages - page_idx,
+				 &(gtt->ttm.dma_address[page_idx]), flags);
  	} else {
-		r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-				     gtt->ttm.dma_address, flags);
+		amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+				 gtt->ttm.dma_address, flags);
  	}
-
-gart_bind_fail:
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
-
-	return r;
  }
 
  /*
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
  	struct amdgpu_ttm_tt *gtt = (void*)ttm;
  	uint64_t flags;
-	int r = 0;
+	int r;
 
  	if (!bo_mem)
  		return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
 
  	/* bind pages into GART page tables */
  	gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
-	r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-		gtt->ttm.dma_address, flags);
-
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
+	amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+			 gtt->ttm.dma_address, flags);
  	gtt->bound = true;
-	return r;
+	return 0;
  }
 
  /*
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 
  	/* Bind pages */
  	gtt->offset = (u64)tmp->start << PAGE_SHIFT;
-	r = amdgpu_ttm_gart_bind(adev, bo, flags);
-	if (unlikely(r)) {
-		ttm_resource_free(bo, &tmp);
-		return r;
-	}
-
+	amdgpu_ttm_gart_bind(adev, bo, flags);
  	amdgpu_gart_invalidate_tlb(adev);
  	ttm_resource_free(bo, &bo->resource);
  	ttm_bo_assign_mem(bo, tmp);
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
   * Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to
   * rebind GTT pages during a GPU reset.
   */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
  	uint64_t flags;
-	int r;
 
  	if (!tbo->ttm)
-		return 0;
+		return;
 
  	flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
-	r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
-	return r;
+	amdgpu_ttm_gart_bind(adev, tbo, flags);
  }
 
  /*
@@ -1032,7 +1003,6 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
  	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
  	/* if the pages have userptr pinning then clear that first */
  	if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
  		return;
 
  	/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
-	r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
-	if (r)
-		DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-			  gtt->ttm.num_pages, gtt->offset);
+	amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
  	gtt->bound = false;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
 
  bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);  uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
  uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
 
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
  			struct dma_fence **fence);
 
  int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
  uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, uint32_t type);
 
  #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
  		return -EINVAL;
  	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	r = adev->gfxhub.funcs->gart_enable(adev);
  	if (r)
  		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
  	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 tmp, field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
  	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 tmp, field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
  	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
  		return -EINVAL;
  	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	r = adev->gfxhub.funcs->gart_enable(adev);
  	if (r)
  		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PTB located at 0x%016llX\n",
  			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -5
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring, uint64_t npages,
 
  	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
  	r = amdgpu_job_submit(job, &adev->mman.entity,
  			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
  	if (r)
--

2.25.1

Reviewed-by
#3 lore raw

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -8
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 557 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
  drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
  11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -6
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
   * replaces them with the dummy page (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  			int pages)
  {
  	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  	uint64_t flags = 0;
  	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
  	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
  	t = offset / AMDGPU_GPU_PAGE_SIZE;
  	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6 @@ int 

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

  	drm_dev_exit(idx);
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +7 -19
-	return 0;
  }
 
  /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   * Map the dma_addresses into GART entries (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  		    int pages, dma_addr_t *dma_addr, uint64_t flags,
  		    void *dst)
  {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  	unsigned i, j, t;
  	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
  	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
  	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  		}
  	}
  	drm_dev_exit(idx);
-	return 0;
  }
 
  /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   * (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
  		     int pages, dma_addr_t *dma_addr,
  		     uint64_t flags)
  {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags, 
+adev->gart.ptr);
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -7
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
  	unsigned			num_gpu_pages;
  	unsigned			num_cpu_pages;
  	unsigned			table_size;
-	bool				ready;
 
  	/* Asic default pte flags */
  	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);  void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);  int amdgpu_gart_init(struct amdgpu_device *adev);  void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
  void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);  #endif 
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
index 9151950e0cc3..babdd915c4c3 100644
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
   *
   * Re-init the gart for each known BO in the GTT.
   */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
  {
  	struct amdgpu_gtt_node *node;
  	struct drm_mm_node *mm_node;
  	struct amdgpu_device *adev;
-	int r = 0;
 
  	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
  	spin_lock(&mgr->lock);
  	drm_mm_for_each_node(mm_node, &mgr->mm) {
  		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
  	}
  	spin_unlock(&mgr->lock);
 
  	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -17
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
  		dma_addr_t *dma_addr;
 
  		dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT];
-		r = amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
-				    cpu_addr);
-		if (r)
-			goto error_free;
+		amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags, cpu_addr);
  	} else {
  		dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
  		dma_address += adev->vm_manager.vram_base_offset;
 
  		for (i = 0; i < num_pages; ++i) {
-			r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-					    &dma_address, flags, cpu_addr);
-			if (r)
-				goto error_free;
-
+			amdgpu_gart_map(adev, i << PAGE_SHIFT, 1, &dma_address,
+					flags, cpu_addr);
  			dma_address += PAGE_SIZE;
  		}
  	}
@@ -826,14 +820,13 @@ static void amdgpu_ttm_tt_unpin_userptr(struct 
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-				struct ttm_buffer_object *tbo,
-				uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+				 struct ttm_buffer_object *tbo,
+				 uint64_t flags)
  {
  	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
  	struct ttm_tt *ttm = tbo->ttm;
  	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
  	if (amdgpu_bo_encrypted(abo))
  		flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
  	if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
  		uint64_t page_idx = 1;
 
-		r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-				gtt->ttm.dma_address, flags);
-		if (r)
-			goto gart_bind_fail;
+		amdgpu_gart_bind(adev, gtt->offset, page_idx,
+				 gtt->ttm.dma_address, flags);
 
  		/* The memory type of the first page defaults to UC. Now
  		 * modify the memory type to NC from the second page of @@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
  		flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
  		flags |= AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -21
-		r = amdgpu_gart_bind(adev,
-				gtt->offset + (page_idx << PAGE_SHIFT),
-				ttm->num_pages - page_idx,
-				&(gtt->ttm.dma_address[page_idx]), flags);
+		amdgpu_gart_bind(adev, gtt->offset + (page_idx << PAGE_SHIFT),
+				 ttm->num_pages - page_idx,
+				 &(gtt->ttm.dma_address[page_idx]), flags);
  	} else {
-		r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-				     gtt->ttm.dma_address, flags);
+		amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+				 gtt->ttm.dma_address, flags);
  	}
-
-gart_bind_fail:
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
-
-	return r;
  }
 
  /*
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
  	struct amdgpu_ttm_tt *gtt = (void*)ttm;
  	uint64_t flags;
-	int r = 0;
+	int r;
 
  	if (!bo_mem)
  		return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct 
 ttm_device *bdev,
 
  	/* bind pages into GART page tables */
  	gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
-	r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-		gtt->ttm.dma_address, flags);
-
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
+	amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+			 gtt->ttm.dma_address, flags);
  	gtt->bound = true;
-	return r;
+	return 0;
  }
 

/*

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -6
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
 
  	/* Bind pages */
  	gtt->offset = (u64)tmp->start << PAGE_SHIFT;
-	r = amdgpu_ttm_gart_bind(adev, bo, flags);
-	if (unlikely(r)) {
-		ttm_resource_free(bo, &tmp);
-		return r;
-	}
-
+	amdgpu_ttm_gart_bind(adev, bo, flags);
  	amdgpu_gart_invalidate_tlb(adev);
  	ttm_resource_free(bo, &bo->resource);
  	ttm_bo_assign_mem(bo, tmp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -11
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
   * Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to
   * rebind GTT pages during a GPU reset.
   */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
  	uint64_t flags;
-	int r;
 
  	if (!tbo->ttm)
-		return 0;
+		return;
 
  	flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
-	r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
-	return r;
+	amdgpu_ttm_gart_bind(adev, tbo, flags);
  }
 
  /*
@@ -1032,7 +1003,6 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
  	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
  	/* if the pages have userptr pinning then clear that first */
  	if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
  		return;
 
  	/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
-	r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
-	if (r)
-		DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-			  gtt->ttm.num_pages, gtt->offset);
+	amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
  	gtt->bound = false;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device 
 *adev);
 
  bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);  

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -0
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
  uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
  			struct dma_fence **fence);
 
  int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int 
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
  uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, 
 uint32_t type);
 
  #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
  		return -EINVAL;
  	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	r = adev->gfxhub.funcs->gart_enable(adev);
  	if (r)
  		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
  	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 tmp, field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
  	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 tmp, field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
  	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
  		return -EINVAL;
  	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	r = adev->gfxhub.funcs->gart_enable(adev);
  	if (r)
  		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PTB located at 0x%016llX\n",
  			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring, 
 uint64_t npages,
 
  	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
  	r = amdgpu_job_submit(job, &adev->mman.entity,
  			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);

if (r)
--
2.25.1

Reviewed-by
#4 lore raw

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -8
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 557 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
  drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
  11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -6
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
   * replaces them with the dummy page (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  			int pages)
  {
  	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
  	uint64_t flags = 0;
  	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
  	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
  	t = offset / AMDGPU_GPU_PAGE_SIZE;
  	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6 @@ int 

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

  	drm_dev_exit(idx);
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +7 -19
-	return 0;
  }
 
  /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   * Map the dma_addresses into GART entries (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  		    int pages, dma_addr_t *dma_addr, uint64_t flags,
  		    void *dst)
  {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  	unsigned i, j, t;
  	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
  	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
  	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
  		}
  	}
  	drm_dev_exit(idx);
-	return 0;
  }
 
  /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   * (all asics).
   * Returns 0 for success, -EINVAL for failure.
   */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
  		     int pages, dma_addr_t *dma_addr,
  		     uint64_t flags)
  {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -7
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
  	unsigned			num_gpu_pages;
  	unsigned			num_cpu_pages;
  	unsigned			table_size;
-	bool				ready;
 
  	/* Asic default pte flags */
  	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);  void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);  int amdgpu_gart_init(struct amdgpu_device *adev);  void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
  void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);  #endif 
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
index 9151950e0cc3..babdd915c4c3 100644
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
   *
   * Re-init the gart for each known BO in the GTT.
   */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
  {
  	struct amdgpu_gtt_node *node;
  	struct drm_mm_node *mm_node;
  	struct amdgpu_device *adev;
-	int r = 0;
 
  	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
  	spin_lock(&mgr->lock);
  	drm_mm_for_each_node(mm_node, &mgr->mm) {
  		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
  	}
  	spin_unlock(&mgr->lock);
 
  	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -17
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
  		dma_addr_t *dma_addr;
 
  		dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT];
-		r = amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
-				    cpu_addr);
-		if (r)
-			goto error_free;
+		amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags, cpu_addr);
  	} else {
  		dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
  		dma_address += adev->vm_manager.vram_base_offset;
 
  		for (i = 0; i < num_pages; ++i) {
-			r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-					    &dma_address, flags, cpu_addr);
-			if (r)
-				goto error_free;
-
+			amdgpu_gart_map(adev, i << PAGE_SHIFT, 1, &dma_address,
+					flags, cpu_addr);
  			dma_address += PAGE_SIZE;
  		}
  	}
@@ -826,14 +820,13 @@ static void amdgpu_ttm_tt_unpin_userptr(struct
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-				struct ttm_buffer_object *tbo,
-				uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+				 struct ttm_buffer_object *tbo,
+				 uint64_t flags)
  {
  	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
  	struct ttm_tt *ttm = tbo->ttm;
  	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
  	if (amdgpu_bo_encrypted(abo))
  		flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
  	if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
  		uint64_t page_idx = 1;
 
-		r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-				gtt->ttm.dma_address, flags);
-		if (r)
-			goto gart_bind_fail;
+		amdgpu_gart_bind(adev, gtt->offset, page_idx,
+				 gtt->ttm.dma_address, flags);
 
  		/* The memory type of the first page defaults to UC. Now
  		 * modify the memory type to NC from the second page of @@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
  		flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
  		flags |= AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -21
-		r = amdgpu_gart_bind(adev,
-				gtt->offset + (page_idx << PAGE_SHIFT),
-				ttm->num_pages - page_idx,
-				&(gtt->ttm.dma_address[page_idx]), flags);
+		amdgpu_gart_bind(adev, gtt->offset + (page_idx << PAGE_SHIFT),
+				 ttm->num_pages - page_idx,
+				 &(gtt->ttm.dma_address[page_idx]), flags);
  	} else {
-		r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-				     gtt->ttm.dma_address, flags);
+		amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+				 gtt->ttm.dma_address, flags);
  	}
-
-gart_bind_fail:
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
-
-	return r;
  }
 
  /*
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
  	struct amdgpu_ttm_tt *gtt = (void*)ttm;
  	uint64_t flags;
-	int r = 0;
+	int r;
 
  	if (!bo_mem)
  		return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct 
 ttm_device *bdev,
 
  	/* bind pages into GART page tables */
  	gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
-	r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-		gtt->ttm.dma_address, flags);
-
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
+	amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+			 gtt->ttm.dma_address, flags);
  	gtt->bound = true;
-	return r;
+	return 0;
  }
 

/*

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -6
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
 
  	/* Bind pages */
  	gtt->offset = (u64)tmp->start << PAGE_SHIFT;
-	r = amdgpu_ttm_gart_bind(adev, bo, flags);
-	if (unlikely(r)) {
-		ttm_resource_free(bo, &tmp);
-		return r;
-	}
-
+	amdgpu_ttm_gart_bind(adev, bo, flags);
  	amdgpu_gart_invalidate_tlb(adev);
  	ttm_resource_free(bo, &bo->resource);
  	ttm_bo_assign_mem(bo, tmp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -11
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
   * Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to
   * rebind GTT pages during a GPU reset.
   */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
  	uint64_t flags;
-	int r;
 
  	if (!tbo->ttm)
-		return 0;
+		return;
 
  	flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
-	r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
-	return r;
+	amdgpu_ttm_gart_bind(adev, tbo, flags);
  }
 
  /*
@@ -1032,7 +1003,6 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,  {
  	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
  	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
  	/* if the pages have userptr pinning then clear that first */
  	if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
  		return;
 
  	/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
-	r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
-	if (r)
-		DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-			  gtt->ttm.num_pages, gtt->offset);
+	amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
  	gtt->bound = false;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device 
 *adev);
 
  bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem); 

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -0
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
  uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
  			struct dma_fence **fence);
 
  int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int 
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
  uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, 
 uint32_t type);
 
  #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
  		return -EINVAL;
  	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	r = adev->gfxhub.funcs->gart_enable(adev);
  	if (r)
  		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
  	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 tmp, field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
  	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)  {
  	uint64_t table_addr;
-	int r, i;
  	u32 tmp, field;
+	int i;
 
  	if (adev->gart.bo == NULL) {
  		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
  		return -EINVAL;
  	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
  	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
  		 (unsigned)(adev->gmc.gart_size >> 20),
  		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
  		return -EINVAL;
  	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
  	r = adev->gfxhub.funcs->gart_enable(adev);
  	if (r)
  		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
  	DRM_INFO("PTB located at 0x%016llX\n",
  			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
  	return 0;
  }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring, 
 uint64_t npages,
 
  	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
  	r = amdgpu_job_submit(job, &adev->mman.entity,
  			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);

if (r)
--
2.25.1

maintainer
#5 lore raw

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 605 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -8
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 556 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
   drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
   drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
   drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
   drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
   11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -6
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
    * replaces them with the dummy page (all asics).
    * Returns 0 for success, -EINVAL for failure.
    */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   			int pages)
   {
   	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   	uint64_t flags = 0;
   	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
   	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
   	t = offset / AMDGPU_GPU_PAGE_SIZE;
   	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6 @@ int

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

   		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
   
   	drm_dev_exit(idx);
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +7 -19
-	return 0;
   }
 
   /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
    * Map the dma_addresses into GART entries (all asics).
    * Returns 0 for success, -EINVAL for failure.
    */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   		    int pages, dma_addr_t *dma_addr, uint64_t flags,
   		    void *dst)
   {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   	unsigned i, j, t;
   	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
   	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
   	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   		}
   	}
   	drm_dev_exit(idx);
-	return 0;
   }
 
   /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
    * (all asics).
    * Returns 0 for success, -EINVAL for failure.
    */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
   		     int pages, dma_addr_t *dma_addr,
   		     uint64_t flags)
   {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
   }
 
   /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -7
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
   	unsigned			num_gpu_pages;
   	unsigned			num_cpu_pages;
   	unsigned			table_size;
-	bool				ready;
 
   	/* Asic default pte flags */
   	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);  void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);  int amdgpu_gart_init(struct amdgpu_device *adev);  void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
   void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);  #endif
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
index 9151950e0cc3..babdd915c4c3 100644
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
    *
    * Re-init the gart for each known BO in the GTT.
    */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
   {
   	struct amdgpu_gtt_node *node;
   	struct drm_mm_node *mm_node;
   	struct amdgpu_device *adev;
-	int r = 0;
 
   	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
   	spin_lock(&mgr->lock);
   	drm_mm_for_each_node(mm_node, &mgr->mm) {
   		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
   	}
   	spin_unlock(&mgr->lock);
 
   	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
   }
 
   /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -17
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
   		dma_addr_t *dma_addr;
 
   		dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT];
-		r = amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
-				    cpu_addr);
-		if (r)
-			goto error_free;
+		amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags, cpu_addr);
   	} else {
   		dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
   		dma_address += adev->vm_manager.vram_base_offset;
 
   		for (i = 0; i < num_pages; ++i) {
-			r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-					    &dma_address, flags, cpu_addr);
-			if (r)
-				goto error_free;
-
+			amdgpu_gart_map(adev, i << PAGE_SHIFT, 1, &dma_address,
+					flags, cpu_addr);
   			dma_address += PAGE_SIZE;
   		}
   	}
@@ -826,14 +820,13 @@ static void amdgpu_ttm_tt_unpin_userptr(struct
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-				struct ttm_buffer_object *tbo,
-				uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+				 struct ttm_buffer_object *tbo,
+				 uint64_t flags)
   {
   	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
   	struct ttm_tt *ttm = tbo->ttm;
   	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
   	if (amdgpu_bo_encrypted(abo))
   		flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
   	if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
   		uint64_t page_idx = 1;
 
-		r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-				gtt->ttm.dma_address, flags);
-		if (r)
-			goto gart_bind_fail;
+		amdgpu_gart_bind(adev, gtt->offset, page_idx,
+				 gtt->ttm.dma_address, flags);
 
   		/* The memory type of the first page defaults to UC. Now
   		 * modify the memory type to NC from the second page of @@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
   		flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
   		flags |= AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -21
-		r = amdgpu_gart_bind(adev,
-				gtt->offset + (page_idx << PAGE_SHIFT),
-				ttm->num_pages - page_idx,
-				&(gtt->ttm.dma_address[page_idx]), flags);
+		amdgpu_gart_bind(adev, gtt->offset + (page_idx << PAGE_SHIFT),
+				 ttm->num_pages - page_idx,
+				 &(gtt->ttm.dma_address[page_idx]), flags);
   	} else {
-		r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-				     gtt->ttm.dma_address, flags);
+		amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+				 gtt->ttm.dma_address, flags);
   	}
-
-gart_bind_fail:
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
-
-	return r;
   }
 
   /*
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
   	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
   	struct amdgpu_ttm_tt *gtt = (void*)ttm;
   	uint64_t flags;
-	int r = 0;
+	int r;
 
   	if (!bo_mem)
   		return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct
 ttm_device *bdev,
 
   	/* bind pages into GART page tables */
   	gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
-	r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-		gtt->ttm.dma_address, flags);
-
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
+	amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+			 gtt->ttm.dma_address, flags);
   	gtt->bound = true;
-	return r;
+	return 0;
   }
 
   /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -6
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct
 ttm_buffer_object *bo)
 
   	/* Bind pages */
   	gtt->offset = (u64)tmp->start << PAGE_SHIFT;
-	r = amdgpu_ttm_gart_bind(adev, bo, flags);
-	if (unlikely(r)) {
-		ttm_resource_free(bo, &tmp);
-		return r;
-	}
-
+	amdgpu_ttm_gart_bind(adev, bo, flags);
   	amdgpu_gart_invalidate_tlb(adev);
   	ttm_resource_free(bo, &bo->resource);
   	ttm_bo_assign_mem(bo, tmp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -11
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
    * Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to
    * rebind GTT pages during a GPU reset.
    */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
   {
   	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
   	uint64_t flags;
-	int r;
 
   	if (!tbo->ttm)
-		return 0;
+		return;
 
   	flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
-	r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
-	return r;
+	amdgpu_ttm_gart_bind(adev, tbo, flags);
   }
 
   /*
@@ -1032,7 +1003,6 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,  {
   	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
   	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
   	/* if the pages have userptr pinning then clear that first */
   	if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
   		return;
 
   	/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
-	r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
-	if (r)
-		DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-			  gtt->ttm.num_pages, gtt->offset);
+	amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
   	gtt->bound = false;
   }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device
 *adev);
 
   bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -0
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
   uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager *man);
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
   			struct dma_fence **fence);
 
   int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
   uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev,
 uint32_t type);
 
   #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
   		return -EINVAL;
   	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	r = adev->gfxhub.funcs->gart_enable(adev);
   	if (r)
   		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)  {
   	uint64_t table_addr;
-	int r, i;
   	u32 field;
+	int i;
 
   	if (adev->gart.bo == NULL) {
   		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
   		return -EINVAL;
   	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
   	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
   	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)  {
   	uint64_t table_addr;
-	int r, i;
   	u32 tmp, field;
+	int i;
 
   	if (adev->gart.bo == NULL) {
   		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
   		return -EINVAL;
   	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
   	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
   	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)  {
   	uint64_t table_addr;
-	int r, i;
   	u32 tmp, field;
+	int i;
 
   	if (adev->gart.bo == NULL) {
   		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
   		return -EINVAL;
   	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
   	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
   	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
   		return -EINVAL;
   	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	r = adev->gfxhub.funcs->gart_enable(adev);
   	if (r)
   		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
   	DRM_INFO("PTB located at 0x%016llX\n",
   			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring,
 uint64_t npages,
 
   	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
   	r = amdgpu_job_submit(job, &adev->mman.entity,
   			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
   	if (r)

--
2.25.1

#6 lore raw

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same sdma_access_bo's creation in amdgpu_ttm_init.

In your patch, you introduce a new check of WARN_ON(!adev->gart.ptr)), however, sdma_access_bo targets to create a bo in GTT domain, but adev->gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we change it to VRAM?

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 608 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -8
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 557 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
   drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
   drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
   drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
   drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
   11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -6
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
    * replaces them with the dummy page (all asics).
    * Returns 0 for success, -EINVAL for failure.
    */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   			int pages)
   {
   	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   	uint64_t flags = 0;
   	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
   	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
   	t = offset / AMDGPU_GPU_PAGE_SIZE;
   	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6 @@ int 

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

   		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
   
   	drm_dev_exit(idx);
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +7 -19
-	return 0;
   }
 
   /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
    * Map the dma_addresses into GART entries (all asics).
    * Returns 0 for success, -EINVAL for failure.
    */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   		    int pages, dma_addr_t *dma_addr, uint64_t flags,
   		    void *dst)
   {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   	unsigned i, j, t;
   	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
   	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
   	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
   		}
   	}
   	drm_dev_exit(idx);
-	return 0;
   }
 
   /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
    * (all asics).
    * Returns 0 for success, -EINVAL for failure.
    */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
   		     int pages, dma_addr_t *dma_addr,
   		     uint64_t flags)
   {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
   }
 
   /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -7
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
   	unsigned			num_gpu_pages;
   	unsigned			num_cpu_pages;
   	unsigned			table_size;
-	bool				ready;
 
   	/* Asic default pte flags */
   	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);  void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);  int amdgpu_gart_init(struct amdgpu_device *adev);  void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
   void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);  
 #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
    *
    * Re-init the gart for each known BO in the GTT.
    */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
   {
   	struct amdgpu_gtt_node *node;
   	struct drm_mm_node *mm_node;
   	struct amdgpu_device *adev;
-	int r = 0;
 
   	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
   	spin_lock(&mgr->lock);
   	drm_mm_for_each_node(mm_node, &mgr->mm) {
   		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
   	}
   	spin_unlock(&mgr->lock);
 
   	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
   }
 
   /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -17
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
   		dma_addr_t *dma_addr;
 
   		dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT];
-		r = amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
-				    cpu_addr);
-		if (r)
-			goto error_free;
+		amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags, cpu_addr);
   	} else {
   		dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
   		dma_address += adev->vm_manager.vram_base_offset;
 
   		for (i = 0; i < num_pages; ++i) {
-			r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-					    &dma_address, flags, cpu_addr);
-			if (r)
-				goto error_free;
-
+			amdgpu_gart_map(adev, i << PAGE_SHIFT, 1, &dma_address,
+					flags, cpu_addr);
   			dma_address += PAGE_SIZE;
   		}
   	}
@@ -826,14 +820,13 @@ static void amdgpu_ttm_tt_unpin_userptr(struct
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-				struct ttm_buffer_object *tbo,
-				uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+				 struct ttm_buffer_object *tbo,
+				 uint64_t flags)
   {
   	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
   	struct ttm_tt *ttm = tbo->ttm;
   	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
   	if (amdgpu_bo_encrypted(abo))
   		flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
   	if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
   		uint64_t page_idx = 1;
 
-		r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-				gtt->ttm.dma_address, flags);
-		if (r)
-			goto gart_bind_fail;
+		amdgpu_gart_bind(adev, gtt->offset, page_idx,
+				 gtt->ttm.dma_address, flags);
 
   		/* The memory type of the first page defaults to UC. Now
   		 * modify the memory type to NC from the second page of @@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
   		flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
   		flags |= AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -21
-		r = amdgpu_gart_bind(adev,
-				gtt->offset + (page_idx << PAGE_SHIFT),
-				ttm->num_pages - page_idx,
-				&(gtt->ttm.dma_address[page_idx]), flags);
+		amdgpu_gart_bind(adev, gtt->offset + (page_idx << PAGE_SHIFT),
+				 ttm->num_pages - page_idx,
+				 &(gtt->ttm.dma_address[page_idx]), flags);
   	} else {
-		r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-				     gtt->ttm.dma_address, flags);
+		amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+				 gtt->ttm.dma_address, flags);
   	}
-
-gart_bind_fail:
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
-
-	return r;
   }
 
   /*
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
   	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
   	struct amdgpu_ttm_tt *gtt = (void*)ttm;
   	uint64_t flags;
-	int r = 0;
+	int r;
 
   	if (!bo_mem)
   		return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct 
 ttm_device *bdev,
 
   	/* bind pages into GART page tables */
   	gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
-	r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-		gtt->ttm.dma_address, flags);
-
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
+	amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+			 gtt->ttm.dma_address, flags);
   	gtt->bound = true;
-	return r;
+	return 0;
   }
 
   /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -6
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
 
   	/* Bind pages */
   	gtt->offset = (u64)tmp->start << PAGE_SHIFT;
-	r = amdgpu_ttm_gart_bind(adev, bo, flags);
-	if (unlikely(r)) {
-		ttm_resource_free(bo, &tmp);
-		return r;
-	}
-
+	amdgpu_ttm_gart_bind(adev, bo, flags);
   	amdgpu_gart_invalidate_tlb(adev);
   	ttm_resource_free(bo, &bo->resource);
   	ttm_bo_assign_mem(bo, tmp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -11
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
    * Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to
    * rebind GTT pages during a GPU reset.
    */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
   {
   	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
   	uint64_t flags;
-	int r;
 
   	if (!tbo->ttm)
-		return 0;
+		return;
 
   	flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
-	r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
-	return r;
+	amdgpu_ttm_gart_bind(adev, tbo, flags);
   }
 
   /*
@@ -1032,7 +1003,6 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,  {
   	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
   	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
   	/* if the pages have userptr pinning then clear that first */
   	if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
   		return;
 
   	/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
-	r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
-	if (r)
-		DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-			  gtt->ttm.num_pages, gtt->offset);
+	amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
   	gtt->bound = false;
   }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device 
 *adev);
 
   bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem); 

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr); +void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager
*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
   			struct dma_fence **fence);
 
   int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int 
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
   uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, 
 uint32_t type);
 
   #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
   		return -EINVAL;
   	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	r = adev->gfxhub.funcs->gart_enable(adev);
   	if (r)
   		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)  {
   	uint64_t table_addr;
-	int r, i;
   	u32 field;
+	int i;
 
   	if (adev->gart.bo == NULL) {
   		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
   		return -EINVAL;
   	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
   	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
   	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)  {
   	uint64_t table_addr;
-	int r, i;
   	u32 tmp, field;
+	int i;
 
   	if (adev->gart.bo == NULL) {
   		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
   		return -EINVAL;
   	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
   	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
   	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)  {
   	uint64_t table_addr;
-	int r, i;
   	u32 tmp, field;
+	int i;
 
   	if (adev->gart.bo == NULL) {
   		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
   		return -EINVAL;
   	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
   	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
   	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
   		 (unsigned)(adev->gmc.gart_size >> 20),
   		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
   		return -EINVAL;
   	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
   	r = adev->gfxhub.funcs->gart_enable(adev);
   	if (r)
   		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
   	DRM_INFO("PTB located at 0x%016llX\n",
   			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
   	return 0;
   }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring, 
 uint64_t npages,
 
   	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
   	r = amdgpu_job_submit(job, &adev->mman.entity,
   			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
   	if (r)

--
2.25.1

maintainer
#7 lore raw

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 637 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same sdma_access_bo's creation in amdgpu_ttm_init.

In your patch, you introduce a new check of WARN_ON(!adev->gart.ptr)), however, sdma_access_bo targets to create a bo in GTT domain, but adev->gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we change it to VRAM?

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 608 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -8
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 557 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

The only thing we need to warn about are GART binding before the table is even allocated.

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
    drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------------
    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
    drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
    drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
    drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
    11 files changed, 52 insertions(+), 137 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -6
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
     * replaces them with the dummy page (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
    			int pages)
    {
    	unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
    	uint64_t flags = 0;
    	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to unbind memory from uninitialized GART !\n");
-		return -EINVAL;
-	}
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
    	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
    	t = offset / AMDGPU_GPU_PAGE_SIZE;
    	p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6 @@ int

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

    		amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);
    
    	drm_dev_exit(idx);
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +7 -19
-	return 0;
    }
 
    /**
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
     * Map the dma_addresses into GART entries (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
    		    int pages, dma_addr_t *dma_addr, uint64_t flags,
    		    void *dst)
    {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
    	unsigned i, j, t;
    	int idx;
 
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
    	if (!drm_dev_enter(adev_to_drm(adev), &idx))
-		return 0;
+		return;
 
    	t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
    		}
    	}
    	drm_dev_exit(idx);
-	return 0;
    }
 
    /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
     * (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
    		     int pages, dma_addr_t *dma_addr,
    		     uint64_t flags)
    {
-	if (!adev->gart.ready) {
-		WARN(1, "trying to bind memory to uninitialized GART !\n");
-		return -EINVAL;
-	}
-
-	if (!adev->gart.ptr)
-		return 0;
+	if (WARN_ON(!adev->gart.ptr))
+		return;
 
-	return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-			       adev->gart.ptr);
+	amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
    }
 
    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +7 -7
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
    	unsigned			num_gpu_pages;
    	unsigned			num_cpu_pages;
    	unsigned			table_size;
-	bool				ready;
 
    	/* Asic default pte flags */
    	uint64_t			gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);  void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);  int amdgpu_gart_init(struct amdgpu_device *adev);  void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
-		       int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-		    int pages, dma_addr_t *dma_addr, uint64_t flags,
-		    void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-		     int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
+			int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+		     int pages, dma_addr_t *dma_addr, uint64_t flags,
+		     void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+		      int pages, dma_addr_t *dma_addr, uint64_t flags);
    void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);
 #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -7
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr)
     *
     * Re-init the gart for each known BO in the GTT.
     */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
    {
    	struct amdgpu_gtt_node *node;
    	struct drm_mm_node *mm_node;
    	struct amdgpu_device *adev;
-	int r = 0;
 
    	adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
    	spin_lock(&mgr->lock);
    	drm_mm_for_each_node(mm_node, &mgr->mm) {
    		node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
-		r = amdgpu_ttm_recover_gart(node->tbo);
-		if (r)
-			break;
+		amdgpu_ttm_recover_gart(node->tbo);
    	}
    	spin_unlock(&mgr->lock);
 
    	amdgpu_gart_invalidate_tlb(adev);
-
-	return r;
    }
 
    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -17
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
    		dma_addr_t *dma_addr;
 
    		dma_addr = &bo->ttm->dma_address[mm_cur->start >> PAGE_SHIFT];
-		r = amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
-				    cpu_addr);
-		if (r)
-			goto error_free;
+		amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags, cpu_addr);
    	} else {
    		dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object *bo,
    		dma_address += adev->vm_manager.vram_base_offset;
 
    		for (i = 0; i < num_pages; ++i) {
-			r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-					    &dma_address, flags, cpu_addr);
-			if (r)
-				goto error_free;
-
+			amdgpu_gart_map(adev, i << PAGE_SHIFT, 1, &dma_address,
+					flags, cpu_addr);
    			dma_address += PAGE_SIZE;
    		}
    	}
@@ -826,14 +820,13 @@ static void amdgpu_ttm_tt_unpin_userptr(struct
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-				struct ttm_buffer_object *tbo,
-				uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+				 struct ttm_buffer_object *tbo,
+				 uint64_t flags)
    {
    	struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
    	struct ttm_tt *ttm = tbo->ttm;
    	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
    	if (amdgpu_bo_encrypted(abo))
    		flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
    	if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
    		uint64_t page_idx = 1;
 
-		r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-				gtt->ttm.dma_address, flags);
-		if (r)
-			goto gart_bind_fail;
+		amdgpu_gart_bind(adev, gtt->offset, page_idx,
+				 gtt->ttm.dma_address, flags);
 
    		/* The memory type of the first page defaults to UC. Now
    		 * modify the memory type to NC from the second page of @@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
    		flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
    		flags |= AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -21
-		r = amdgpu_gart_bind(adev,
-				gtt->offset + (page_idx << PAGE_SHIFT),
-				ttm->num_pages - page_idx,
-				&(gtt->ttm.dma_address[page_idx]), flags);
+		amdgpu_gart_bind(adev, gtt->offset + (page_idx << PAGE_SHIFT),
+				 ttm->num_pages - page_idx,
+				 &(gtt->ttm.dma_address[page_idx]), flags);
    	} else {
-		r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-				     gtt->ttm.dma_address, flags);
+		amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+				 gtt->ttm.dma_address, flags);
    	}
-
-gart_bind_fail:
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
-
-	return r;
    }
 
    /*
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
    	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
    	struct amdgpu_ttm_tt *gtt = (void*)ttm;
    	uint64_t flags;
-	int r = 0;
+	int r;
 
    	if (!bo_mem)
    		return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct
 ttm_device *bdev,
 
    	/* bind pages into GART page tables */
    	gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
-	r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-		gtt->ttm.dma_address, flags);
-
-	if (r)
-		DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-			  ttm->num_pages, gtt->offset);
+	amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+			 gtt->ttm.dma_address, flags);
    	gtt->bound = true;
-	return r;
+	return 0;
    }
 
    /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -6
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct
 ttm_buffer_object *bo)
 
    	/* Bind pages */
    	gtt->offset = (u64)tmp->start << PAGE_SHIFT;
-	r = amdgpu_ttm_gart_bind(adev, bo, flags);
-	if (unlikely(r)) {
-		ttm_resource_free(bo, &tmp);
-		return r;
-	}
-
+	amdgpu_ttm_gart_bind(adev, bo, flags);
    	amdgpu_gart_invalidate_tlb(adev);
    	ttm_resource_free(bo, &bo->resource);
    	ttm_bo_assign_mem(bo, tmp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -11
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
     * Called by amdgpu_gtt_mgr_recover() from amdgpu_device_reset() to
     * rebind GTT pages during a GPU reset.
     */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
    {
    	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
    	uint64_t flags;
-	int r;
 
    	if (!tbo->ttm)
-		return 0;
+		return;
 
    	flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
-	r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
-	return r;
+	amdgpu_ttm_gart_bind(adev, tbo, flags);
    }
 
    /*
@@ -1032,7 +1003,6 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,  {
    	struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
    	struct amdgpu_ttm_tt *gtt = (void *)ttm;
-	int r;
 
    	/* if the pages have userptr pinning then clear that first */
    	if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
    		return;
 
    	/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
-	r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
-	if (r)
-		DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-			  gtt->ttm.num_pages, gtt->offset);
+	amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
    	gtt->bound = false;
    }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device
 *adev);
 
    bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr); +void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

uint64_t amdgpu_preempt_mgr_usage(struct ttm_resource_manager
*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
    			struct dma_fence **fence);
 
    int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
    uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev,
 uint32_t type);
 
    #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -10
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
    		return -EINVAL;
    	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
    	r = adev->gfxhub.funcs->gart_enable(adev);
    	if (r)
    		return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
    		 (unsigned)(adev->gmc.gart_size >> 20),
    		 (unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
-
    	return 0;
    }
 
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -5
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)  {
    	uint64_t table_addr;
-	int r, i;
    	u32 field;
+	int i;
 
    	if (adev->gart.bo == NULL) {
    		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
    		return -EINVAL;
    	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
    	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
    	dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n",
    		 (unsigned)(adev->gmc.gart_size >> 20),
    		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
    	return 0;
    }
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -6
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)  {
    	uint64_t table_addr;
-	int r, i;
    	u32 tmp, field;
+	int i;
 
    	if (adev->gart.bo == NULL) {
    		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
    		return -EINVAL;
    	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
    	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
    	/* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
    	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
    		 (unsigned)(adev->gmc.gart_size >> 20),
    		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
    	return 0;
    }
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -6
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)  static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)  {
    	uint64_t table_addr;
-	int r, i;
    	u32 tmp, field;
+	int i;
 
    	if (adev->gart.bo == NULL) {
    		dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
    		return -EINVAL;
    	}
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
    	table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
    	/* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
    	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
    		 (unsigned)(adev->gmc.gart_size >> 20),
    		 (unsigned long long)table_addr);
-	adev->gart.ready = true;
    	return 0;
    }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -9
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
    		return -EINVAL;
    	}
 
-	if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-		goto skip_pin_bo;
-
-	r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
-	if (r)
-		return r;
-
-skip_pin_bo:
+	amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
    	r = adev->gfxhub.funcs->gart_enable(adev);
    	if (r)
    		return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
    	DRM_INFO("PTB located at 0x%016llX\n",
    			(unsigned long long)amdgpu_bo_gpu_offset(adev->gart.bo));
 
-	adev->gart.ready = true;
    	return 0;
    }
 
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring *ring,
 uint64_t npages,
 
    	cpu_addr = &job->ibs[0].ptr[num_dw];
 
-	r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
-	if (r)
-		goto error_free;
-
+	amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
    	r = amdgpu_job_submit(job, &adev->mman.entity,
    			      AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
    	if (r)

--
2.25.1

#8 lore raw

[Public]

Switching to a VRAM bounce buffer can drop performance around 4x~6x on Vega20 over larger access so it's not desired.

Jon

Quoted 722 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: January 20, 2022 9:10 AM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 5 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same

sdma_access_bo's creation in amdgpu_ttm_init.

Quoted 2 lines

In your patch, you introduce a new check of WARN_ON(!adev->gart.ptr)),

however, sdma_access_bo targets to create a bo in GTT domain, but adev-

Quoted 5 lines

gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we

change it to VRAM?

Quoted 12 lines

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Quoted 70 lines

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 62 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))

(quoted diff) +0 -7
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 11 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and

GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The only thing we need to warn about are GART binding before the

table is even allocated.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
    drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------

------

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
    drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
    drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
    drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
    11 files changed, 52 insertions(+), 137 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct

amdgpu_device *adev)

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct · line 153

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
     * replaces them with the dummy page (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -0
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t
+offset,
                          int pages)
    {
          unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 165

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
          uint64_t flags = 0;
          int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to unbind memory from uninitialized GART

!\n");

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 171

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +3 -3
-         return -EINVAL;
- }
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
          if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
          t = offset / AMDGPU_GPU_PAGE_SIZE;
          p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6

@@ int

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 9 lines

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

                  amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

          drm_dev_exit(idx);
- return 0;
    }

    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 204

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
     * Map the dma_addresses into GART entries (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
                      int pages, dma_addr_t *dma_addr, uint64_t flags,
                      void *dst)
    {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
          unsigned i, j, t;
          int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -4
-         return -EINVAL;
- }
-
          if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
          t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
                  }
          }
          drm_dev_exit(idx);
- return 0;
    }
 
    /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 240

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
     * (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 254

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
                       int pages, dma_addr_t *dma_addr,
                       uint64_t flags)
    {
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -7
-         return -EINVAL;
- }
-
- if (!adev->gart.ptr)
-         return 0;
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
- return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-                        adev->gart.ptr);
+ amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
    }
 
    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -1
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
          unsigned                        num_gpu_pages;
          unsigned                        num_cpu_pages;
          unsigned                        table_size;
- bool                            ready;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -0
          /* Asic default pte flags */
          uint64_t                        gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct

amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 57

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -6
-                int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-             int pages, dma_addr_t *dma_addr, uint64_t flags,
-             void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-              int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 59

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
+                 int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 62

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +3 -0
+              int pages, dma_addr_t *dma_addr, uint64_t flags,
+              void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -0
+               int pages, dma_addr_t *dma_addr, uint64_t flags);
    void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);
 #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct

amdgpu_gtt_mgr *mgr)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
     *
     * Re-init the gart for each known BO in the GTT.
     */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
    {
          struct amdgpu_gtt_node *node;
          struct drm_mm_node *mm_node;
          struct amdgpu_device *adev;
- int r = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct · line 236

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
          adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
          spin_lock(&mgr->lock);
          drm_mm_for_each_node(mm_node, &mgr->mm) {
                  node = container_of(mm_node, typeof(*node),

base.mm_nodes[0]);

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -5
-         r = amdgpu_ttm_recover_gart(node->tbo);
-         if (r)
-                 break;
+         amdgpu_ttm_recover_gart(node->tbo);
          }
          spin_unlock(&mgr->lock);
 
          amdgpu_gart_invalidate_tlb(adev);
-
- return r;
    }
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 248

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                  dma_addr_t *dma_addr;
 
                  dma_addr = &bo->ttm->dma_address[mm_cur->start >>

PAGE_SHIFT];

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 249

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-         r = amdgpu_gart_map(adev, 0, num_pages, dma_addr,

flags,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 249

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-                             cpu_addr);
-         if (r)
-                 goto error_free;
+         amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,

cpu_addr);

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
          } else {
                  dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 257

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
                  dma_address += adev->vm_manager.vram_base_offset;
 
                  for (i = 0; i < num_pages; ++i) {
-                 r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-                                     &dma_address, flags, cpu_addr);
-                 if (r)
-                         goto error_free;
-
+                 amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,

&dma_address,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+                                 flags, cpu_addr);
                          dma_address += PAGE_SIZE;
                  }
          }
@@ -826,14 +820,13 @@ static void

amdgpu_ttm_tt_unpin_userptr(struct

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-                         struct ttm_buffer_object *tbo,
-                         uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+                          struct ttm_buffer_object *tbo,
+                          uint64_t flags)
    {
          struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
          struct ttm_tt *ttm = tbo->ttm;
          struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_gart_bind(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
          if (amdgpu_bo_encrypted(abo))
                  flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct

amdgpu_device *adev,

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -4
          if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
                  uint64_t page_idx = 1;
 
-         r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-                         gtt->ttm.dma_address, flags);
-         if (r)
-                 goto gart_bind_fail;
+         amdgpu_gart_bind(adev, gtt->offset, page_idx,
+                          gtt->ttm.dma_address, flags);
 
                  /* The memory type of the first page defaults to UC. Now
                   * modify the memory type to NC from the second page of
(quoted diff) +0 -0
@@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct
 amdgpu_device *adev,
 >>>                   flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
Quoted 1 line
Quoted 1 line
Quoted 1 line
                  flags |=

AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
-         r = amdgpu_gart_bind(adev,
-                         gtt->offset + (page_idx << PAGE_SHIFT),
-                         ttm->num_pages - page_idx,
-                         &(gtt->ttm.dma_address[page_idx]), flags);
+         amdgpu_gart_bind(adev, gtt->offset + (page_idx <<

PAGE_SHIFT),

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -9
+                          ttm->num_pages - page_idx,
+                          &(gtt->ttm.dma_address[page_idx]), flags);
          } else {
-         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-                              gtt->ttm.dma_address, flags);
+         amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                          gtt->ttm.dma_address, flags);
          }
-
-gart_bind_fail:
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
-
- return r;
    }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct

Quoted 2 lines
    /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct

ttm_device *bdev,

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -8
          struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
          struct amdgpu_ttm_tt *gtt = (void*)ttm;
          uint64_t flags;
- int r = 0;
+ int r;
 
          if (!bo_mem)
                  return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct
 ttm_device *bdev,
 
          /* bind pages into GART page tables */
          gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-         gtt->ttm.dma_address, flags);
-
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                  gtt->ttm.dma_address, flags);
          gtt->bound = true;
- return r;
+ return 0;
    }
 
    /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct
 ttm_buffer_object *bo)
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -3
          /* Bind pages */
          gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
-         ttm_resource_free(bo, &tmp);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-         return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
          amdgpu_gart_invalidate_tlb(adev);
          ttm_resource_free(bo, &bo->resource);
          ttm_bo_assign_mem(bo, tmp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct

ttm_buffer_object *bo)

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct · line 980

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
     * Called by amdgpu_gtt_mgr_recover() from

amdgpu_device_reset() to

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -6
     * rebind GTT pages during a GPU reset.
     */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
    {
          struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
          uint64_t flags;
- int r;
 
          if (!tbo->ttm)
-         return 0;
+         return;
 
          flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;
+ amdgpu_ttm_gart_bind(adev, tbo, flags);
    }
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
    /*
@@ -1032,7 +1003,6 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
          struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
          struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
          /* if the pages have userptr pinning then clear that first */
          if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void · line 1024

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                  return;
 
          /* unbind shouldn't be done for GDS/GWS/OA in

ttm_bo_clean_mm */

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
-         DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-                   gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
          gtt->bound = false;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct

amdgpu_device

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
 *adev);
 
    bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr); +void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

uint64_t amdgpu_preempt_mgr_usage(struct

ttm_resource_manager

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
                          struct dma_fence **fence);
 
    int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
    uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev,
 uint32_t type);
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
    #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -8
                  return -EINVAL;
          }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          r = adev->gfxhub.funcs->gart_enable(adev);
          if (r)
                  return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct · line 1027

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -2
- adev->gart.ready = true;
-
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static void gmc_v6_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) {

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
          uint64_t table_addr;
- int r, i;
          u32 field;
+ int i;
 
          if (adev->gart.bo == NULL) {
                  dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                  return -EINVAL;
          }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
          table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct

amdgpu_device *adev)

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct · line 556

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
          dev_info(adev->dev, "PCIE GART of %uM enabled (table at

0x%016llX).\n",

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -1
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)table_addr);
- adev->gart.ready = true;
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -5
          uint64_t table_addr;
- int r, i;
          u32 tmp, field;
+ int i;
 
          if (adev->gart.bo == NULL) {
                  dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                  return -EINVAL;
          }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_gart_enable(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
          /* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
          DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)table_addr);
- adev->gart.ready = true;
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static void gmc_v8_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -5
          uint64_t table_addr;
- int r, i;
          u32 tmp, field;
+ int i;
 
          if (adev->gart.bo == NULL) {
                  dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                  return -EINVAL;
          }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_gart_enable(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
          /* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
          DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)table_addr);
- adev->gart.ready = true;
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -8
                  return -EINVAL;
          }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          r = adev->gfxhub.funcs->gart_enable(adev);
          if (r)
                  return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct · line 1801

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
          DRM_INFO("PTB located at 0x%016llX\n",
                          (unsigned long long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -1
- adev->gart.ready = true;
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_gart_map(struct amdgpu_ring

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring

*ring,

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
 uint64_t npages,
 
          cpu_addr = &job->ibs[0].ptr[num_dw];
 
- r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
- if (r)
-         goto error_free;
-
+ amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
          r = amdgpu_job_submit(job, &adev->mman.entity,
                                AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
          if (r)

--
2.25.1

#9 lore raw

[Public]

Then the most simple direction to drop the calltrace is to put off the creation of this bo after xx_gart_init is called?

Regards,
Guchun

-----Original Message-----
From: Kim, Jonathan <[email protected]>
Sent: Thursday, January 20, 2022 11:05 PM
To: Koenig, Christian <[email protected]>; Chen, Guchun <[email protected]>; Christian König <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Switching to a VRAM bounce buffer can drop performance around 4x~6x on Vega20 over larger access so it's not desired.

Jon

Quoted 730 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: January 20, 2022 9:10 AM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 5 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same

sdma_access_bo's creation in amdgpu_ttm_init.

Quoted 3 lines

In your patch, you introduce a new check of
WARN_ON(!adev->gart.ptr)),

however, sdma_access_bo targets to create a bo in GTT domain, but adev-

Quoted 5 lines

gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we

change it to VRAM?

Quoted 12 lines

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Quoted 71 lines

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 63 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))

(quoted diff) +0 -7
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 12 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and

GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The only thing we need to warn about are GART binding before the

table is even allocated.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
    drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
    drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------

------

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
    drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
    drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
    drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
    drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
    11 files changed, 52 insertions(+), 137 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct

amdgpu_device *adev)

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct · line 153

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
     * replaces them with the dummy page (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -0
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t 
+offset,
                          int pages)
    {
          unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 165

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
          uint64_t flags = 0;
          int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to unbind memory from uninitialized GART

!\n");

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 171

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +3 -3
-         return -EINVAL;
- }
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
          if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
          t = offset / AMDGPU_GPU_PAGE_SIZE;
          p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6

@@ int

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 9 lines

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

                  amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

          drm_dev_exit(idx);
- return 0;
    }

    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 204

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
     * Map the dma_addresses into GART entries (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
                      int pages, dma_addr_t *dma_addr, uint64_t flags,
                      void *dst)
    {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
          unsigned i, j, t;
          int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -4
-         return -EINVAL;
- }
-
          if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
          t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
                  }
          }
          drm_dev_exit(idx);
- return 0;
    }
 
    /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 240

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
     * (all asics).
     * Returns 0 for success, -EINVAL for failure.
     */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 254

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
                       int pages, dma_addr_t *dma_addr,
                       uint64_t flags)
    {
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -7
-         return -EINVAL;
- }
-
- if (!adev->gart.ptr)
-         return 0;
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
- return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-                        adev->gart.ptr);
+ amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
    }
 
    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -1
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
          unsigned                        num_gpu_pages;
          unsigned                        num_cpu_pages;
          unsigned                        table_size;
- bool                            ready;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -0
          /* Asic default pte flags */
          uint64_t                        gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct

amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 57

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -6
-                int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-             int pages, dma_addr_t *dma_addr, uint64_t flags,
-             void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-              int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 59

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
+                 int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 62

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +3 -0
+              int pages, dma_addr_t *dma_addr, uint64_t flags,
+              void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -0
+               int pages, dma_addr_t *dma_addr, uint64_t flags);
    void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev); 
 #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct

amdgpu_gtt_mgr *mgr)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
     *
     * Re-init the gart for each known BO in the GTT.
     */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
    {
          struct amdgpu_gtt_node *node;
          struct drm_mm_node *mm_node;
          struct amdgpu_device *adev;
- int r = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct · line 236

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
          adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
          spin_lock(&mgr->lock);
          drm_mm_for_each_node(mm_node, &mgr->mm) {
                  node = container_of(mm_node, typeof(*node),

base.mm_nodes[0]);

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -5
-         r = amdgpu_ttm_recover_gart(node->tbo);
-         if (r)
-                 break;
+         amdgpu_ttm_recover_gart(node->tbo);
          }
          spin_unlock(&mgr->lock);
 
          amdgpu_gart_invalidate_tlb(adev);
-
- return r;
    }
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
    /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                  dma_addr_t *dma_addr;
 
                  dma_addr = &bo->ttm->dma_address[mm_cur->start 
Quoted 1 line
Quoted 1 line

PAGE_SHIFT];

Quoted 1 line
Quoted 1 line
Quoted 1 line

- r = amdgpu_gart_map(adev, 0, num_pages, dma_addr,

flags,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-                             cpu_addr);
-         if (r)
-                 goto error_free;
+         amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,

cpu_addr);

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 4 lines
          } else {
                  dma_addr_t dma_address;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 258

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
                  dma_address += 
 adev->vm_manager.vram_base_offset;
 
                  for (i = 0; i < num_pages; ++i) {
-                 r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-                                     &dma_address, flags, cpu_addr);
-                 if (r)
-                         goto error_free;
-
+                 amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,

&dma_address,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+                                 flags, cpu_addr);
                          dma_address += PAGE_SIZE;
                  }
          }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -826,14 +820,13 @@ static void

amdgpu_ttm_tt_unpin_userptr(struct

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-                         struct ttm_buffer_object *tbo,
-                         uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+                          struct ttm_buffer_object *tbo,
+                          uint64_t flags)
    {
          struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
          struct ttm_tt *ttm = tbo->ttm;
          struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
          if (amdgpu_bo_encrypted(abo))
                  flags |= AMDGPU_PTE_TMZ; @@ -841,10 +834,8 @@ 

static int amdgpu_ttm_gart_bind(struct

amdgpu_device *adev,

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
          if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
                  uint64_t page_idx = 1;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -4
-         r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-                         gtt->ttm.dma_address, flags);
-         if (r)
-                 goto gart_bind_fail;
+         amdgpu_gart_bind(adev, gtt->offset, page_idx,
+                          gtt->ttm.dma_address, flags);
 
                  /* The memory type of the first page defaults to UC. Now
                   * modify the memory type to NC from the second 

page of

(quoted diff) +0 -0
@@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct 
 amdgpu_device *adev,
 >>>                   flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
Quoted 1 line
Quoted 1 line
Quoted 1 line
                  flags |=

AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
-         r = amdgpu_gart_bind(adev,
-                         gtt->offset + (page_idx << PAGE_SHIFT),
-                         ttm->num_pages - page_idx,
-                         &(gtt->ttm.dma_address[page_idx]), flags);
+         amdgpu_gart_bind(adev, gtt->offset + (page_idx <<

PAGE_SHIFT),

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -9
+                          ttm->num_pages - page_idx,
+                          &(gtt->ttm.dma_address[page_idx]), 
+ flags);
          } else {
-         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-                              gtt->ttm.dma_address, flags);
+         amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                          gtt->ttm.dma_address, flags);
          }
-
-gart_bind_fail:
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
-
- return r;
    }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct

Quoted 2 lines
    /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct

ttm_device *bdev,

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -8
          struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
          struct amdgpu_ttm_tt *gtt = (void*)ttm;
          uint64_t flags;
- int r = 0;
+ int r;
 
          if (!bo_mem)
                  return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct 
 ttm_device *bdev,
 
          /* bind pages into GART page tables */
          gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-         gtt->ttm.dma_address, flags);
-
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                  gtt->ttm.dma_address, flags);
          gtt->bound = true;
- return r;
+ return 0;
    }
 
    /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -3
          /* Bind pages */
          gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
-         ttm_resource_free(bo, &tmp);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-         return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
          amdgpu_gart_invalidate_tlb(adev);
          ttm_resource_free(bo, &bo->resource);
          ttm_bo_assign_mem(bo, tmp); @@ -1006,19 +980,16 @@ int 

amdgpu_ttm_alloc_gart(struct

ttm_buffer_object *bo)

Quoted 1 line
Quoted 1 line
Quoted 1 line

* Called by amdgpu_gtt_mgr_recover() from

amdgpu_device_reset() to

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

* rebind GTT pages during a GPU reset.
*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -3
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
    {
          struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
          uint64_t flags;
- int r;
 
          if (!tbo->ttm)
-         return 0;
+         return;
 
          flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, 

tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;

+ amdgpu_ttm_gart_bind(adev, tbo, flags);
    }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 2 lines
    /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -1032,7 +1003,6 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
          struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
          struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
          /* if the pages have userptr pinning then clear that first */
          if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void · line 1024

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                  return;
 
          /* unbind shouldn't be done for GDS/GWS/OA in

ttm_bo_clean_mm */

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
-         DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-                   gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
          gtt->bound = false;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct

amdgpu_device

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
 *adev);
 
    bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem); 

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr); +void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

uint64_t amdgpu_preempt_mgr_usage(struct

ttm_resource_manager

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
                          struct dma_fence **fence);
 
    int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int 
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
    uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, 
 uint32_t type);
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
    #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -8
                  return -EINVAL;
          }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          r = adev->gfxhub.funcs->gart_enable(adev);
          if (r)
                  return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct · line 1027

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -2
- adev->gart.ready = true;
-
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static void gmc_v6_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) {

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
          uint64_t table_addr;
- int r, i;
          u32 field;
+ int i;
 
          if (adev->gart.bo == NULL) {
                  dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                  return -EINVAL;
          }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
          table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct

amdgpu_device *adev)

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct · line 556

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
          dev_info(adev->dev, "PCIE GART of %uM enabled (table at

0x%016llX).\n",

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -1
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)table_addr);
- adev->gart.ready = true;
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -5
          uint64_t table_addr;
- int r, i;
          u32 tmp, field;
+ int i;
 
          if (adev->gart.bo == NULL) {
                  dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                  return -EINVAL;
          }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_gart_enable(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
          /* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
          DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)table_addr);
- adev->gart.ready = true;
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static void gmc_v8_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -5
          uint64_t table_addr;
- int r, i;
          u32 tmp, field;
+ int i;
 
          if (adev->gart.bo == NULL) {
                  dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                  return -EINVAL;
          }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_gart_enable(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
          /* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
          DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                   (unsigned)(adev->gmc.gart_size >> 20),
                   (unsigned long long)table_addr);
- adev->gart.ready = true;
          return 0;
    }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -8
                  return -EINVAL;
          }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
          r = adev->gfxhub.funcs->gart_enable(adev);
          if (r)
                  return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
          DRM_INFO("PTB located at 0x%016llX\n",
                          (unsigned long 

long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 5 lines
Quoted 5 lines
- adev->gart.ready = true;
          return 0;
    }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_gart_map(struct amdgpu_ring

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring

*ring,

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
 uint64_t npages,
 
          cpu_addr = &job->ibs[0].ptr[num_dw];
 
- r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
- if (r)
-         goto error_free;
-
+ amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
          r = amdgpu_job_submit(job, &adev->mman.entity,
                                AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
          if (r)

--
2.25.1

maintainer
#10 lore raw
In reply to Kim, Jonathan

I think we could remove this warning as well, all we need to do is to make sure that the GART table is always restored from the metadata before it is enabled in hardware.

I've seen that we do this anyway for most hardware generations, but we really need to double check.

Christian.

Am 20.01.22 um 16:04 schrieb Kim, Jonathan:

Quoted 721 lines

[Public]

Switching to a VRAM bounce buffer can drop performance around 4x~6x on Vega20 over larger access so it's not desired.

Jon

Quoted 715 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: January 20, 2022 9:10 AM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 5 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same

sdma_access_bo's creation in amdgpu_ttm_init.

Quoted 1 line

In your patch, you introduce a new check of WARN_ON(!adev->gart.ptr)),

however, sdma_access_bo targets to create a bo in GTT domain, but adev-

Quoted 5 lines

gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we

change it to VRAM?

Quoted 11 lines

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Quoted 70 lines

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 62 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))

(quoted diff) +0 -7
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 11 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and

GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The only thing we need to warn about are GART binding before the

table is even allocated.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
     drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
     drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
     drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
     drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------

------

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
     drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
     drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
     drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
     drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
     drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
     drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
     drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
     11 files changed, 52 insertions(+), 137 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct

amdgpu_device *adev)

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct · line 153

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
      * replaces them with the dummy page (all asics).
      * Returns 0 for success, -EINVAL for failure.
      */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -0
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t
+offset,
                           int pages)
     {
           unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 165

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
           uint64_t flags = 0;
           int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to unbind memory from uninitialized GART

!\n");

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 171

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +3 -3
-         return -EINVAL;
- }
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
           if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
           t = offset / AMDGPU_GPU_PAGE_SIZE;
           p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6

@@ int

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 9 lines

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

                   amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

           drm_dev_exit(idx);
- return 0;
     }

     /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 204

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
      * Map the dma_addresses into GART entries (all asics).
      * Returns 0 for success, -EINVAL for failure.
      */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
                       int pages, dma_addr_t *dma_addr, uint64_t flags,
                       void *dst)
     {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
           unsigned i, j, t;
           int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -4
-         return -EINVAL;
- }
-
           if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
           t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
                   }
           }
           drm_dev_exit(idx);
- return 0;
     }
 
     /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 240

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
      * (all asics).
      * Returns 0 for success, -EINVAL for failure.
      */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 254

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
                        int pages, dma_addr_t *dma_addr,
                        uint64_t flags)
     {
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -7
-         return -EINVAL;
- }
-
- if (!adev->gart.ptr)
-         return 0;
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
- return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-                        adev->gart.ptr);
+ amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
     }
 
     /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -1
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
           unsigned                        num_gpu_pages;
           unsigned                        num_cpu_pages;
           unsigned                        table_size;
- bool                            ready;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -0
           /* Asic default pte flags */
           uint64_t                        gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct

amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 57

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -6
-                int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-             int pages, dma_addr_t *dma_addr, uint64_t flags,
-             void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-              int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 59

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
+                 int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 62

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +3 -0
+              int pages, dma_addr_t *dma_addr, uint64_t flags,
+              void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -0
+               int pages, dma_addr_t *dma_addr, uint64_t flags);
     void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);
 #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct

amdgpu_gtt_mgr *mgr)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
      *
      * Re-init the gart for each known BO in the GTT.
      */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
     {
           struct amdgpu_gtt_node *node;
           struct drm_mm_node *mm_node;
           struct amdgpu_device *adev;
- int r = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct · line 236

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
           adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
           spin_lock(&mgr->lock);
           drm_mm_for_each_node(mm_node, &mgr->mm) {
                   node = container_of(mm_node, typeof(*node),

base.mm_nodes[0]);

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -5
-         r = amdgpu_ttm_recover_gart(node->tbo);
-         if (r)
-                 break;
+         amdgpu_ttm_recover_gart(node->tbo);
           }
           spin_unlock(&mgr->lock);
 
           amdgpu_gart_invalidate_tlb(adev);
-
- return r;
     }
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
     /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 248

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                   dma_addr_t *dma_addr;
 
                   dma_addr = &bo->ttm->dma_address[mm_cur->start >>

PAGE_SHIFT];

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 249

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-         r = amdgpu_gart_map(adev, 0, num_pages, dma_addr,

flags,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 249

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-                             cpu_addr);
-         if (r)
-                 goto error_free;
+         amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,

cpu_addr);

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
           } else {
                   dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 257

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
                   dma_address += adev->vm_manager.vram_base_offset;
 
                   for (i = 0; i < num_pages; ++i) {
-                 r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-                                     &dma_address, flags, cpu_addr);
-                 if (r)
-                         goto error_free;
-
+                 amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,

&dma_address,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+                                 flags, cpu_addr);
                           dma_address += PAGE_SIZE;
                   }
           }
@@ -826,14 +820,13 @@ static void

amdgpu_ttm_tt_unpin_userptr(struct

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-                         struct ttm_buffer_object *tbo,
-                         uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+                          struct ttm_buffer_object *tbo,
+                          uint64_t flags)
     {
           struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
           struct ttm_tt *ttm = tbo->ttm;
           struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_gart_bind(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
           if (amdgpu_bo_encrypted(abo))
                   flags |= AMDGPU_PTE_TMZ;
@@ -841,10 +834,8 @@ static int amdgpu_ttm_gart_bind(struct

amdgpu_device *adev,

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -4
           if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
                   uint64_t page_idx = 1;
 
-         r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-                         gtt->ttm.dma_address, flags);
-         if (r)
-                 goto gart_bind_fail;
+         amdgpu_gart_bind(adev, gtt->offset, page_idx,
+                          gtt->ttm.dma_address, flags);
 
                   /* The memory type of the first page defaults to UC. Now
                    * modify the memory type to NC from the second page of
(quoted diff) +0 -0
@@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct
 amdgpu_device *adev,
 >>>                    flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
Quoted 1 line
Quoted 1 line
Quoted 1 line
                   flags |=

AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
-         r = amdgpu_gart_bind(adev,
-                         gtt->offset + (page_idx << PAGE_SHIFT),
-                         ttm->num_pages - page_idx,
-                         &(gtt->ttm.dma_address[page_idx]), flags);
+         amdgpu_gart_bind(adev, gtt->offset + (page_idx <<

PAGE_SHIFT),

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -9
+                          ttm->num_pages - page_idx,
+                          &(gtt->ttm.dma_address[page_idx]), flags);
           } else {
-         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-                              gtt->ttm.dma_address, flags);
+         amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                          gtt->ttm.dma_address, flags);
           }
-
-gart_bind_fail:
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
-
- return r;
     }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct

Quoted 2 lines
     /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct

ttm_device *bdev,

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -8
           struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
           struct amdgpu_ttm_tt *gtt = (void*)ttm;
           uint64_t flags;
- int r = 0;
+ int r;
 
           if (!bo_mem)
                   return -EINVAL;
@@ -930,14 +913,10 @@ static int amdgpu_ttm_backend_bind(struct
 ttm_device *bdev,
 
           /* bind pages into GART page tables */
           gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-         gtt->ttm.dma_address, flags);
-
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                  gtt->ttm.dma_address, flags);
           gtt->bound = true;
- return r;
+ return 0;
     }
 
     /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct
 ttm_buffer_object *bo)
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -3
           /* Bind pages */
           gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
-         ttm_resource_free(bo, &tmp);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-         return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
           amdgpu_gart_invalidate_tlb(adev);
           ttm_resource_free(bo, &bo->resource);
           ttm_bo_assign_mem(bo, tmp);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -1006,19 +980,16 @@ int amdgpu_ttm_alloc_gart(struct

ttm_buffer_object *bo)

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_alloc_gart(struct · line 980

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
      * Called by amdgpu_gtt_mgr_recover() from

amdgpu_device_reset() to

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -6
      * rebind GTT pages during a GPU reset.
      */
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
     {
           struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
           uint64_t flags;
- int r;
 
           if (!tbo->ttm)
-         return 0;
+         return;
 
           flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;
+ amdgpu_ttm_gart_bind(adev, tbo, flags);
     }
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
     /*
@@ -1032,7 +1003,6 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
           struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
           struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
           /* if the pages have userptr pinning then clear that first */
           if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void · line 1024

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                   return;
 
           /* unbind shouldn't be done for GDS/GWS/OA in

ttm_bo_clean_mm */

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
-         DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-                   gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
           gtt->bound = false;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct

amdgpu_device

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
 *adev);
 
     bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr); +void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

uint64_t amdgpu_preempt_mgr_usage(struct

ttm_resource_manager

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
                           struct dma_fence **fence);
 
     int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
     uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev,
 uint32_t type);
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
     #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -8
                   return -EINVAL;
           }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           r = adev->gfxhub.funcs->gart_enable(adev);
           if (r)
                   return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct · line 1027

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -2
- adev->gart.ready = true;
-
           return 0;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static void gmc_v6_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) {

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
           uint64_t table_addr;
- int r, i;
           u32 field;
+ int i;
 
           if (adev->gart.bo == NULL) {
                   dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                   return -EINVAL;
           }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
           table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct

amdgpu_device *adev)

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct · line 556

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
           dev_info(adev->dev, "PCIE GART of %uM enabled (table at

0x%016llX).\n",

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -1
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)table_addr);
- adev->gart.ready = true;
           return 0;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -5
           uint64_t table_addr;
- int r, i;
           u32 tmp, field;
+ int i;
 
           if (adev->gart.bo == NULL) {
                   dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                   return -EINVAL;
           }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_gart_enable(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
           /* Setup TLB control */
@@ -712,7 +709,6 @@ static int gmc_v7_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
           DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)table_addr);
- adev->gart.ready = true;
           return 0;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static void gmc_v8_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -5
           uint64_t table_addr;
- int r, i;
           u32 tmp, field;
+ int i;
 
           if (adev->gart.bo == NULL) {
                   dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                   return -EINVAL;
           }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_gart_enable(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
           /* Setup TLB control */
@@ -953,7 +950,6 @@ static int gmc_v8_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
           DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)table_addr);
- adev->gart.ready = true;
           return 0;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -8
                   return -EINVAL;
           }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           r = adev->gfxhub.funcs->gart_enable(adev);
           if (r)
                   return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct · line 1801

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
           DRM_INFO("PTB located at 0x%016llX\n",
                           (unsigned long long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -1
- adev->gart.ready = true;
           return 0;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_gart_map(struct amdgpu_ring

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring

*ring,

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
 uint64_t npages,
 
           cpu_addr = &job->ibs[0].ptr[num_dw];
 
- r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
- if (r)
-         goto error_free;
-
+ amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
           r = amdgpu_job_submit(job, &adev->mman.entity,
                                 AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
           if (r)

--
2.25.1

#11 lore raw

[Public]

How about changing the code from "if (WARN_ON(!adev->gart.ptr))" to "if (!adev->gart.ptr)", the purpose is to drop the warning only. Other functionality keeps the same.

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, January 20, 2022 11:47 PM
To: Kim, Jonathan <[email protected]>; Chen, Guchun <[email protected]>; Christian König <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I think we could remove this warning as well, all we need to do is to make sure that the GART table is always restored from the metadata before it is enabled in hardware.

I've seen that we do this anyway for most hardware generations, but we really need to double check.

Christian.

Am 20.01.22 um 16:04 schrieb Kim, Jonathan:

Quoted 729 lines

[Public]

Switching to a VRAM bounce buffer can drop performance around 4x~6x on Vega20 over larger access so it's not desired.

Jon

Quoted 723 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: January 20, 2022 9:10 AM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 5 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same

sdma_access_bo's creation in amdgpu_ttm_init.

Quoted 2 lines

In your patch, you introduce a new check of
WARN_ON(!adev->gart.ptr)),

however, sdma_access_bo targets to create a bo in GTT domain, but adev-

Quoted 5 lines

gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we

change it to VRAM?

Quoted 11 lines

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Quoted 71 lines

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 63 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))

(quoted diff) +0 -7
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 12 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and

GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The only thing we need to warn about are GART binding before the

table is even allocated.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
     drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
     drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
     drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
     drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------

------

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
     drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
     drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
     drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
     drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
     drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
     drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
     drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
     11 files changed, 52 insertions(+), 137 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct

amdgpu_device *adev)

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct · line 153

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
      * replaces them with the dummy page (all asics).
      * Returns 0 for success, -EINVAL for failure.
      */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -0
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t 
+offset,
                           int pages)
     {
           unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 165

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
           uint64_t flags = 0;
           int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to unbind memory from uninitialized GART

!\n");

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 171

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +3 -3
-         return -EINVAL;
- }
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
           if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
           t = offset / AMDGPU_GPU_PAGE_SIZE;
           p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6

@@ int

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 9 lines

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

                   amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

           drm_dev_exit(idx);
- return 0;
     }

     /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 204

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
      * Map the dma_addresses into GART entries (all asics).
      * Returns 0 for success, -EINVAL for failure.
      */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
                       int pages, dma_addr_t *dma_addr, uint64_t flags,
                       void *dst)
     {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
           unsigned i, j, t;
           int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -4
-         return -EINVAL;
- }
-
           if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
           t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
                   }
           }
           drm_dev_exit(idx);
- return 0;
     }
 
     /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 240

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
      * (all asics).
      * Returns 0 for success, -EINVAL for failure.
      */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 254

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
                        int pages, dma_addr_t *dma_addr,
                        uint64_t flags)
     {
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -7
-         return -EINVAL;
- }
-
- if (!adev->gart.ptr)
-         return 0;
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
- return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-                        adev->gart.ptr);
+ amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
     }
 
     /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -1
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
           unsigned                        num_gpu_pages;
           unsigned                        num_cpu_pages;
           unsigned                        table_size;
- bool                            ready;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -0
           /* Asic default pte flags */
           uint64_t                        gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct

amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 57

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -6
-                int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-             int pages, dma_addr_t *dma_addr, uint64_t flags,
-             void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-              int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 59

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
+                 int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 62

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +3 -0
+              int pages, dma_addr_t *dma_addr, uint64_t flags,
+              void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -0
+               int pages, dma_addr_t *dma_addr, uint64_t flags);
     void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev); 
 #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct

amdgpu_gtt_mgr *mgr)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
      *
      * Re-init the gart for each known BO in the GTT.
      */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
     {
           struct amdgpu_gtt_node *node;
           struct drm_mm_node *mm_node;
           struct amdgpu_device *adev;
- int r = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct · line 236

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
           adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
           spin_lock(&mgr->lock);
           drm_mm_for_each_node(mm_node, &mgr->mm) {
                   node = container_of(mm_node, typeof(*node),

base.mm_nodes[0]);

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -5
-         r = amdgpu_ttm_recover_gart(node->tbo);
-         if (r)
-                 break;
+         amdgpu_ttm_recover_gart(node->tbo);
           }
           spin_unlock(&mgr->lock);
 
           amdgpu_gart_invalidate_tlb(adev);
-
- return r;
     }
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
     /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                   dma_addr_t *dma_addr;
 
                   dma_addr = &bo->ttm->dma_address[mm_cur->start 
Quoted 1 line
Quoted 1 line

PAGE_SHIFT];

Quoted 1 line
Quoted 1 line
Quoted 1 line

- r = amdgpu_gart_map(adev, 0, num_pages, dma_addr,

flags,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-                             cpu_addr);
-         if (r)
-                 goto error_free;
+         amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,

cpu_addr);

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 4 lines
           } else {
                   dma_addr_t dma_address;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 258

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
                   dma_address += 
 adev->vm_manager.vram_base_offset;
 
                   for (i = 0; i < num_pages; ++i) {
-                 r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-                                     &dma_address, flags, cpu_addr);
-                 if (r)
-                         goto error_free;
-
+                 amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,

&dma_address,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+                                 flags, cpu_addr);
                           dma_address += PAGE_SIZE;
                   }
           }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -826,14 +820,13 @@ static void

amdgpu_ttm_tt_unpin_userptr(struct

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-                         struct ttm_buffer_object *tbo,
-                         uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+                          struct ttm_buffer_object *tbo,
+                          uint64_t flags)
     {
           struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
           struct ttm_tt *ttm = tbo->ttm;
           struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
           if (amdgpu_bo_encrypted(abo))
                   flags |= AMDGPU_PTE_TMZ; @@ -841,10 +834,8 @@ 

static int amdgpu_ttm_gart_bind(struct

amdgpu_device *adev,

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
           if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
                   uint64_t page_idx = 1;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -4
-         r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-                         gtt->ttm.dma_address, flags);
-         if (r)
-                 goto gart_bind_fail;
+         amdgpu_gart_bind(adev, gtt->offset, page_idx,
+                          gtt->ttm.dma_address, flags);
 
                   /* The memory type of the first page defaults to UC. Now
                    * modify the memory type to NC from the second 

page of

(quoted diff) +0 -0
@@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct 
 amdgpu_device *adev,
 >>>                    flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
Quoted 1 line
Quoted 1 line
Quoted 1 line
                   flags |=

AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
-         r = amdgpu_gart_bind(adev,
-                         gtt->offset + (page_idx << PAGE_SHIFT),
-                         ttm->num_pages - page_idx,
-                         &(gtt->ttm.dma_address[page_idx]), flags);
+         amdgpu_gart_bind(adev, gtt->offset + (page_idx <<

PAGE_SHIFT),

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -9
+                          ttm->num_pages - page_idx,
+                          &(gtt->ttm.dma_address[page_idx]), 
+ flags);
           } else {
-         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-                              gtt->ttm.dma_address, flags);
+         amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                          gtt->ttm.dma_address, flags);
           }
-
-gart_bind_fail:
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
-
- return r;
     }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct

Quoted 2 lines
     /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct

ttm_device *bdev,

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
           struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
           struct amdgpu_ttm_tt *gtt = (void*)ttm;
           uint64_t flags;
- int r = 0;
+ int r;
 
           if (!bo_mem)
                   return -EINVAL; @@ -930,14 +913,10 @@ static 

int amdgpu_ttm_backend_bind(struct ttm_device *bdev,

           /* bind pages into GART page tables */
           gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;

- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -6
-         gtt->ttm.dma_address, flags);
-
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                  gtt->ttm.dma_address, flags);
           gtt->bound = true;
- return r;
+ return 0;
     }
 
     /*
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -3
           /* Bind pages */
           gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
-         ttm_resource_free(bo, &tmp);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-         return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
           amdgpu_gart_invalidate_tlb(adev);
           ttm_resource_free(bo, &bo->resource);
           ttm_bo_assign_mem(bo, tmp); @@ -1006,19 +980,16 @@ int 

amdgpu_ttm_alloc_gart(struct

ttm_buffer_object *bo)

Quoted 1 line
Quoted 1 line
Quoted 1 line

* Called by amdgpu_gtt_mgr_recover() from

amdgpu_device_reset() to

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

* rebind GTT pages during a GPU reset.
*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -3
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
     {
           struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
           uint64_t flags;
- int r;
 
           if (!tbo->ttm)
-         return 0;
+         return;
 
           flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm, 

tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;

+ amdgpu_ttm_gart_bind(adev, tbo, flags);
     }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 2 lines
     /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -1032,7 +1003,6 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
           struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
           struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
           /* if the pages have userptr pinning then clear that first */
           if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void · line 1024

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                   return;
 
           /* unbind shouldn't be done for GDS/GWS/OA in

ttm_bo_clean_mm */

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
-         DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-                   gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
           gtt->bound = false;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct

amdgpu_device

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
 *adev);
 
     bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem); 

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr); +void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

uint64_t amdgpu_preempt_mgr_usage(struct

ttm_resource_manager

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
                           struct dma_fence **fence);
 
     int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int 
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
     uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev, 
 uint32_t type);
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
     #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -8
                   return -EINVAL;
           }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           r = adev->gfxhub.funcs->gart_enable(adev);
           if (r)
                   return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct · line 1027

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -2
- adev->gart.ready = true;
-
           return 0;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static void gmc_v6_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) {

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
           uint64_t table_addr;
- int r, i;
           u32 field;
+ int i;
 
           if (adev->gart.bo == NULL) {
                   dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                   return -EINVAL;
           }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
           table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct

amdgpu_device *adev)

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct · line 556

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
           dev_info(adev->dev, "PCIE GART of %uM enabled (table at

0x%016llX).\n",

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -1
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)table_addr);
- adev->gart.ready = true;
           return 0;
     }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -5
           uint64_t table_addr;
- int r, i;
           u32 tmp, field;
+ int i;
 
           if (adev->gart.bo == NULL) {
                   dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                   return -EINVAL;
           }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
           /* Setup TLB control */ @@ -712,7 +709,6 @@ static int 

gmc_v7_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
           DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)table_addr);
- adev->gart.ready = true;
           return 0;
     }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static void gmc_v8_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -5
           uint64_t table_addr;
- int r, i;
           u32 tmp, field;
+ int i;
 
           if (adev->gart.bo == NULL) {
                   dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                   return -EINVAL;
           }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
           /* Setup TLB control */ @@ -953,7 +950,6 @@ static int 

gmc_v8_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
           DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                    (unsigned)(adev->gmc.gart_size >> 20),
                    (unsigned long long)table_addr);
- adev->gart.ready = true;
           return 0;
     }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -8
                   return -EINVAL;
           }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
           r = adev->gfxhub.funcs->gart_enable(adev);
           if (r)
                   return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
           DRM_INFO("PTB located at 0x%016llX\n",
                           (unsigned long 

long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 4 lines
Quoted 4 lines
- adev->gart.ready = true;
           return 0;
     }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_gart_map(struct amdgpu_ring

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring

*ring,

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
 uint64_t npages,
 
           cpu_addr = &job->ibs[0].ptr[num_dw];
 
- r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
- if (r)
-         goto error_free;
-
+ amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
           r = amdgpu_job_submit(job, &adev->mman.entity,
                                 AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
           if (r)

--
2.25.1

maintainer
#12 lore raw

Yeah, you of course still need to check if the table is allocated or not.

Otherwise we will run immediately into a NULL pointer exception.

Question is does it always work with this change?

Regards,
Christian.

Am 21.01.22 um 02:54 schrieb Chen, Guchun:

Quoted 748 lines

[Public]

How about changing the code from "if (WARN_ON(!adev->gart.ptr))" to "if (!adev->gart.ptr)", the purpose is to drop the warning only. Other functionality keeps the same.

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, January 20, 2022 11:47 PM
To: Kim, Jonathan <[email protected]>; Chen, Guchun <[email protected]>; Christian König <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I think we could remove this warning as well, all we need to do is to make sure that the GART table is always restored from the metadata before it is enabled in hardware.

I've seen that we do this anyway for most hardware generations, but we really need to double check.

Christian.

Am 20.01.22 um 16:04 schrieb Kim, Jonathan:

Quoted 728 lines

[Public]

Switching to a VRAM bounce buffer can drop performance around 4x~6x on Vega20 over larger access so it's not desired.

Jon

Quoted 722 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: January 20, 2022 9:10 AM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 5 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same

sdma_access_bo's creation in amdgpu_ttm_init.

Quoted 2 lines

In your patch, you introduce a new check of
WARN_ON(!adev->gart.ptr)),

however, sdma_access_bo targets to create a bo in GTT domain, but adev-

Quoted 5 lines

gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we

change it to VRAM?

Quoted 11 lines

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Quoted 71 lines

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 63 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))

(quoted diff) +0 -7
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 12 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and

GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The only thing we need to warn about are GART binding before the

table is even allocated.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
      drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
      drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
      drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
      drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------

------

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
      drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
      drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
      drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
      drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
      drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
      drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
      drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
      11 files changed, 52 insertions(+), 137 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct

amdgpu_device *adev)

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct · line 153

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
       * replaces them with the dummy page (all asics).
       * Returns 0 for success, -EINVAL for failure.
       */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -0
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t
+offset,
                            int pages)
      {
            unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 165

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
            uint64_t flags = 0;
            int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to unbind memory from uninitialized GART

!\n");

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 171

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +3 -3
-         return -EINVAL;
- }
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
            if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
            t = offset / AMDGPU_GPU_PAGE_SIZE;
            p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 +186,6

@@ int

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 9 lines

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

                    amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

            drm_dev_exit(idx);
- return 0;
      }

      /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 204

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
       * Map the dma_addresses into GART entries (all asics).
       * Returns 0 for success, -EINVAL for failure.
       */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
                        int pages, dma_addr_t *dma_addr, uint64_t flags,
                        void *dst)
      {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
            unsigned i, j, t;
            int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -4
-         return -EINVAL;
- }
-
            if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
            t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
                    }
            }
            drm_dev_exit(idx);
- return 0;
      }
 
      /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 240

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
       * (all asics).
       * Returns 0 for success, -EINVAL for failure.
       */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 254

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
                         int pages, dma_addr_t *dma_addr,
                         uint64_t flags)
      {
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -7
-         return -EINVAL;
- }
-
- if (!adev->gart.ptr)
-         return 0;
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
- return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-                        adev->gart.ptr);
+ amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
      }
 
      /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -1
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
            unsigned                        num_gpu_pages;
            unsigned                        num_cpu_pages;
            unsigned                        table_size;
- bool                            ready;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -0
            /* Asic default pte flags */
            uint64_t                        gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct

amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 57

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -6
-                int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-             int pages, dma_addr_t *dma_addr, uint64_t flags,
-             void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-              int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 59

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
+                 int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 62

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +3 -0
+              int pages, dma_addr_t *dma_addr, uint64_t flags,
+              void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -0
+               int pages, dma_addr_t *dma_addr, uint64_t flags);
      void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev);
 #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c

b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct

amdgpu_gtt_mgr *mgr)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
       *
       * Re-init the gart for each known BO in the GTT.
       */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
      {
            struct amdgpu_gtt_node *node;
            struct drm_mm_node *mm_node;
            struct amdgpu_device *adev;
- int r = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct · line 236

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
            adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
            spin_lock(&mgr->lock);
            drm_mm_for_each_node(mm_node, &mgr->mm) {
                    node = container_of(mm_node, typeof(*node),

base.mm_nodes[0]);

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -5
-         r = amdgpu_ttm_recover_gart(node->tbo);
-         if (r)
-                 break;
+         amdgpu_ttm_recover_gart(node->tbo);
            }
            spin_unlock(&mgr->lock);
 
            amdgpu_gart_invalidate_tlb(adev);
-
- return r;
      }
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
      /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 248

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                    dma_addr_t *dma_addr;
 
                    dma_addr = &bo->ttm->dma_address[mm_cur->start

PAGE_SHIFT];

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 249

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
-         r = amdgpu_gart_map(adev, 0, num_pages, dma_addr,

flags,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 249

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-                             cpu_addr);
-         if (r)
-                 goto error_free;
+         amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,

cpu_addr);

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
            } else {
                    dma_addr_t dma_address;
 
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 258

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
                    dma_address +=
 adev->vm_manager.vram_base_offset;
 
                    for (i = 0; i < num_pages; ++i) {
-                 r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-                                     &dma_address, flags, cpu_addr);
-                 if (r)
-                         goto error_free;
-
+                 amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,

&dma_address,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+                                 flags, cpu_addr);
                            dma_address += PAGE_SIZE;
                    }
            }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -826,14 +820,13 @@ static void

amdgpu_ttm_tt_unpin_userptr(struct

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-                         struct ttm_buffer_object *tbo,
-                         uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+                          struct ttm_buffer_object *tbo,
+                          uint64_t flags)
      {
            struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
            struct ttm_tt *ttm = tbo->ttm;
            struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
            if (amdgpu_bo_encrypted(abo))
                    flags |= AMDGPU_PTE_TMZ; @@ -841,10 +834,8 @@

static int amdgpu_ttm_gart_bind(struct

amdgpu_device *adev,

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
            if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
                    uint64_t page_idx = 1;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -4
-         r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-                         gtt->ttm.dma_address, flags);
-         if (r)
-                 goto gart_bind_fail;
+         amdgpu_gart_bind(adev, gtt->offset, page_idx,
+                          gtt->ttm.dma_address, flags);
 
                    /* The memory type of the first page defaults to UC. Now
                     * modify the memory type to NC from the second

page of

(quoted diff) +0 -0
@@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct
 amdgpu_device *adev,
 >>>                     flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
Quoted 1 line
Quoted 1 line
Quoted 1 line
                    flags |=

AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
-         r = amdgpu_gart_bind(adev,
-                         gtt->offset + (page_idx << PAGE_SHIFT),
-                         ttm->num_pages - page_idx,
-                         &(gtt->ttm.dma_address[page_idx]), flags);
+         amdgpu_gart_bind(adev, gtt->offset + (page_idx <<

PAGE_SHIFT),

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -9
+                          ttm->num_pages - page_idx,
+                          &(gtt->ttm.dma_address[page_idx]),
+ flags);
            } else {
-         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-                              gtt->ttm.dma_address, flags);
+         amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                          gtt->ttm.dma_address, flags);
            }
-
-gart_bind_fail:
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
-
- return r;
      }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct

Quoted 2 lines
      /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct

ttm_device *bdev,

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
            struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
            struct amdgpu_ttm_tt *gtt = (void*)ttm;
            uint64_t flags;
- int r = 0;
+ int r;
 
            if (!bo_mem)
                    return -EINVAL; @@ -930,14 +913,10 @@ static

int amdgpu_ttm_backend_bind(struct ttm_device *bdev,

            /* bind pages into GART page tables */
            gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;

- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -6
-         gtt->ttm.dma_address, flags);
-
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                  gtt->ttm.dma_address, flags);
            gtt->bound = true;
- return r;
+ return 0;
      }
 
      /*
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct
 ttm_buffer_object *bo)
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -3
            /* Bind pages */
            gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
-         ttm_resource_free(bo, &tmp);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-         return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
            amdgpu_gart_invalidate_tlb(adev);
            ttm_resource_free(bo, &bo->resource);
            ttm_bo_assign_mem(bo, tmp); @@ -1006,19 +980,16 @@ int

amdgpu_ttm_alloc_gart(struct

ttm_buffer_object *bo)

Quoted 1 line
Quoted 1 line
Quoted 1 line

* Called by amdgpu_gtt_mgr_recover() from

amdgpu_device_reset() to

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

* rebind GTT pages during a GPU reset.
*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -3
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
      {
            struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
            uint64_t flags;
- int r;
 
            if (!tbo->ttm)
-         return 0;
+         return;
 
            flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm,

tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;

+ amdgpu_ttm_gart_bind(adev, tbo, flags);
      }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 2 lines
      /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -1032,7 +1003,6 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
            struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
            struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
            /* if the pages have userptr pinning then clear that first */
            if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void · line 1024

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                    return;
 
            /* unbind shouldn't be done for GDS/GWS/OA in

ttm_bo_clean_mm */

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
-         DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-                   gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
            gtt->bound = false;
      }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct

amdgpu_device

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
 *adev);
 
      bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);

uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); -int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr); +void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);

uint64_t amdgpu_preempt_mgr_usage(struct

ttm_resource_manager

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -0
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
                            struct dma_fence **fence);
 
      int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); -int
 amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
      uint64_t amdgpu_ttm_domain_start(struct amdgpu_device *adev,
 uint32_t type);
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
      #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -8
                    return -EINVAL;
            }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            r = adev->gfxhub.funcs->gart_enable(adev);
            if (r)
                    return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct · line 1027

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -2
- adev->gart.ready = true;
-
            return 0;
      }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static void gmc_v6_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) {

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
            uint64_t table_addr;
- int r, i;
            u32 field;
+ int i;
 
            if (adev->gart.bo == NULL) {
                    dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                    return -EINVAL;
            }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
            table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct

amdgpu_device *adev)

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct · line 556

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
            dev_info(adev->dev, "PCIE GART of %uM enabled (table at

0x%016llX).\n",

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -1
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long long)table_addr);
- adev->gart.ready = true;
            return 0;
      }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -5
            uint64_t table_addr;
- int r, i;
            u32 tmp, field;
+ int i;
 
            if (adev->gart.bo == NULL) {
                    dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                    return -EINVAL;
            }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
            /* Setup TLB control */ @@ -712,7 +709,6 @@ static int

gmc_v7_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
            DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long long)table_addr);
- adev->gart.ready = true;
            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static void gmc_v8_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -5
            uint64_t table_addr;
- int r, i;
            u32 tmp, field;
+ int i;
 
            if (adev->gart.bo == NULL) {
                    dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                    return -EINVAL;
            }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
            /* Setup TLB control */ @@ -953,7 +950,6 @@ static int

gmc_v8_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
            DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long long)table_addr);
- adev->gart.ready = true;
            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -8
                    return -EINVAL;
            }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            r = adev->gfxhub.funcs->gart_enable(adev);
            if (r)
                    return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
            DRM_INFO("PTB located at 0x%016llX\n",
                            (unsigned long

long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 4 lines
Quoted 4 lines
- adev->gart.ready = true;
            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_gart_map(struct amdgpu_ring

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring

*ring,

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
 uint64_t npages,
 
            cpu_addr = &job->ibs[0].ptr[num_dw];
 
- r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
- if (r)
-         goto error_free;
-
+ amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
            r = amdgpu_job_submit(job, &adev->mman.entity,
                                  AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
            if (r)

--
2.25.1

#13 lore raw

[Public]

Hi Christian,

So far I did not find something bad except the warning. So I assume it should be fine with below change. So let me make a patch for this?

-if (WARN_ON(!adev->gart.ptr))
+if (!adev->gart.ptr)

	return;

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, January 21, 2022 3:24 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; Christian König <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Yeah, you of course still need to check if the table is allocated or not.

Otherwise we will run immediately into a NULL pointer exception.

Question is does it always work with this change?

Regards,
Christian.

Am 21.01.22 um 02:54 schrieb Chen, Guchun:

Quoted 757 lines

[Public]

How about changing the code from "if (WARN_ON(!adev->gart.ptr))" to "if (!adev->gart.ptr)", the purpose is to drop the warning only. Other functionality keeps the same.

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, January 20, 2022 11:47 PM
To: Kim, Jonathan <[email protected]>; Chen, Guchun <[email protected]>; Christian König <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I think we could remove this warning as well, all we need to do is to make sure that the GART table is always restored from the metadata before it is enabled in hardware.

I've seen that we do this anyway for most hardware generations, but we really need to double check.

Christian.

Am 20.01.22 um 16:04 schrieb Kim, Jonathan:

Quoted 735 lines

[Public]

Switching to a VRAM bounce buffer can drop performance around 4x~6x on Vega20 over larger access so it's not desired.

Jon

Quoted 729 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: January 20, 2022 9:10 AM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 5 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same

sdma_access_bo's creation in amdgpu_ttm_init.

Quoted 2 lines

In your patch, you introduce a new check of
WARN_ON(!adev->gart.ptr)),

however, sdma_access_bo targets to create a bo in GTT domain, but adev-

Quoted 5 lines

gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we

change it to VRAM?

Quoted 11 lines

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Quoted 71 lines

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 63 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))

(quoted diff) +0 -7
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 12 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and

GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The only thing we need to warn about are GART binding before the

table is even allocated.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
      drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
      drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
      drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
      drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------

------

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
      drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
      drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
      drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
      drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
      drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
      drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
      drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
      11 files changed, 52 insertions(+), 137 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct

amdgpu_device *adev)

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct · line 153

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
       * replaces them with the dummy page (all asics).
       * Returns 0 for success, -EINVAL for failure.
       */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -0
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t 
+offset,
                            int pages)
      {
            unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 165

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
            uint64_t flags = 0;
            int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to unbind memory from uninitialized GART

!\n");

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -2
-         return -EINVAL;
- }
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -1
            if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
            t = offset / AMDGPU_GPU_PAGE_SIZE;
            p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7 
+186,6

@@ int

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 9 lines

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

                    amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

            drm_dev_exit(idx);
- return 0;
      }

      /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 204

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
       * Map the dma_addresses into GART entries (all asics).
       * Returns 0 for success, -EINVAL for failure.
       */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
                        int pages, dma_addr_t *dma_addr, uint64_t flags,
                        void *dst)
      {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
            unsigned i, j, t;
            int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -4
-         return -EINVAL;
- }
-
            if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
            t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
                    }
            }
            drm_dev_exit(idx);
- return 0;
      }
 
      /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct

amdgpu_device *adev, uint64_t offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 241

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
       * (all asics).
       * Returns 0 for success, -EINVAL for failure.
       */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t 
 offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 255

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
                         int pages, dma_addr_t *dma_addr,
                         uint64_t flags)
      {
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -7
-         return -EINVAL;
- }
-
- if (!adev->gart.ptr)
-         return 0;
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
- return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-                        adev->gart.ptr);
+ amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
      }
 
      /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -1
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
            unsigned                        num_gpu_pages;
            unsigned                        num_cpu_pages;
            unsigned                        table_size;
- bool                            ready;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -0
            /* Asic default pte flags */
            uint64_t                        gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct

amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 57

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -6
-                int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-             int pages, dma_addr_t *dma_addr, uint64_t flags,
-             void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-              int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 59

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
+                 int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 62

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +3 -0
+              int pages, dma_addr_t *dma_addr, uint64_t flags,
+              void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -0
+               int pages, dma_addr_t *dma_addr, uint64_t flags);
      void amdgpu_gart_invalidate_tlb(struct amdgpu_device 
 *adev); #endif diff --git 

a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct

amdgpu_gtt_mgr *mgr)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
       *
       * Re-init the gart for each known BO in the GTT.
       */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
      {
            struct amdgpu_gtt_node *node;
            struct drm_mm_node *mm_node;
            struct amdgpu_device *adev;
- int r = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct · line 236

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
            adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
            spin_lock(&mgr->lock);
            drm_mm_for_each_node(mm_node, &mgr->mm) {
                    node = container_of(mm_node, typeof(*node),

base.mm_nodes[0]);

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -5
-         r = amdgpu_ttm_recover_gart(node->tbo);
-         if (r)
-                 break;
+         amdgpu_ttm_recover_gart(node->tbo);
            }
            spin_unlock(&mgr->lock);
 
            amdgpu_gart_invalidate_tlb(adev);
-
- return r;
      }
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
      /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                    dma_addr_t *dma_addr;
 
                    dma_addr = 

&bo->ttm->dma_address[mm_cur->start

PAGE_SHIFT];

Quoted 1 line
Quoted 1 line
Quoted 1 line

- r = amdgpu_gart_map(adev, 0, num_pages, dma_addr,

flags,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-                             cpu_addr);
-         if (r)
-                 goto error_free;
+         amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,

cpu_addr);

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 4 lines
            } else {
                    dma_addr_t dma_address;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 258

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
                    dma_address +=
 adev->vm_manager.vram_base_offset;
 
                    for (i = 0; i < num_pages; ++i) {
-                 r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-                                     &dma_address, flags, cpu_addr);
-                 if (r)
-                         goto error_free;
-
+                 amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,

&dma_address,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+                                 flags, cpu_addr);
                            dma_address += PAGE_SIZE;
                    }
            }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -826,14 +820,13 @@ static void

amdgpu_ttm_tt_unpin_userptr(struct

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-                         struct ttm_buffer_object *tbo,
-                         uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+                          struct ttm_buffer_object *tbo,
+                          uint64_t flags)
      {
            struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
            struct ttm_tt *ttm = tbo->ttm;
            struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
            if (amdgpu_bo_encrypted(abo))
                    flags |= AMDGPU_PTE_TMZ; @@ -841,10 +834,8 @@ 

static int amdgpu_ttm_gart_bind(struct

amdgpu_device *adev,

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
            if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
                    uint64_t page_idx = 1;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -4
-         r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-                         gtt->ttm.dma_address, flags);
-         if (r)
-                 goto gart_bind_fail;
+         amdgpu_gart_bind(adev, gtt->offset, page_idx,
+                          gtt->ttm.dma_address, flags);
 
                    /* The memory type of the first page defaults to UC. Now
                     * modify the memory type to NC from the 

second page of

(quoted diff) +0 -0
@@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct 
 amdgpu_device *adev,
 >>>                     flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
Quoted 1 line
Quoted 1 line
Quoted 1 line
                    flags |=

AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
-         r = amdgpu_gart_bind(adev,
-                         gtt->offset + (page_idx << PAGE_SHIFT),
-                         ttm->num_pages - page_idx,
-                         &(gtt->ttm.dma_address[page_idx]), flags);
+         amdgpu_gart_bind(adev, gtt->offset + (page_idx <<

PAGE_SHIFT),

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -9
+                          ttm->num_pages - page_idx,
+                          &(gtt->ttm.dma_address[page_idx]),
+ flags);
            } else {
-         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-                              gtt->ttm.dma_address, flags);
+         amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                          gtt->ttm.dma_address, flags);
            }
-
-gart_bind_fail:
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
-
- return r;
      }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct

Quoted 2 lines
      /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct

ttm_device *bdev,

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
            struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
            struct amdgpu_ttm_tt *gtt = (void*)ttm;
            uint64_t flags;
- int r = 0;
+ int r;
 
            if (!bo_mem)
                    return -EINVAL; @@ -930,14 +913,10 @@ static 

int amdgpu_ttm_backend_bind(struct ttm_device *bdev,

            /* bind pages into GART page tables */
            gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;

- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -6
-         gtt->ttm.dma_address, flags);
-
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                  gtt->ttm.dma_address, flags);
            gtt->bound = true;
- return r;
+ return 0;
      }
 
      /*
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct 
 ttm_buffer_object *bo)
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -3
            /* Bind pages */
            gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
-         ttm_resource_free(bo, &tmp);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-         return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
            amdgpu_gart_invalidate_tlb(adev);
            ttm_resource_free(bo, &bo->resource);
            ttm_bo_assign_mem(bo, tmp); @@ -1006,19 +980,16 @@ 

int amdgpu_ttm_alloc_gart(struct

ttm_buffer_object *bo)

Quoted 1 line
Quoted 1 line
Quoted 1 line

* Called by amdgpu_gtt_mgr_recover() from

amdgpu_device_reset() to

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

* rebind GTT pages during a GPU reset.
*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -3
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
      {
            struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
            uint64_t flags;
- int r;
 
            if (!tbo->ttm)
-         return 0;
+         return;
 
            flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm,

tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;

+ amdgpu_ttm_gart_bind(adev, tbo, flags);
      }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 2 lines
      /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -1032,7 +1003,6 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
            struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
            struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
            /* if the pages have userptr pinning then clear that first */
            if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void · line 1024

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                    return;
 
            /* unbind shouldn't be done for GDS/GWS/OA in

ttm_bo_clean_mm */

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
-         DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-                   gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
            gtt->bound = false;
      }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct

amdgpu_device

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct · line 125

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
 *adev);
 
      bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource 
 *mem); uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr); 
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
      uint64_t amdgpu_preempt_mgr_usage(struct

ttm_resource_manager

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
                            struct dma_fence **fence);
 
      int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo); 
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
      uint64_t amdgpu_ttm_domain_start(struct amdgpu_device 
 *adev, uint32_t type);
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 7 lines
      #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -8
                    return -EINVAL;
            }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            r = adev->gfxhub.funcs->gart_enable(adev);
            if (r)
                    return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long 

long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 5 lines
Quoted 5 lines

- adev->gart.ready = true;
-

            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static void gmc_v6_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) {

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
            uint64_t table_addr;
- int r, i;
            u32 field;
+ int i;
 
            if (adev->gart.bo == NULL) {
                    dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                    return -EINVAL;
            }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
            table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct

amdgpu_device *adev)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
            dev_info(adev->dev, "PCIE GART of %uM enabled (table 

at

0x%016llX).\n",

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long long)table_addr);
- adev->gart.ready = true;
            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -5
            uint64_t table_addr;
- int r, i;
            u32 tmp, field;
+ int i;
 
            if (adev->gart.bo == NULL) {
                    dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                    return -EINVAL;
            }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
            /* Setup TLB control */ @@ -712,7 +709,6 @@ static 

int gmc_v7_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
            DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long long)table_addr);
- adev->gart.ready = true;
            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static void gmc_v8_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -5
            uint64_t table_addr;
- int r, i;
            u32 tmp, field;
+ int i;
 
            if (adev->gart.bo == NULL) {
                    dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                    return -EINVAL;
            }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
            /* Setup TLB control */ @@ -953,7 +950,6 @@ static 

int gmc_v8_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
            DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                     (unsigned)(adev->gmc.gart_size >> 20),
                     (unsigned long long)table_addr);
- adev->gart.ready = true;
            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -8
                    return -EINVAL;
            }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
            r = adev->gfxhub.funcs->gart_enable(adev);
            if (r)
                    return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
            DRM_INFO("PTB located at 0x%016llX\n",
                            (unsigned long

long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 4 lines
Quoted 4 lines
- adev->gart.ready = true;
            return 0;
      }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_gart_map(struct amdgpu_ring

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring

*ring,

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
 uint64_t npages,
 
            cpu_addr = &job->ibs[0].ptr[num_dw];
 
- r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags, 
 cpu_addr);
- if (r)
-         goto error_free;
-
+ amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
            r = amdgpu_job_submit(job, &adev->mman.entity,
                                  AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
            if (r)

--
2.25.1

maintainer
#14 lore raw

Sure, go ahead. Just remove both warning, the one for map as well as the one for unmap.

Regards,
Christian.

Am 21.01.22 um 08:31 schrieb Chen, Guchun:

Quoted 786 lines

[Public]

Hi Christian,

So far I did not find something bad except the warning. So I assume it should be fine with below change. So let me make a patch for this?

(quoted diff) +1 -1
-if (WARN_ON(!adev->gart.ptr))
+if (!adev->gart.ptr)
	return;

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Friday, January 21, 2022 3:24 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; Christian König <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Yeah, you of course still need to check if the table is allocated or not.

Otherwise we will run immediately into a NULL pointer exception.

Question is does it always work with this change?

Regards,
Christian.

Am 21.01.22 um 02:54 schrieb Chen, Guchun:

Quoted 757 lines

[Public]

How about changing the code from "if (WARN_ON(!adev->gart.ptr))" to "if (!adev->gart.ptr)", the purpose is to drop the warning only. Other functionality keeps the same.

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, January 20, 2022 11:47 PM
To: Kim, Jonathan <[email protected]>; Chen, Guchun <[email protected]>; Christian König <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I think we could remove this warning as well, all we need to do is to make sure that the GART table is always restored from the metadata before it is enabled in hardware.

I've seen that we do this anyway for most hardware generations, but we really need to double check.

Christian.

Am 20.01.22 um 16:04 schrieb Kim, Jonathan:

Quoted 735 lines

[Public]

Switching to a VRAM bounce buffer can drop performance around 4x~6x on Vega20 over larger access so it's not desired.

Jon

Quoted 729 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: January 20, 2022 9:10 AM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

I actually suggested to allocate the bounce buffer in VRAM, but that add a bit more latency.

Christian.

Am 20.01.22 um 15:00 schrieb Chen, Guchun:

Quoted 5 lines

[Public]

Hi Christian,

Unfortunately, your patch brings another warning from the same

sdma_access_bo's creation in amdgpu_ttm_init.

Quoted 2 lines

In your patch, you introduce a new check of
WARN_ON(!adev->gart.ptr)),

however, sdma_access_bo targets to create a bo in GTT domain, but adev-

Quoted 5 lines

gart.ptr is ready in gmc_v10_0_gart_init only.

Hi Jonathan,

Is it mandatory to create this sdma_access_bo in GTT domain? Can we

change it to VRAM?

Quoted 11 lines

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, January 19, 2022 10:38 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Quoted 71 lines

Hi Guchun,

yes, just haven't found time to do this yet.

Regards,
Christian.

Am 19.01.22 um 15:24 schrieb Chen, Guchun:

Quoted 63 lines

[Public]

Hello Christian,

Do you plan to submit your code to drm-next branch?

Regards,
Guchun

-----Original Message-----
From: Chen, Guchun
Sent: Tuesday, January 18, 2022 10:22 PM
To: 'Christian König' <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amdgpu: remove gart.ready flag

[Public]

Thanks for the clarification. The patch is:

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 10:10 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: remove gart.ready flag

Am 18.01.22 um 14:28 schrieb Chen, Guchun:

Quoted 11 lines

[Public]

- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))

(quoted diff) +0 -7
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
Quoted 1 line

Does deleting skip_pin_bo path cause bo redundant pin in SRIOV case?

Pinning/unpinning the BO was already removed as well.

See Nirmoy's patches in the git log.

Regards,
Christian.

Quoted 12 lines

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Tuesday, January 18, 2022 8:02 PM
To: Chen, Guchun <[email protected]>; Kim, Jonathan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: remove gart.ready flag

That's just a leftover from old radeon days and was preventing CS and

GART bindings before the hardware was initialized. But nowdays that is perfectly valid.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The only thing we need to warn about are GART binding before the

table is even allocated.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
       drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c    | 35 +++-------
       drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h    | 15 ++--
       drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c |  9 +--
       drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 77 ++++++---------

------

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
       drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 +-
       drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c      | 11 +--
       drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c       |  7 +-
       drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c       |  8 +--
       drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c       |  8 +--
       drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c       | 10 +--
       drivers/gpu/drm/amd/amdkfd/kfd_migrate.c    |  5 +-
       11 files changed, 52 insertions(+), 137 deletions(-)
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
index 645950a653a0..53cc844346f0 100644
@@ -150,7 +150,7 @@ void amdgpu_gart_table_vram_free(struct

amdgpu_device *adev)

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c void amdgpu_gart_table_vram_free(struct · line 153

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
        * replaces them with the dummy page (all asics).
        * Returns 0 for success, -EINVAL for failure.
        */
-int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -0
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t
+offset,
                             int pages)
       {
             unsigned t;
@@ -161,13 +161,11 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 165

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
             uint64_t flags = 0;
             int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to unbind memory from uninitialized GART

!\n");

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -2
-         return -EINVAL;
- }
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -1
             if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
             t = offset / AMDGPU_GPU_PAGE_SIZE;
             p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; @@ -188,7
+186,6

@@ int

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct

Quoted 9 lines

amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

                     amdgpu_gmc_flush_gpu_tlb(adev, 0, i, 0);

             drm_dev_exit(idx);
- return 0;
       }

       /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
@@ -204,7 +201,7 @@ int amdgpu_gart_unbind(struct

amdgpu_device *adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_unbind(struct · line 204

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
        * Map the dma_addresses into GART entries (all asics).
        * Returns 0 for success, -EINVAL for failure.
        */
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -0
                         int pages, dma_addr_t *dma_addr, uint64_t flags,
                         void *dst)
       {
@@ -212,13 +209,8 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
             unsigned i, j, t;
             int idx;
 
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct amdgpu_device

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -4
-         return -EINVAL;
- }
-
             if (!drm_dev_enter(adev_to_drm(adev), &idx))
-         return 0;
+         return;
 
             t = offset / AMDGPU_GPU_PAGE_SIZE;
 
@@ -230,7 +222,6 @@ int amdgpu_gart_map(struct amdgpu_device

*adev, uint64_t offset,

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -1
                     }
             }
             drm_dev_exit(idx);
- return 0;
       }
 
       /**
@@ -246,20 +237,14 @@ int amdgpu_gart_map(struct

amdgpu_device *adev, uint64_t offset,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 241

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +1 -1
        * (all asics).
        * Returns 0 for success, -EINVAL for failure.
        */
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t
 offset,
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c int amdgpu_gart_map(struct · line 255

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +0 -2
                          int pages, dma_addr_t *dma_addr,
                          uint64_t flags)
       {
- if (!adev->gart.ready) {
-         WARN(1, "trying to bind memory to uninitialized GART

!\n");

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -7
-         return -EINVAL;
- }
-
- if (!adev->gart.ptr)
-         return 0;
+ if (WARN_ON(!adev->gart.ptr))
+         return;
 
- return amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
-                        adev->gart.ptr);
+ amdgpu_gart_map(adev, offset, pages, dma_addr, flags,
+adev->gart.ptr);
       }
 
       /**
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -1
index 78895413cf9f..8fea3e04e411 100644
@@ -46,7 +46,6 @@ struct amdgpu_gart {
             unsigned                        num_gpu_pages;
             unsigned                        num_cpu_pages;
             unsigned                        table_size;
- bool                            ready;
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +0 -0
             /* Asic default pte flags */
             uint64_t                        gart_pte_flags;
@@ -58,12 +57,12 @@ int amdgpu_gart_table_vram_pin(struct

amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); -int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 57

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -6
-                int pages);
-int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
-             int pages, dma_addr_t *dma_addr, uint64_t flags,
-             void *dst);
-int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,
-              int pages, dma_addr_t *dma_addr, uint64_t flags);
+void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 59

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
+                 int pages);
+void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t

offset,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h int amdgpu_gart_table_vram_pin(struct · line 62

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +3 -0
+              int pages, dma_addr_t *dma_addr, uint64_t flags,
+              void *dst);
+void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t

offset,

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +1 -0
+               int pages, dma_addr_t *dma_addr, uint64_t flags);
       void amdgpu_gart_invalidate_tlb(struct amdgpu_device
 *adev); #endif diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 9151950e0cc3..babdd915c4c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
@@ -224,26 +224,21 @@ uint64_t amdgpu_gtt_mgr_usage(struct

amdgpu_gtt_mgr *mgr)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -2
        *
        * Re-init the gart for each known BO in the GTT.
        */
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
       {
             struct amdgpu_gtt_node *node;
             struct drm_mm_node *mm_node;
             struct amdgpu_device *adev;
- int r = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c uint64_t amdgpu_gtt_mgr_usage(struct · line 236

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
             adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
             spin_lock(&mgr->lock);
             drm_mm_for_each_node(mm_node, &mgr->mm) {
                     node = container_of(mm_node, typeof(*node),

base.mm_nodes[0]);

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -5
-         r = amdgpu_ttm_recover_gart(node->tbo);
-         if (r)
-                 break;
+         amdgpu_ttm_recover_gart(node->tbo);
             }
             spin_unlock(&mgr->lock);
 
             amdgpu_gart_invalidate_tlb(adev);
-
- return r;
       }
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +0 -0
       /**
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index b489cd8abe31..9cdb61ec669e 100644
@@ -246,10 +246,7 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                     dma_addr_t *dma_addr;
 
                     dma_addr =

&bo->ttm->dma_address[mm_cur->start

PAGE_SHIFT];

Quoted 1 line
Quoted 1 line
Quoted 1 line

- r = amdgpu_gart_map(adev, 0, num_pages, dma_addr,

flags,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-                             cpu_addr);
-         if (r)
-                 goto error_free;
+         amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,

cpu_addr);

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct

Quoted 4 lines
             } else {
                     dma_addr_t dma_address;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -257,11 +254,8 @@ static int amdgpu_ttm_map_buffer(struct

ttm_buffer_object *bo,

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_map_buffer(struct · line 258

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
                     dma_address +=
 adev->vm_manager.vram_base_offset;
 
                     for (i = 0; i < num_pages; ++i) {
-                 r = amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,
-                                     &dma_address, flags, cpu_addr);
-                 if (r)
-                         goto error_free;
-
+                 amdgpu_gart_map(adev, i << PAGE_SHIFT, 1,

&dma_address,

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
+                                 flags, cpu_addr);
                             dma_address += PAGE_SIZE;
                     }
             }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -826,14 +820,13 @@ static void

amdgpu_ttm_tt_unpin_userptr(struct

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -4
 ttm_device *bdev,  #endif  }
 
-static int amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
-                         struct ttm_buffer_object *tbo,
-                         uint64_t flags)
+static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,
+                          struct ttm_buffer_object *tbo,
+                          uint64_t flags)
       {
             struct amdgpu_bo *abo = ttm_to_amdgpu_bo(tbo);
             struct ttm_tt *ttm = tbo->ttm;
             struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
             if (amdgpu_bo_encrypted(abo))
                     flags |= AMDGPU_PTE_TMZ; @@ -841,10 +834,8 @@

static int amdgpu_ttm_gart_bind(struct

amdgpu_device *adev,

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
             if (abo->flags & AMDGPU_GEM_CREATE_CP_MQD_GFX9) {
                     uint64_t page_idx = 1;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -4
-         r = amdgpu_gart_bind(adev, gtt->offset, page_idx,
-                         gtt->ttm.dma_address, flags);
-         if (r)
-                 goto gart_bind_fail;
+         amdgpu_gart_bind(adev, gtt->offset, page_idx,
+                          gtt->ttm.dma_address, flags);
 
                     /* The memory type of the first page defaults to UC. Now
                      * modify the memory type to NC from the

second page of

(quoted diff) +0 -0
@@ -853,21 +844,13 @@ static int amdgpu_ttm_gart_bind(struct
 amdgpu_device *adev,
 >>>                      flags &= ~AMDGPU_PTE_MTYPE_VG10_MASK;
Quoted 1 line
Quoted 1 line
Quoted 1 line
                     flags |=

AMDGPU_PTE_MTYPE_VG10(AMDGPU_MTYPE_NC);

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
-         r = amdgpu_gart_bind(adev,
-                         gtt->offset + (page_idx << PAGE_SHIFT),
-                         ttm->num_pages - page_idx,
-                         &(gtt->ttm.dma_address[page_idx]), flags);
+         amdgpu_gart_bind(adev, gtt->offset + (page_idx <<

PAGE_SHIFT),

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -9
+                          ttm->num_pages - page_idx,
+                          &(gtt->ttm.dma_address[page_idx]),
+ flags);
             } else {
-         r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
-                              gtt->ttm.dma_address, flags);
+         amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                          gtt->ttm.dma_address, flags);
             }
-
-gart_bind_fail:
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
-
- return r;
       }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_backend_bind(struct

Quoted 2 lines
       /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -883,7 +866,7 @@ static int amdgpu_ttm_backend_bind(struct

ttm_device *bdev,

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
             struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
             struct amdgpu_ttm_tt *gtt = (void*)ttm;
             uint64_t flags;
- int r = 0;
+ int r;
 
             if (!bo_mem)
                     return -EINVAL; @@ -930,14 +913,10 @@ static

int amdgpu_ttm_backend_bind(struct ttm_device *bdev,

             /* bind pages into GART page tables */
             gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;

- r = amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -6
-         gtt->ttm.dma_address, flags);
-
- if (r)
-         DRM_ERROR("failed to bind %u pages at 0x%08llX\n",
-                   ttm->num_pages, gtt->offset);
+ amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
+                  gtt->ttm.dma_address, flags);
             gtt->bound = true;
- return r;
+ return 0;
       }
 
       /*
@@ -987,12 +966,7 @@ int amdgpu_ttm_alloc_gart(struct
 ttm_buffer_object *bo)
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -3
             /* Bind pages */
             gtt->offset = (u64)tmp->start << PAGE_SHIFT;
- r = amdgpu_ttm_gart_bind(adev, bo, flags);
- if (unlikely(r)) {
-         ttm_resource_free(bo, &tmp);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -3
-         return r;
- }
-
+ amdgpu_ttm_gart_bind(adev, bo, flags);
             amdgpu_gart_invalidate_tlb(adev);
             ttm_resource_free(bo, &bo->resource);
             ttm_bo_assign_mem(bo, tmp); @@ -1006,19 +980,16 @@

int amdgpu_ttm_alloc_gart(struct

ttm_buffer_object *bo)

Quoted 1 line
Quoted 1 line
Quoted 1 line

* Called by amdgpu_gtt_mgr_recover() from

amdgpu_device_reset() to

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

* rebind GTT pages during a GPU reset.
*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -3
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo)
       {
             struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
             uint64_t flags;
- int r;
 
             if (!tbo->ttm)
-         return 0;
+         return;
 
             flags = amdgpu_ttm_tt_pte_flags(adev, tbo->ttm,

tbo->resource);
- r = amdgpu_ttm_gart_bind(adev, tbo, flags);
-
- return r;

+ amdgpu_ttm_gart_bind(adev, tbo, flags);
       }
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 2 lines
       /*
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
@@ -1032,7 +1003,6 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev, {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -1
             struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
             struct amdgpu_ttm_tt *gtt = (void *)ttm;
- int r;
 
             /* if the pages have userptr pinning then clear that first */
             if (gtt->userptr) {
@@ -1052,10 +1022,7 @@ static void

amdgpu_ttm_backend_unbind(struct ttm_device *bdev,

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void · line 1024

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
                     return;
 
             /* unbind shouldn't be done for GDS/GWS/OA in

ttm_bo_clean_mm */

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
- r = amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
- if (r)
-         DRM_ERROR("failed to unbind %u pages at 0x%08llX\n",
-                   gtt->ttm.num_pages, gtt->offset);
+ amdgpu_gart_unbind(adev, gtt->offset, ttm->num_pages);
             gtt->bound = false;
       }
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -0
index 084aa49e627d..d9691f262f16 100644
@@ -119,7 +119,7 @@ void amdgpu_vram_mgr_fini(struct

amdgpu_device

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h void amdgpu_vram_mgr_fini(struct · line 125

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
 *adev);
 
       bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource
 *mem); uint64_t amdgpu_gtt_mgr_usage(struct amdgpu_gtt_mgr *mgr);
-int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
+void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
 
       uint64_t amdgpu_preempt_mgr_usage(struct

ttm_resource_manager

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*man);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -1
@@ -162,7 +162,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
                             struct dma_fence **fence);
 
       int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo);
-int amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
+void amdgpu_ttm_recover_gart(struct ttm_buffer_object *tbo);
       uint64_t amdgpu_ttm_domain_start(struct amdgpu_device
 *adev, uint32_t type);
 
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 7 lines
       #if IS_ENABLED(CONFIG_DRM_AMDGPU_USERPTR)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..867c94a1a81a 100644
@@ -1000,14 +1000,7 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -8
                     return -EINVAL;
             }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
             r = adev->gfxhub.funcs->gart_enable(adev);
             if (r)
                     return r;
@@ -1033,8 +1026,6 @@ static int gmc_v10_0_gart_enable(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
                      (unsigned)(adev->gmc.gart_size >> 20),
                      (unsigned long

long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 5 lines
Quoted 5 lines

- adev->gart.ready = true;
-

             return 0;
       }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static void gmc_v6_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
index cd6c38e083d0..3baece11d74e 100644
@@ -469,16 +469,14 @@ static void gmc_v6_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) {

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -4
             uint64_t table_addr;
- int r, i;
             u32 field;
+ int i;
 
             if (adev->gart.bo == NULL) {
                     dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                     return -EINVAL;
             }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
 
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c static int gmc_v6_0_gart_enable(struct

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
             table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
@@ -558,7 +556,6 @@ static int gmc_v6_0_gart_enable(struct

amdgpu_device *adev)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +0 -0
             dev_info(adev->dev, "PCIE GART of %uM enabled (table

at

0x%016llX).\n",

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
                      (unsigned)(adev->gmc.gart_size >> 20),
                      (unsigned long long)table_addr);
- adev->gart.ready = true;
             return 0;
       }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index ab8adbff9e2d..cf83f8c258f4 100644
@@ -613,17 +613,14 @@ static void gmc_v7_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -5
             uint64_t table_addr;
- int r, i;
             u32 tmp, field;
+ int i;
 
             if (adev->gart.bo == NULL) {
                     dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                     return -EINVAL;
             }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
             table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
             /* Setup TLB control */ @@ -712,7 +709,6 @@ static

int gmc_v7_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
             DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                      (unsigned)(adev->gmc.gart_size >> 20),
                      (unsigned long long)table_addr);
- adev->gart.ready = true;
             return 0;
       }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static void gmc_v8_0_set_prt(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
index 054733838292..7cc7c8001734 100644
@@ -837,17 +837,14 @@ static void gmc_v8_0_set_prt(struct

amdgpu_device *adev, bool enable) static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) {

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -5
             uint64_t table_addr;
- int r, i;
             u32 tmp, field;
+ int i;
 
             if (adev->gart.bo == NULL) {
                     dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
                     return -EINVAL;
             }
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
             table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
             /* Setup TLB control */ @@ -953,7 +950,6 @@ static

int gmc_v8_0_gart_enable(struct

amdgpu_device *adev)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
             DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
                      (unsigned)(adev->gmc.gart_size >> 20),
                      (unsigned long long)table_addr);
- adev->gart.ready = true;
             return 0;
       }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index c76ffd1a70cd..9f71f810c2f8 100644
@@ -1783,14 +1783,7 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_gart_enable(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -8
                     return -EINVAL;
             }
 
- if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
-         goto skip_pin_bo;
-
- r = amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
- if (r)
-         return r;
-
-skip_pin_bo:
+ amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
             r = adev->gfxhub.funcs->gart_enable(adev);
             if (r)
                     return r;
@@ -1807,7 +1800,6 @@ static int gmc_v9_0_gart_enable(struct

amdgpu_device *adev)

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
             DRM_INFO("PTB located at 0x%016llX\n",
                             (unsigned long

long)amdgpu_bo_gpu_offset(adev-

gart.bo));

Quoted 4 lines
Quoted 4 lines
- adev->gart.ready = true;
             return 0;
       }
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c svm_migrate_gart_map(struct amdgpu_ring

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +0 -0
index d5d2cf2ee788..88db82b3d443 100644
@@ -86,10 +86,7 @@ svm_migrate_gart_map(struct amdgpu_ring

*ring,

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1 -4
 uint64_t npages,
 
             cpu_addr = &job->ibs[0].ptr[num_dw];
 
- r = amdgpu_gart_map(adev, 0, npages, addr, pte_flags,
 cpu_addr);
- if (r)
-         goto error_free;
-
+ amdgpu_gart_map(adev, 0, npages, addr, pte_flags, cpu_addr);
             r = amdgpu_job_submit(job, &adev->mman.entity,
                                   AMDGPU_FENCE_OWNER_UNDEFINED, &fence);
             if (r)

--
2.25.1