]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: reduce the full gpu access time in amdgpu_device_init.
authorchong li <chongli2@amd.com>
Fri, 7 Nov 2025 03:59:28 +0000 (11:59 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 8 Dec 2025 18:56:38 +0000 (13:56 -0500)
[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).

v2:
improve the coding style.

Signed-off-by: chong li <chongli2@amd.com>
Reviewed-by: Emily Deng <Emily.Deng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdkfd/kfd_topology.c
drivers/gpu/drm/amd/amdkfd/kfd_topology.h

index 8bdfcde2029b5348c66f617cd1e9493ccc7d2555..335d733751cbfd454ddb11086f531c1c016725da 100644 (file)
@@ -37,7 +37,7 @@
 #include "amdgpu_sync.h"
 #include "amdgpu_vm.h"
 #include "amdgpu_xcp.h"
-
+#include "kfd_topology.h"
 extern uint64_t amdgpu_amdkfd_total_mem_size;
 
 enum TLB_FLUSH_TYPE {
index 6fb82d6c9a1a525b75dc4fef67a988d640eff83e..06f4cdcccb4fed5030c0c33dbef08437809984a3 100644 (file)
@@ -3317,7 +3317,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);
        }
 
@@ -4934,6 +4933,13 @@ fence_driver_init:
 
        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
index 811636af14eaac25fe5d9937388a643a04b44e3c..9c3e8f946a3d582380ec31b03726359fd46eecbf 100644 (file)
@@ -2404,3 +2404,26 @@ int kfd_debugfs_rls_by_device(struct seq_file *m, void *data)
 }
 
 #endif
+
+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)
+                       continue;
+
+               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);
+}
index 3de8ec0043bb4a60f0f261e02e48681ce73d2819..ad63ba67b57740376687bfb513442c5573fb3522 100644 (file)
@@ -201,4 +201,10 @@ struct kfd_topology_device *kfd_create_topology_device(
                struct list_head *device_list);
 void kfd_release_topology_device_list(struct list_head *device_list);
 
+#if IS_ENABLED(CONFIG_HSA_AMD)
+void kfd_update_svm_support_properties(struct amdgpu_device *adev);
+#else
+static inline void kfd_update_svm_support_properties(struct amdgpu_device *adev) {}
+#endif
+
 #endif /* __KFD_TOPOLOGY_H__ */