Skip to contentSkip to conversation

drm/amdgpu: reduce the full gpu access time in amdgpu_device_init.

PATCH New chong li 1 participant 1 message Nov 11, 2025

Subsystems (3)
lore
Share & tools
lore

chong li

author
#0 lore raw

PATCH 1/1 drm/amdgpu: reduce the full gpu access time in amdgpu_device_init.

[Why]
function "devm_memremap_pages" in function "kgd2kfd_init_zone_device", sometimes cost too much time.

[How]
move the function "kgd2kfd_init_zone_device"
after release full gpu access(amdgpu_virt_release_full_gpu).

Change-Id I3eebd7272b8f0c85d08fec80acee67a2c9e59e52
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h      |  1 +
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c  | 24 ++++++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -1
index 860ac1f9e35d..c293e9a24d48 100644
@@ -84,6 +84,8 @@
 
 #include <drm/drm_drv.h>
 
+#include <kfd_priv.h>
+
 #if IS_ENABLED(CONFIG_X86)
 #include <asm/intel-family.h>
 #include <asm/cpu_device_id.h>
@@ -3314,7 +3316,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 
 	/* Don't init kfd if whole hive need to be reset during init */
 	if (adev->init_lvl->level != AMDGPU_INIT_LEVEL_MINIMAL_XGMI) {
-		kgd2kfd_init_zone_device(adev);
 		amdgpu_amdkfd_device_init(adev);
 	}
 
@@ -4918,6 +4919,13 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
 	if (adev->init_lvl->level == AMDGPU_INIT_LEVEL_MINIMAL_XGMI)
 		amdgpu_xgmi_reset_on_init(adev);
+
+	/* Don't init kfd if whole hive need to be reset during init */
+	if (adev->init_lvl->level != AMDGPU_INIT_LEVEL_MINIMAL_XGMI) {
+		kgd2kfd_init_zone_device(adev);
+		kfd_update_svm_support_properties(adev);
+	}
+
 	/*
 	 * Place those sysfs registering after `late_init`. As some of those
 	 * operations performed in `late_init` might affect the sysfs
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -0
index 70ef051511bb..bd1c6d1742c8 100644
@@ -1358,6 +1358,7 @@ struct process_queue_node {
 
 void kfd_process_dequeue_from_device(struct kfd_process_device *pdd);
 void kfd_process_dequeue_from_all_devices(struct kfd_process *p);
+void kfd_update_svm_support_properties(struct amdgpu_device *adev);
 int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p);
 void pqm_uninit(struct process_queue_manager *pqm);
 int pqm_create_queue(struct process_queue_manager *pqm,
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +24 -0
index 5c98746eb72d..f25d867ec40a 100644
@@ -2401,4 +2401,28 @@ int kfd_debugfs_rls_by_device(struct seq_file *m, void *data)
 	return r;
 }
 
+void kfd_update_svm_support_properties(struct amdgpu_device *adev)
+{
+	struct kfd_topology_device *dev;
+	int ret;
+	down_write(&topology_lock);
+
+	list_for_each_entry(dev, &topology_device_list, list) {
+		if (dev->gpu && dev->gpu->adev == adev) {
+			if (KFD_IS_SVM_API_SUPPORTED(adev)) {
+				dev->node_props.capability |= HSA_CAP_SVMAPI_SUPPORTED;
+				ret = kfd_topology_update_sysfs();
+				if (!ret)
+					sys_props.generation_count++;
+				else
+					dev_err(adev->dev, "Failed to update SVM support properties. ret=%d\n", ret);			}
+			else
+				dev->node_props.capability &= ~HSA_CAP_SVMAPI_SUPPORTED;
+		}
+	}
+
+	up_write(&topology_lock);
+	return ;
+}
+
 #endif
Signature · 1 line
2.48.1