[PATCH] drm/amdkfd: handle svm migrate init error

Philip Yang Philip.Yang at amd.com
Fri Sep 17 19:15:58 UTC 2021


If svm migration init failed to create pages for device memory, set flag
to disable SVM capability, svm migrate fini skip release device pages
and mem region.

Signed-off-by: Philip Yang <Philip.Yang at amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index dab290a4d19d..21f745e0b86c 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -894,6 +894,9 @@ int svm_migrate_init(struct amdgpu_device *adev)
 	r = devm_memremap_pages(adev->dev, pgmap);
 	if (IS_ERR(r)) {
 		pr_err("failed to register HMM device memory\n");
+
+		/* Disable SVM support capability */
+		pgmap->type = 0;
 		devm_release_mem_region(adev->dev, res->start,
 					res->end - res->start + 1);
 		return PTR_ERR(r);
@@ -913,6 +916,9 @@ void svm_migrate_fini(struct amdgpu_device *adev)
 {
 	struct dev_pagemap *pgmap = &adev->kfd.dev->pgmap;
 
+	if (!KFD_IS_SVM_API_SUPPORTED(adev->kfd.dev))
+		return;
+
 	devm_memunmap_pages(adev->dev, pgmap);
 	devm_release_mem_region(adev->dev, pgmap->range.start,
 				pgmap->range.end - pgmap->range.start + 1);
-- 
2.17.1



More information about the amd-gfx mailing list