[PATCH 4/4] drm/amdkfd: Enable SVM on Native mode

Alex Deucher alexander.deucher at amd.com
Tue May 9 22:08:18 UTC 2023


From: Mukul Joshi <mukul.joshi at amd.com>

This patch enables SVM capability on GFX9.4.3 when
run in Native mode. It also sets best_prefetch and
best_restore locations to CPU as there is no VRAM.

Signed-off-by: Mukul Joshi <mukul.joshi at amd.com>
Acked-by: Rajneesh Bhardwaj <rajneesh.bhardwaj at amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 8 ++++++++
 drivers/gpu/drm/amd/amdkfd/kfd_svm.h | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index c87b12f1c957..8a1075eed5b4 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -2542,6 +2542,9 @@ svm_range_best_restore_location(struct svm_range *prange,
 		return -1;
 	}
 
+	if (node->adev->gmc.is_app_apu)
+		return 0;
+
 	if (prange->preferred_loc == gpuid ||
 	    prange->preferred_loc == KFD_IOCTL_SVM_LOCATION_SYSMEM) {
 		return prange->preferred_loc;
@@ -3255,6 +3258,11 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 		goto out;
 	}
 
+	if (bo_node->adev->gmc.is_app_apu) {
+		best_loc = 0;
+		goto out;
+	}
+
 	if (p->xnack_enabled)
 		bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE);
 	else
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.h b/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
index 5116786718b6..7515ddade3ae 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
@@ -200,7 +200,8 @@ void svm_range_list_lock_and_flush_work(struct svm_range_list *svms, struct mm_s
 /* SVM API and HMM page migration work together, device memory type
  * is initialized to not 0 when page migration register device memory.
  */
-#define KFD_IS_SVM_API_SUPPORTED(dev) ((dev)->pgmap.type != 0)
+#define KFD_IS_SVM_API_SUPPORTED(dev) ((dev)->pgmap.type != 0 ||\
+				       (dev)->adev->gmc.is_app_apu)
 
 void svm_range_bo_unref_async(struct svm_range_bo *svm_bo);
 
-- 
2.40.1



More information about the amd-gfx mailing list