drm/amdgpu: revise the device initialization sequences
authorEvan Quan <evan.quan@amd.com>
Fri, 11 Aug 2023 07:14:46 +0000 (15:14 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 31 Aug 2023 20:35:33 +0000 (16:35 -0400)
By placing the sysfs interfaces creation after `.late_int`. Since some
operations performed during `.late_init` may affect how the sysfs
interfaces should be created.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index ed0104f565040e526de1e73d732efe4b48d8bd4d..d45f5ea575836a9fd689647b9d284d4a79bb126d 100644 (file)
@@ -3862,22 +3862,6 @@ fence_driver_init:
        /* Get a log2 for easy divisions. */
        adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps));
 
-       r = amdgpu_atombios_sysfs_init(adev);
-       if (r)
-               drm_err(&adev->ddev,
-                       "registering atombios sysfs failed (%d).\n", r);
-
-       r = amdgpu_pm_sysfs_init(adev);
-       if (r)
-               DRM_ERROR("registering pm sysfs failed (%d).\n", r);
-
-       r = amdgpu_ucode_sysfs_init(adev);
-       if (r) {
-               adev->ucode_sysfs_en = false;
-               DRM_ERROR("Creating firmware sysfs failed (%d).\n", r);
-       } else
-               adev->ucode_sysfs_en = true;
-
        /*
         * Register gpu instance before amdgpu_device_enable_mgpu_fan_boost.
         * Otherwise the mgpu fan boost feature will be skipped due to the
@@ -3906,6 +3890,27 @@ fence_driver_init:
                flush_delayed_work(&adev->delayed_init_work);
        }
 
+       /*
+        * Place those sysfs registering after `late_init`. As some of those
+        * operations performed in `late_init` might affect the sysfs
+        * interfaces creating.
+        */
+       r = amdgpu_atombios_sysfs_init(adev);
+       if (r)
+               drm_err(&adev->ddev,
+                       "registering atombios sysfs failed (%d).\n", r);
+
+       r = amdgpu_pm_sysfs_init(adev);
+       if (r)
+               DRM_ERROR("registering pm sysfs failed (%d).\n", r);
+
+       r = amdgpu_ucode_sysfs_init(adev);
+       if (r) {
+               adev->ucode_sysfs_en = false;
+               DRM_ERROR("Creating firmware sysfs failed (%d).\n", r);
+       } else
+               adev->ucode_sysfs_en = true;
+
        r = sysfs_create_files(&adev->dev->kobj, amdgpu_dev_attributes);
        if (r)
                dev_err(adev->dev, "Could not create amdgpu device attr\n");