Skip to contentSkip to conversation

drm/amdgpu: Wait for reset on init completion

PATCH In review Lijo Lazar 2 participants 2 messages Oct 7, 2024 – Oct 10, 2024

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Wait for reset on init completion

When reset on initialization is requested, wait for the reset to finish. In cases where module is loaded after boot, this makes sure all initialization work is done after a successful return of modprobe.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +8 -1
index 6532b7530a5c..8e697273d2ac 100644
@@ -1554,6 +1554,7 @@ static void amdgpu_xgmi_schedule_reset_on_init(struct amdgpu_hive_info *hive)
 int amdgpu_xgmi_reset_on_init(struct amdgpu_device *adev)
 {
 	struct amdgpu_hive_info *hive;
+	bool reset_scheduled;
 	int num_devs;
 
 	hive = amdgpu_get_xgmi_hive(adev);
@@ -1562,12 +1563,18 @@ int amdgpu_xgmi_reset_on_init(struct amdgpu_device *adev)
 
 	mutex_lock(&hive->hive_lock);
 	num_devs = atomic_read(&hive->number_devices);
-	if (num_devs == adev->gmc.xgmi.num_physical_nodes)
+	reset_scheduled = false;
+	if (num_devs == adev->gmc.xgmi.num_physical_nodes) {
 		amdgpu_xgmi_schedule_reset_on_init(hive);
+		reset_scheduled = true;
+	}
 
 	mutex_unlock(&hive->hive_lock);
 	amdgpu_put_xgmi_hive(hive);
 
+	if (reset_scheduled)
+		flush_work(&hive->reset_on_init_work);
+
 	return 0;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Regards,
Ramesh

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, October 7, 2024 4:33 AM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Bhardwaj, Rajneesh <[email protected]>; Errabolu, Ramesh <[email protected]>; Xu, Feifei <[email protected]>
Subject: [PATCH] drm/amdgpu: Wait for reset on init completion

When reset on initialization is requested, wait for the reset to finish.
In cases where module is loaded after boot, this makes sure all initialization work is done after a successful return of modprobe.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +8 -1
index 6532b7530a5c..8e697273d2ac 100644
@@ -1554,6 +1554,7 @@ static void amdgpu_xgmi_schedule_reset_on_init(struct amdgpu_hive_info *hive)  int amdgpu_xgmi_reset_on_init(struct amdgpu_device *adev)  {
        struct amdgpu_hive_info *hive;
+       bool reset_scheduled;
        int num_devs;
 
        hive = amdgpu_get_xgmi_hive(adev);
@@ -1562,12 +1563,18 @@ int amdgpu_xgmi_reset_on_init(struct amdgpu_device *adev)
 
        mutex_lock(&hive->hive_lock);
        num_devs = atomic_read(&hive->number_devices);
-       if (num_devs == adev->gmc.xgmi.num_physical_nodes)
+       reset_scheduled = false;
+       if (num_devs == adev->gmc.xgmi.num_physical_nodes) {
                amdgpu_xgmi_schedule_reset_on_init(hive);
+               reset_scheduled = true;
+       }
 
        mutex_unlock(&hive->hive_lock);
        amdgpu_put_xgmi_hive(hive);
 
+       if (reset_scheduled)
+               flush_work(&hive->reset_on_init_work);
+
        return 0;
 }
 

--
2.25.1