Skip to contentSkip to conversation

drm/amdgpu: fix a race in GPU reset with IB test

PATCH In review Alex Deucher 2 participants 2 messages May 28, 2019 – May 29, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: fix a race in GPU reset with IB test

Split late_init into two functions, one (do_late_init) which just does the hw init, and late_init which calls do_late_init and schedules the IB test work. Call do_late_init in the GPU reset code to run the init code, but not schedule the IB test code. The IB test code is called directly in the gpu reset code so no need to run the IB tests in a separate work thread. If we do, we end up racing.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 43 +++++++++++++---------
 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +26 -17
index 7a8c2201cd04..6b90840307dc 100644
@@ -1869,19 +1869,7 @@ static int amdgpu_device_set_pg_state(struct amdgpu_device *adev, enum amd_power
 	return 0;
 }
 
-/**
- * amdgpu_device_ip_late_init - run late init for hardware IPs
- *
- * @adev: amdgpu_device pointer
- *
- * Late initialization pass for hardware IPs.  The list of all the hardware
- * IPs that make up the asic is walked and the late_init callbacks are run.
- * late_init covers any special initialization that an IP requires
- * after all of the have been initialized or something that needs to happen
- * late in the init process.
- * Returns 0 on success, negative error code on failure.
- */
-static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
+static int amdgpu_device_do_ip_late_init(struct amdgpu_device *adev)
 {
 	int i = 0, r;
 
@@ -1902,14 +1890,35 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
 	amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
 	amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-	queue_delayed_work(system_wq, &adev->late_init_work,
-			   msecs_to_jiffies(AMDGPU_RESUME_MS));
-
 	amdgpu_device_fill_reset_magic(adev);
 
 	return 0;
 }
 
+/**
+ * amdgpu_device_ip_late_init - run late init for hardware IPs
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * Late initialization pass for hardware IPs.  The list of all the hardware
+ * IPs that make up the asic is walked and the late_init callbacks are run.
+ * late_init covers any special initialization that an IP requires
+ * after all of the have been initialized or something that needs to happen
+ * late in the init process.
+ * Returns 0 on success, negative error code on failure.
+ */
+static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
+{
+	int r;
+
+	r = amdgpu_device_do_ip_late_init(adev);
+
+	queue_delayed_work(system_wq, &adev->late_init_work,
+			   msecs_to_jiffies(AMDGPU_RESUME_MS));
+
+	return r;
+}
+
 /**
  * amdgpu_device_ip_fini - run fini for hardware IPs
  *
@@ -3502,7 +3511,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
 				if (vram_lost)
 					amdgpu_device_fill_reset_magic(tmp_adev);
 
-				r = amdgpu_device_ip_late_init(tmp_adev);
+				r = amdgpu_device_do_ip_late_init(tmp_adev);
 				if (r)
 					goto out;
 
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20190528192955.599-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 28.05.19 um 21:29 schrieb Alex Deucher:

Quoted 7 lines

Split late_init into two functions, one (do_late_init) which just does the hw init, and late_init which calls do_late_init and schedules the IB test work. Call do_late_init in the GPU reset code to run the init code, but not schedule the IB test code. The IB test code is called directly in the gpu reset code so no need to run the IB tests in a separate work thread. If we do, we end up racing.

I already had the suspicion that we do something wrong in the reset path with this.

But I don't really like the naming. How about we call the late_init_work delayed_init_work instead and explicitly schedule it from amdgpu_device_init() ?

Christian.

Quoted 71 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 43 +++++++++++++---------
  1 file changed, 26 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +25 -16
index 7a8c2201cd04..6b90840307dc 100644
@@ -1869,19 +1869,7 @@ static int amdgpu_device_set_pg_state(struct amdgpu_device *adev, enum amd_power
  	return 0;
  }
 
-/**
- * amdgpu_device_ip_late_init - run late init for hardware IPs
- *
- * @adev: amdgpu_device pointer
- *
- * Late initialization pass for hardware IPs.  The list of all the hardware
- * IPs that make up the asic is walked and the late_init callbacks are run.
- * late_init covers any special initialization that an IP requires
- * after all of the have been initialized or something that needs to happen
- * late in the init process.
- * Returns 0 on success, negative error code on failure.
- */
-static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
+static int amdgpu_device_do_ip_late_init(struct amdgpu_device *adev)
  {
  	int i = 0, r;
 
@@ -1902,14 +1890,35 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
  	amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
  	amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-	queue_delayed_work(system_wq, &adev->late_init_work,
-			   msecs_to_jiffies(AMDGPU_RESUME_MS));
-
  	amdgpu_device_fill_reset_magic(adev);
 
  	return 0;
  }
 
+/**
+ * amdgpu_device_ip_late_init - run late init for hardware IPs
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * Late initialization pass for hardware IPs.  The list of all the hardware
+ * IPs that make up the asic is walked and the late_init callbacks are run.
+ * late_init covers any special initialization that an IP requires
+ * after all of the have been initialized or something that needs to happen
+ * late in the init process.
+ * Returns 0 on success, negative error code on failure.
+ */
+static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
+{
+	int r;
+
+	r = amdgpu_device_do_ip_late_init(adev);
+
+	queue_delayed_work(system_wq, &adev->late_init_work,
+			   msecs_to_jiffies(AMDGPU_RESUME_MS));
+
+	return r;
+}
+
  /**
   * amdgpu_device_ip_fini - run fini for hardware IPs
   *

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive, · line 3517

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3502,7 +3511,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
  				if (vram_lost)
  					amdgpu_device_fill_reset_magic(tmp_adev);
 
-				r = amdgpu_device_ip_late_init(tmp_adev);
+				r = amdgpu_device_do_ip_late_init(tmp_adev);
  				if (r)
  					goto out;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx