Skip to contentSkip to conversation

Revert "drm/amdkfd: flush TLB after updating GPU page table"

PATCH In review Philip Yang 3 participants 7 messages May 13, 2021 – May 14, 2021

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

PATCH 1/2 Revert "drm/amdkfd: flush TLB after updating GPU page table"

This reverts commit bcbc99676607d4ff9fd15f27481cb1794a567d65.

After "drm/amdgpu: flush TLB if valid PDE turns into PTE" is checked in, this workaround is not needed.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -3
index a518ad26ceec..50da0d1fb9c1 100644
@@ -1240,9 +1240,6 @@ static int svm_range_map_to_gpus(struct svm_range *prange,
 				break;
 			}
 		}
-
-		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
 	}
 
 	return r;
Signature · 6 lines
2.17.1

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

PATCH 2/2 drm/amdkfd: heavy-weight flush TLB after unmap

Need do a heavy-weight TLB flush to make sure we have no more dirty data in the cache for the unmapped pages.

Add flush_type parameter to amdgpu_amdkfd_flush_gpu_tlb_pasid.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c   | 2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c       | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
index 5f6696a3c778..0be9a6695b2e 100644
@@ -670,10 +670,10 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid)
 	return 0;
 }
 
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid)
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      uint32_t flush_type)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
-	const uint32_t flush_type = 0;
 	bool all_hub = false;
 
 	if (adev->family == AMDGPU_FAMILY_AI)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +2 -1
index 313ee49b9f17..e8ce851c6f29 100644
@@ -135,7 +135,8 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
 void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle);
 bool amdgpu_amdkfd_have_atomics_support(struct kgd_dev *kgd);
 int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid);
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid);
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      uint32_t flush_type);
 
 bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid);
 
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
index 9d4f527bda7c..1d8a593edd3f 100644
@@ -1853,7 +1853,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd)
 							pdd->qpd.vmid);
 	} else {
 		amdgpu_amdkfd_flush_gpu_tlb_pasid(dev->kgd,
-						pdd->process->pasid);
+						pdd->process->pasid, 0);
 	}
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -2
index 50da0d1fb9c1..e57a8e405efd 100644
@@ -1125,7 +1125,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
 				break;
 		}
 		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						  p->pasid, 2);
 	}
 
 	return r;
@@ -1182,7 +1182,7 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 		p = container_of(prange->svms, struct kfd_process, svms);
 		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						  p->pasid, 0);
 	}
 out:
 	prange->mapping.bo_va = NULL;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdkfd: heavy-weight flush TLB after unmap

Am 2021-05-13 um 12:58 p.m. schrieb Philip Yang:

Quoted 6 lines

Need do a heavy-weight TLB flush to make sure we have no more dirty data in the cache for the unmapped pages.

Add flush_type parameter to amdgpu_amdkfd_flush_gpu_tlb_pasid.

The series is

Quoted 65 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c   | 2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c       | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
index 5f6696a3c778..0be9a6695b2e 100644
@@ -670,10 +670,10 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid)
 	return 0;
 }
 
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid)
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      uint32_t flush_type)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
-	const uint32_t flush_type = 0;
 	bool all_hub = false;
 
 	if (adev->family == AMDGPU_FAMILY_AI)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +2 -1
index 313ee49b9f17..e8ce851c6f29 100644
@@ -135,7 +135,8 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
 void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle);
 bool amdgpu_amdkfd_have_atomics_support(struct kgd_dev *kgd);
 int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid);
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid);
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      uint32_t flush_type);
 
 bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid);
 
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
index 9d4f527bda7c..1d8a593edd3f 100644
@@ -1853,7 +1853,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd)
 							pdd->qpd.vmid);
 	} else {
 		amdgpu_amdkfd_flush_gpu_tlb_pasid(dev->kgd,
-						pdd->process->pasid);
+						pdd->process->pasid, 0);
 	}
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
index 50da0d1fb9c1..e57a8e405efd 100644
@@ -1125,7 +1125,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
 				break;
 		}
 		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						  p->pasid, 2);
 	}
 
 	return r;

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 1188

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
@@ -1182,7 +1182,7 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 		p = container_of(prange->svms, struct kfd_process, svms);
 		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						  p->pasid, 0);
 	}
 out:
 	prange->mapping.bo_va = NULL;

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

#3 lore raw

Re: [PATCH 2/2] drm/amdkfd: heavy-weight flush TLB after unmap

In reply to Philip Yang

Am 13.05.21 um 18:58 schrieb Philip Yang:

Quoted 4 lines

Need do a heavy-weight TLB flush to make sure we have no more dirty data in the cache for the unmapped pages.

Add flush_type parameter to amdgpu_amdkfd_flush_gpu_tlb_pasid.

Using a define for the flush type instead of magic numbers would be really nice to have here.

Apart from that I'm fine with the patch.

Christian.

Quoted 67 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 ++-
  drivers/gpu/drm/amd/amdkfd/kfd_process.c   | 2 +-
  drivers/gpu/drm/amd/amdkfd/kfd_svm.c       | 4 ++--
  4 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
index 5f6696a3c778..0be9a6695b2e 100644
@@ -670,10 +670,10 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid)
  	return 0;
  }
 
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid)
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      uint32_t flush_type)
  {
  	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
-	const uint32_t flush_type = 0;
  	bool all_hub = false;
 
  	if (adev->family == AMDGPU_FAMILY_AI)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +2 -1
index 313ee49b9f17..e8ce851c6f29 100644
@@ -135,7 +135,8 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
  void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle);
  bool amdgpu_amdkfd_have_atomics_support(struct kgd_dev *kgd);
  int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid);
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid);
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      uint32_t flush_type);
 
  bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid);
 
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
index 9d4f527bda7c..1d8a593edd3f 100644
@@ -1853,7 +1853,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd)
  							pdd->qpd.vmid);
  	} else {
  		amdgpu_amdkfd_flush_gpu_tlb_pasid(dev->kgd,
-						pdd->process->pasid);
+						pdd->process->pasid, 0);
  	}
  }
 
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
index 50da0d1fb9c1..e57a8e405efd 100644
@@ -1125,7 +1125,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
  				break;
  		}
  		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						  p->pasid, 2);
  	}
 
  	return r;

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 1188

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
@@ -1182,7 +1182,7 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
  		p = container_of(prange->svms, struct kfd_process, svms);
  		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						  p->pasid, 0);
  	}
  out:
  	prange->mapping.bo_va = NULL;

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

#4 lore raw

PATCH v2 2/2 drm/amdkfd: heavy-weight flush TLB after unmap

In reply to Philip Yang

Need do a heavy-weight TLB flush to make sure we have no more dirty data in the cache for the unmapped pages.

Define enum TLB_FLUSH_TYPE, add flush_type parameter to amdgpu_amdkfd_flush_gpu_tlb_pasid.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 9 ++++++++-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c   | 2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c       | 4 ++--
 4 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
index 5f6696a3c778..bfab2f9fdd17 100644
@@ -670,10 +670,10 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid)
 	return 0;
 }
 
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid)
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      enum TLB_FLUSH_TYPE flush_type)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
-	const uint32_t flush_type = 0;
 	bool all_hub = false;
 
 	if (adev->family == AMDGPU_FAMILY_AI)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +8 -1
index 313ee49b9f17..f4de50de359b 100644
@@ -36,6 +36,12 @@
 
 extern uint64_t amdgpu_amdkfd_total_mem_size;
 
+enum TLB_FLUSH_TYPE {
+	TLB_FLUSH_LEGACY = 0,
+	TLB_FLUSH_LIGHTWEIGHT,
+	TLB_FLUSH_HEAVYWEIGHT
+};
+
 struct amdgpu_device;
 
 struct kfd_bo_va_list {
@@ -135,7 +141,8 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
 void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle);
 bool amdgpu_amdkfd_have_atomics_support(struct kgd_dev *kgd);
 int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid);
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid);
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      enum TLB_FLUSH_TYPE flush_type);
 
 bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid);
 
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
index 9d4f527bda7c..5b6c5669c03d 100644
@@ -1853,7 +1853,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd)
 							pdd->qpd.vmid);
 	} else {
 		amdgpu_amdkfd_flush_gpu_tlb_pasid(dev->kgd,
-						pdd->process->pasid);
+					pdd->process->pasid, TLB_FLUSH_LEGACY);
 	}
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -2
index a52e4594785f..f2901e7a993e 100644
@@ -1127,7 +1127,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
 				break;
 		}
 		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+					p->pasid, TLB_FLUSH_HEAVYWEIGHT);
 	}
 
 	return r;
@@ -1183,7 +1183,7 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 		p = container_of(prange->svms, struct kfd_process, svms);
 		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						p->pasid, TLB_FLUSH_LEGACY);
 	}
 out:
 	prange->mapping.bo_va = NULL;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] drm/amdkfd: heavy-weight flush TLB after unmap

Am 14.05.21 um 16:42 schrieb Philip Yang:

Quoted 7 lines

Need do a heavy-weight TLB flush to make sure we have no more dirty data in the cache for the unmapped pages.

Define enum TLB_FLUSH_TYPE, add flush_type parameter to amdgpu_amdkfd_flush_gpu_tlb_pasid.

Quoted 78 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 9 ++++++++-
  drivers/gpu/drm/amd/amdkfd/kfd_process.c   | 2 +-
  drivers/gpu/drm/amd/amdkfd/kfd_svm.c       | 4 ++--
  4 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
index 5f6696a3c778..bfab2f9fdd17 100644
@@ -670,10 +670,10 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid)
  	return 0;
  }
 
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid)
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      enum TLB_FLUSH_TYPE flush_type)
  {
  	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
-	const uint32_t flush_type = 0;
  	bool all_hub = false;
 
  	if (adev->family == AMDGPU_FAMILY_AI)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +8 -1
index 313ee49b9f17..f4de50de359b 100644
@@ -36,6 +36,12 @@
 
  extern uint64_t amdgpu_amdkfd_total_mem_size;
 
+enum TLB_FLUSH_TYPE {
+	TLB_FLUSH_LEGACY = 0,
+	TLB_FLUSH_LIGHTWEIGHT,
+	TLB_FLUSH_HEAVYWEIGHT
+};
+
  struct amdgpu_device;
 
  struct kfd_bo_va_list {
@@ -135,7 +141,8 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
  void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle);
  bool amdgpu_amdkfd_have_atomics_support(struct kgd_dev *kgd);
  int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid);
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid);
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+				      enum TLB_FLUSH_TYPE flush_type);
 
  bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid);
 
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
index 9d4f527bda7c..5b6c5669c03d 100644
@@ -1853,7 +1853,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd)
  							pdd->qpd.vmid);
  	} else {
  		amdgpu_amdkfd_flush_gpu_tlb_pasid(dev->kgd,
-						pdd->process->pasid);
+					pdd->process->pasid, TLB_FLUSH_LEGACY);
  	}
  }
 
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
index a52e4594785f..f2901e7a993e 100644
@@ -1127,7 +1127,7 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,
  				break;
  		}
  		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+					p->pasid, TLB_FLUSH_HEAVYWEIGHT);
  	}
 
  	return r;

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 1189

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
@@ -1183,7 +1183,7 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
  		p = container_of(prange->svms, struct kfd_process, svms);
  		amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-						  p->pasid);
+						p->pasid, TLB_FLUSH_LEGACY);
  	}
  out:
  	prange->mapping.bo_va = NULL;

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

maintainer Reviewed-by
#6 lore raw

Re: [PATCH v2 2/2] drm/amdkfd: heavy-weight flush TLB after unmap

Am 2021-05-14 um 11:14 a.m. schrieb Christian König:

Quoted 10 lines

Am 14.05.21 um 16:42 schrieb Philip Yang:

Quoted 7 lines

Need do a heavy-weight TLB flush to make sure we have no more dirty data in the cache for the unmapped pages.

Define enum TLB_FLUSH_TYPE, add flush_type parameter to amdgpu_amdkfd_flush_gpu_tlb_pasid.

Quoted 88 lines
Quoted 88 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 9 ++++++++- drivers/gpu/drm/amd/amdkfd/kfd_process.c   | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_svm.c       | 4 ++--

  4 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -1
index 5f6696a3c778..bfab2f9fdd17 100644
@@ -670,10 +670,10 @@ int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct
 kgd_dev *kgd, uint16_t vmid)
       return 0;
   }
   -int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd,
 uint16_t pasid)
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t
 pasid,
+                      enum TLB_FLUSH_TYPE flush_type)
   {
       struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
-    const uint32_t flush_type = 0;

      bool all_hub = false;
        if (adev->family == AMDGPU_FAMILY_AI)

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +5 -0
index 313ee49b9f17..f4de50de359b 100644
@@ -36,6 +36,12 @@
     extern uint64_t amdgpu_amdkfd_total_mem_size;
   +enum TLB_FLUSH_TYPE {
+    TLB_FLUSH_LEGACY = 0,
+    TLB_FLUSH_LIGHTWEIGHT,
+    TLB_FLUSH_HEAVYWEIGHT
+};
+
   struct amdgpu_device;
     struct kfd_bo_va_list {
@@ -135,7 +141,8 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd,
 enum kgd_engine_type engine,
   void amdgpu_amdkfd_set_compute_idle(struct kgd_dev *kgd, bool idle);
   bool amdgpu_amdkfd_have_atomics_support(struct kgd_dev *kgd);

  int amdgpu_amdkfd_flush_gpu_tlb_vmid(struct kgd_dev *kgd, uint16_t vmid);
-int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid);
+int amdgpu_amdkfd_flush_gpu_tlb_pasid(struct kgd_dev *kgd, uint16_t pasid,
+                      enum TLB_FLUSH_TYPE flush_type); bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid);
  diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 9d4f527bda7c..5b6c5669c03d 100644

drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
@@ -1853,7 +1853,7 @@ void kfd_flush_tlb(struct kfd_process_device *pdd)
                               pdd->qpd.vmid);
       } else {
           amdgpu_amdkfd_flush_gpu_tlb_pasid(dev->kgd,
-                        pdd->process->pasid);
+                    pdd->process->pasid, TLB_FLUSH_LEGACY);
       }
   }

  diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c index a52e4594785f..f2901e7a993e 100644

drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -2
@@ -1127,7 +1127,7 @@ svm_range_unmap_from_gpus(struct svm_range
 *prange, unsigned long start,
                   break;
           }
           amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-                          p->pasid);
+                    p->pasid, TLB_FLUSH_HEAVYWEIGHT);
       }
         return r;
@@ -1183,7 +1183,7 @@ svm_range_map_to_gpu(struct amdgpu_device
 *adev, struct amdgpu_vm *vm,
             p = container_of(prange->svms, struct kfd_process, svms);
           amdgpu_amdkfd_flush_gpu_tlb_pasid((struct kgd_dev *)adev,
-                          p->pasid);
+                        p->pasid, TLB_FLUSH_LEGACY);
Quoted 8 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -0
       }

  out:
      prange->mapping.bo_va = NULL;

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

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