Skip to contentSkip to conversation

drm/amdgpu: reset asic after system-wide suspend aborted

PATCH Superseded Prike Liang 4 participants 15 messages Nov 18, 2021 – Nov 23, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: reset asic after system-wide suspend aborted

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19 +++++++++++++++++++
 3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
 	bool				in_s3;
 	bool				in_s4;
 	bool				in_s0ix;
+	bool				pm_completed;
 
 	atomic_t 			in_gpu_reset;
 	enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
 	if (adev->in_s0ix)
 		amdgpu_gfx_state_change_set(adev, sGpuChangeState_D0Entry);
 
+	if (!adev->pm_completed) {
+		dev_warn(adev->dev, "suspend aborted will do asic reset\n");
+		amdgpu_asic_reset(adev);
+	}
 	/* post card */
 	if (amdgpu_device_need_post(adev)) {
 		r = amdgpu_device_asic_init(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +19 -0
index eee3cf8..9f90017 100644
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct device *dev)
 	return r;
 }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is suspended
+ * completely in the system-wide suspend process.
+ */
+static int amdgpu_pmops_noirq_suspend(struct device *dev)
+{
+	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+	dev_dbg(dev, "amdgpu suspend completely.\n");
+	adev->pm_completed = true;
+
+	return 0;
+}
+
 static int amdgpu_pmops_resume(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -2181,6 +2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)
 	r = amdgpu_device_resume(drm_dev, true);
 	if (amdgpu_acpi_is_s0ix_active(adev))
 		adev->in_s0ix = false;
+	adev->pm_completed = false;
 	return r;
 }
 
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops = {
 	.runtime_suspend = amdgpu_pmops_runtime_suspend,
 	.runtime_resume = amdgpu_pmops_runtime_resume,
 	.runtime_idle = amdgpu_pmops_runtime_idle,
+	.suspend_noirq = amdgpu_pmops_noirq_suspend,
 };
 
 static int amdgpu_flush(struct file *f, fl_owner_t id)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 16 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19 +++++++++++++++++++
  3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
index b85b67a..8bd9833 100644

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
  	bool				in_s3;
  	bool				in_s4;
  	bool				in_s0ix;
+	bool				pm_completed;

PM framework maintains separate flags, why not use the same?

        dev->power.is_suspended = false;
        dev->power.is_noirq_suspended = false;
        dev->power.is_late_suspended = false;

BTW, Alex posted a patch which does similar thing, though it tries reset if suspend fails.

https://lore.kernel.org/all/DM6PR12MB26195F8E099407B4B6966FEBE4999@DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of resume.

Thanks,
Lijo

Quoted 63 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  	atomic_t 			in_gpu_reset;
  	enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
  	if (adev->in_s0ix)
  		amdgpu_gfx_state_change_set(adev, sGpuChangeState_D0Entry);
 
+	if (!adev->pm_completed) {
+		dev_warn(adev->dev, "suspend aborted will do asic reset\n");
+		amdgpu_asic_reset(adev);
+	}
  	/* post card */
  	if (amdgpu_device_need_post(adev)) {
  		r = amdgpu_device_asic_init(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +19 -0
index eee3cf8..9f90017 100644
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct device *dev)
  	return r;
  }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is suspended
+ * completely in the system-wide suspend process.
+ */
+static int amdgpu_pmops_noirq_suspend(struct device *dev)
+{
+	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+	dev_dbg(dev, "amdgpu suspend completely.\n");
+	adev->pm_completed = true;
+
+	return 0;
+}
+
  static int amdgpu_pmops_resume(struct device *dev)
  {
  	struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -2181,6 +2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)
  	r = amdgpu_device_resume(drm_dev, true);
  	if (amdgpu_acpi_is_s0ix_active(adev))
  		adev->in_s0ix = false;
+	adev->pm_completed = false;
  	return r;
  }
 
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops = {
  	.runtime_suspend = amdgpu_pmops_runtime_suspend,
  	.runtime_resume = amdgpu_pmops_runtime_resume,
  	.runtime_idle = amdgpu_pmops_runtime_idle,
+	.suspend_noirq = amdgpu_pmops_noirq_suspend,
  };
 
  static int amdgpu_flush(struct file *f, fl_owner_t id)
#2 lore raw

[Public]

Quoted 37 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 9 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
  3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
    bool                            in_s3;
    bool                            in_s4;
    bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 4 lines
         dev->power.is_suspended = false;
         dev->power.is_noirq_suspended = false;
         dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU device whether is finished suspend.

Quoted 9 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if suspend fails.

https://lore.kernel.org/all/DM6PR12MB26195F8E099407B4B6966FEBE4999@
DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of resume.

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend aborted after AMDGPU suspend case well, so now seems we only need take care suspend abort case here.

Quoted 72 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
    atomic_t                        in_gpu_reset;
    enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
    if (adev->in_s0ix)
            amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic reset\n");
+           amdgpu_asic_reset(adev);
+   }
    /* post card */
    if (amdgpu_device_need_post(adev)) {
            r = amdgpu_device_asic_init(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct

device *dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops

Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +19 -0
    return r;
  }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is suspended
+ * completely in the system-wide suspend process.
+ */
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
+   adev->pm_completed = true;
+
+   return 0;
+}
+
  static int amdgpu_pmops_resume(struct device *dev)
  {
    struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2181,6
+2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)
    r = amdgpu_device_resume(drm_dev, true);
    if (amdgpu_acpi_is_s0ix_active(adev))
            adev->in_s0ix = false;
+   adev->pm_completed = false;
    return r;
  }
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
    .runtime_suspend = amdgpu_pmops_runtime_suspend,
    .runtime_resume = amdgpu_pmops_runtime_resume,
    .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
  };
 
  static int amdgpu_flush(struct file *f, fl_owner_t id)
#3 lore raw
Quoted 50 lines · Prike

[Public]

Quoted 37 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 9 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
  3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
    bool                            in_s3;
    bool                            in_s4;
    bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 4 lines
         dev->power.is_suspended = false;
         dev->power.is_noirq_suspended = false;
         dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU device whether is finished suspend.

Quoted 3 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if suspend fails.

Quoted 9 lines
Quoted 6 lines

https://lore.kernel.org/all/DM6PR12MB26195F8E099407B4B6966FEBE4999@
DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of resume.

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend aborted after AMDGPU suspend case well, so now seems we only need take care suspend abort case here.

Yeah, I was thinking we'd take this patch rather than mine to minimize the number of resets.

Alex

Quoted 72 lines
Quoted 72 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
    atomic_t                        in_gpu_reset;
    enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
    if (adev->in_s0ix)
            amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic reset\n");
+           amdgpu_asic_reset(adev);
+   }
    /* post card */
    if (amdgpu_device_need_post(adev)) {
            r = amdgpu_device_asic_init(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct

device *dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops

Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +19 -0
    return r;
  }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is suspended
+ * completely in the system-wide suspend process.
+ */
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
+   adev->pm_completed = true;
+
+   return 0;
+}
+
  static int amdgpu_pmops_resume(struct device *dev)
  {
    struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2181,6
+2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)
    r = amdgpu_device_resume(drm_dev, true);
    if (amdgpu_acpi_is_s0ix_active(adev))
            adev->in_s0ix = false;
+   adev->pm_completed = false;
    return r;
  }
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
    .runtime_suspend = amdgpu_pmops_runtime_suspend,
    .runtime_resume = amdgpu_pmops_runtime_resume,
    .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
  };
 
  static int amdgpu_flush(struct file *f, fl_owner_t id)
#4 lore raw
Quoted 58 lines · Alex Deucher
Quoted 57 lines · Prike

[Public]

Quoted 37 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 9 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
   3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
     bool                            in_s3;
     bool                            in_s4;
     bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 4 lines
          dev->power.is_suspended = false;
          dev->power.is_noirq_suspended = false;
          dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU device whether is finished suspend.

Quoted 9 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if suspend fails.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2FDM6PR12MB26195F8E099407B4B6966FEBE4999%40&amp;data=04%7C01%7CLijo.Lazar%40amd.com%7C6401dce9411b4c134b0208d9aa9ca644%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637728412055353107%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=Z4dgNvHISHVlR4grHm1RU3%2FJMJVdRe7Ukq1DnjCgG0o%3D&amp;reserved=0
DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of resume.

Quoted 6 lines
Quoted 2 lines

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend aborted after AMDGPU suspend case well, so now seems we only need take care suspend abort case here.

Yeah, I was thinking we'd take this patch rather than mine to minimize the number of resets.

Wondering if suspend fails whether there is a need to call resume. It may not get to resume() to do a reset, that needs to be checked.

Thanks,
Lijo

Quoted 75 lines

Alex

Quoted 72 lines
Quoted 72 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
     atomic_t                        in_gpu_reset;
     enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
     if (adev->in_s0ix)
             amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic reset\n");
+           amdgpu_asic_reset(adev);
+   }
     /* post card */
     if (amdgpu_device_need_post(adev)) {
             r = amdgpu_device_asic_init(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct

device *dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops

Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +19 -0
     return r;
   }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is suspended
+ * completely in the system-wide suspend process.
+ */
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
+   adev->pm_completed = true;
+
+   return 0;
+}
+
   static int amdgpu_pmops_resume(struct device *dev)
   {
     struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2181,6
+2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)
     r = amdgpu_device_resume(drm_dev, true);
     if (amdgpu_acpi_is_s0ix_active(adev))
             adev->in_s0ix = false;
+   adev->pm_completed = false;
     return r;
   }
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
     .runtime_suspend = amdgpu_pmops_runtime_suspend,
     .runtime_resume = amdgpu_pmops_runtime_resume,
     .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
   };
 
   static int amdgpu_flush(struct file *f, fl_owner_t id)
#5 lore raw

Am 18.11.21 um 15:09 schrieb Lazar, Lijo:

Quoted 60 lines · Alex Deucher
Quoted 59 lines · Prike
Quoted 58 lines

[Public]

Quoted 37 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 9 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
   3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
      bool                            in_s3;
      bool                            in_s4;
      bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 4 lines

          dev->power.is_suspended = false;
          dev->power.is_noirq_suspended = false;
          dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU device whether is finished suspend.

Quoted 10 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if suspend fails.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2FDM6PR12MB26195F8E099407B4B6966FEBE4999%40&amp;data=04%7C01%7CLijo.Lazar%40amd.com%7C6401dce9411b4c134b0208d9aa9ca644%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637728412055353107%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=Z4dgNvHISHVlR4grHm1RU3%2FJMJVdRe7Ukq1DnjCgG0o%3D&amp;reserved=0

DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of resume.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend aborted after AMDGPU suspend case well, so now seems we only need take care suspend abort case here.

Yeah, I was thinking we'd take this patch rather than mine to minimize the number of resets.

Wondering if suspend fails whether there is a need to call resume. It may not get to resume() to do a reset, that needs to be checked.

I would rather do it so that we reset the ASIC during resume when we detect that the hardware is in a bad state.

This way it should also work with things like kexec and virtualization.

Regards,
Christian.

Quoted 82 lines

Thanks,
Lijo

Quoted 77 lines

Alex

Quoted 74 lines
Quoted 74 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
      atomic_t                        in_gpu_reset;
      enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
      if (adev->in_s0ix)
              amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic 
 reset\n");
+           amdgpu_asic_reset(adev);
+   }
      /* post card */
      if (amdgpu_device_need_post(adev)) {

             r = amdgpu_device_asic_init(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct

device *dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops

Quoted 33 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
      return r;
    }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is 

suspended
+ * completely in the system-wide suspend process.
+ */

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +10 -0
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
+   adev->pm_completed = true;
+
+   return 0;
+}
+

   static int amdgpu_pmops_resume(struct device *dev)
   {
     struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2181,6 +2198,7 @@ static int amdgpu_pmops_resume(struct device *dev) r = amdgpu_device_resume(drm_dev, true);
     if (amdgpu_acpi_is_s0ix_active(adev)) adev->in_s0ix = false;
+   adev->pm_completed = false;
     return r;
   }

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
      .runtime_suspend = amdgpu_pmops_runtime_suspend,
      .runtime_resume = amdgpu_pmops_runtime_resume,
      .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
    };
 
    static int amdgpu_flush(struct file *f, fl_owner_t id)
#6 lore raw
Quoted 68 lines · Christian König

Am 18.11.21 um 15:09 schrieb Lazar, Lijo:

Quoted 67 lines · Alex Deucher
Quoted 65 lines · Prike
Quoted 52 lines

[Public]

Quoted 37 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 9 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
   3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
      bool                            in_s3;
      bool                            in_s4;
      bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 4 lines

          dev->power.is_suspended = false;
          dev->power.is_noirq_suspended = false;
          dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU device whether is finished suspend.

Quoted 5 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if suspend fails.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2FDM6PR12MB26195F8E099407B4B6966FEBE4999%40&amp;data=04%7C01%7Clijo.lazar%40amd.com%7C79c861fcfccc4f2cc45d08d9aa9d61f0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637728415203834017%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=gGnctl8rlNTj6o02hlE06og3RCA%2BQP37B3ejsZSxPdM%3D&amp;reserved=0

Quoted 8 lines
Quoted 5 lines

DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of resume.

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend aborted after AMDGPU suspend case well, so now seems we only need take care suspend abort case here.

Yeah, I was thinking we'd take this patch rather than mine to minimize the number of resets.

Quoted 5 lines
Quoted 1 line

Wondering if suspend fails whether there is a need to call resume. It may not get to resume() to do a reset, that needs to be checked.

I would rather do it so that we reset the ASIC during resume when we detect that the hardware is in a bad state.

This way it should also work with things like kexec and virtualization.

I was thinking from the power framework perspective. If the device's suspend() callback returns failure, why would the framework needs to call a resume() on that device.

Thanks,
Lijo

Quoted 87 lines

Regards,
Christian.

Quoted 82 lines

Thanks,
Lijo

Quoted 77 lines

Alex

Quoted 74 lines
Quoted 74 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
      atomic_t                        in_gpu_reset;
      enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
      if (adev->in_s0ix)
              amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic 
 reset\n");
+           amdgpu_asic_reset(adev);
+   }
      /* post card */
      if (amdgpu_device_need_post(adev)) {

             r = amdgpu_device_asic_init(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct

device *dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops

Quoted 33 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
      return r;
    }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is 

suspended
+ * completely in the system-wide suspend process.
+ */

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +10 -0
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
+   adev->pm_completed = true;
+
+   return 0;
+}
+

   static int amdgpu_pmops_resume(struct device *dev)
   {
     struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2181,6 +2198,7 @@ static int amdgpu_pmops_resume(struct device *dev) r = amdgpu_device_resume(drm_dev, true);
     if (amdgpu_acpi_is_s0ix_active(adev)) adev->in_s0ix = false;
+   adev->pm_completed = false;
     return r;
   }

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
      .runtime_suspend = amdgpu_pmops_runtime_suspend,
      .runtime_resume = amdgpu_pmops_runtime_resume,
      .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
    };
 
    static int amdgpu_flush(struct file *f, fl_owner_t id)
#7 lore raw
Quoted 84 lines · Lijo
Quoted 80 lines · Christian König

Am 18.11.21 um 15:09 schrieb Lazar, Lijo:

Quoted 78 lines · Alex Deucher
Quoted 71 lines
Quoted 62 lines · Prike

[Public]

Quoted 37 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 9 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
   3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
     bool                            in_s3;
     bool                            in_s4;
     bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 4 lines
          dev->power.is_suspended = false;
          dev->power.is_noirq_suspended = false;
          dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU device whether is finished suspend.

Quoted 4 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if
suspend fails.

Quoted 8 lines

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2FDM6PR12MB26195F8E099407B4B6966FEBE4999%40&amp;data=04%7C01%7Clijo.lazar%40amd.com%7C79c861fcfccc4f2cc45d08d9aa9d61f0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637728415203834017%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=gGnctl8rlNTj6o02hlE06og3RCA%2BQP37B3ejsZSxPdM%3D&amp;reserved=0

DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of
resume.

Quoted 6 lines

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend aborted after AMDGPU suspend case well, so now seems we only need take care suspend abort case here.

Quoted 3 lines

Yeah, I was thinking we'd take this patch rather than mine to minimize the number of resets.

Wondering if suspend fails whether there is a need to call resume. It may not get to resume() to do a reset, that needs to be checked.

Quoted 8 lines
Quoted 4 lines

I would rather do it so that we reset the ASIC during resume when we detect that the hardware is in a bad state.

This way it should also work with things like kexec and virtualization.

I was thinking from the power framework perspective. If the device's suspend() callback returns failure, why would the framework needs to call a resume() on that device.

The device's suspend callback succeeds, but some other device or event in the system causes the overall suspend to abort. As such the GPU is never powered off by the platform so it's left in a partially initialized state. The system then calls the resume() callbacks for all of the devices that were previously suspended to bring them back to a working system. GPU reset is just a convenient way to get the device back into a known good state. Unfortunately, I'm not sure if there is a good way to detect whether the GPU is in a known good state or not until we try and re-init the IPs and at that point the IPs are not fully initialized so it's complex to try and unwind that, reset, and try again. It's probably easiest to just reset the GPU on resume all the time. If the GPU was powered down, the reset should work fine since we are resetting a GPU that just came out of reset. If the GPU was not powered down, the reset will put the GPU into a known good state.

Alex

Quoted 91 lines

Thanks,
Lijo

Quoted 87 lines

Regards,
Christian.

Quoted 82 lines

Thanks,
Lijo

Quoted 77 lines

Alex

Quoted 74 lines
Quoted 74 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
     atomic_t                        in_gpu_reset;
     enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
     if (adev->in_s0ix)
             amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic
 reset\n");
+           amdgpu_asic_reset(adev);
+   }
     /* post card */
     if (amdgpu_device_need_post(adev)) {
             r = amdgpu_device_asic_init(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct

device *dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops

Quoted 33 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
     return r;
   }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is

suspended
+ * completely in the system-wide suspend process.
+ */

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +12 -0
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
+   adev->pm_completed = true;
+
+   return 0;
+}
+
   static int amdgpu_pmops_resume(struct device *dev)
   {
     struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2181,6
+2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)
     r = amdgpu_device_resume(drm_dev, true);
     if (amdgpu_acpi_is_s0ix_active(adev))
             adev->in_s0ix = false;
+   adev->pm_completed = false;
     return r;
   }
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
     .runtime_suspend = amdgpu_pmops_runtime_suspend,
     .runtime_resume = amdgpu_pmops_runtime_resume,
     .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
   };
 
   static int amdgpu_flush(struct file *f, fl_owner_t id)
#8 lore raw
Quoted 94 lines · Alex Deucher
Quoted 84 lines · Lijo
Quoted 80 lines · Christian König

Am 18.11.21 um 15:09 schrieb Lazar, Lijo:

Quoted 78 lines · Alex Deucher
Quoted 71 lines
Quoted 62 lines · Prike

[Public]

Quoted 37 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 9 lines · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of amdgpu suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
    drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
    drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
    3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
      bool                            in_s3;
      bool                            in_s4;
      bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 4 lines
           dev->power.is_suspended = false;
           dev->power.is_noirq_suspended = false;
           dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU device whether is finished suspend.

Quoted 4 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if
suspend fails.

Quoted 8 lines

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2FDM6PR12MB26195F8E099407B4B6966FEBE4999%40&amp;data=04%7C01%7Clijo.lazar%40amd.com%7C2ce211aeeeb448f6cb2c08d9aa9f4741%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637728423343483218%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=nyzhGwTJV83YZkit34Bb%2B5tBxGEMvFzCyZPjz8eSDgc%3D&amp;reserved=0

DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of
resume.

Quoted 6 lines

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend aborted after AMDGPU suspend case well, so now seems we only need take care suspend abort case here.

Quoted 3 lines

Yeah, I was thinking we'd take this patch rather than mine to minimize the number of resets.

Wondering if suspend fails whether there is a need to call resume. It may not get to resume() to do a reset, that needs to be checked.

Quoted 8 lines
Quoted 4 lines

I would rather do it so that we reset the ASIC during resume when we detect that the hardware is in a bad state.

This way it should also work with things like kexec and virtualization.

I was thinking from the power framework perspective. If the device's suspend() callback returns failure, why would the framework needs to call a resume() on that device.

Quoted 16 lines

The device's suspend callback succeeds, but some other device or event in the system causes the overall suspend to abort. As such the GPU is never powered off by the platform so it's left in a partially initialized state. The system then calls the resume() callbacks for all of the devices that were previously suspended to bring them back to a working system. GPU reset is just a convenient way to get the device back into a known good state. Unfortunately, I'm not sure if there is a good way to detect whether the GPU is in a known good state or not until we try and re-init the IPs and at that point the IPs are not fully initialized so it's complex to try and unwind that, reset, and try again. It's probably easiest to just reset the GPU on resume all the time. If the GPU was powered down, the reset should work fine since we are resetting a GPU that just came out of reset. If the GPU was not powered down, the reset will put the GPU into a known good state.

https://elixir.bootlin.com/linux/latest/source/drivers/base/power/main.c#L925

I don't have a machine to trace the path. The flag is set only if suspend is succesful.

Thanks,
Lijo

Quoted 93 lines

Alex

Quoted 91 lines

Thanks,
Lijo

Quoted 87 lines

Regards,
Christian.

Quoted 82 lines

Thanks,
Lijo

Quoted 77 lines

Alex

Quoted 74 lines
Quoted 74 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
      atomic_t                        in_gpu_reset;
      enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct drm_device

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
      if (adev->in_s0ix)
              amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic
 reset\n");
+           amdgpu_asic_reset(adev);
+   }
      /* post card */
      if (amdgpu_device_need_post(adev)) {
              r = amdgpu_device_asic_init(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int amdgpu_pmops_suspend(struct

device *dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops

Quoted 33 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
      return r;
    }
 
+/*
+ * Actually the PM suspend whether is completed should be confirmed
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is

suspended
+ * completely in the system-wide suspend process.
+ */

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +12 -0
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
+   adev->pm_completed = true;
+
+   return 0;
+}
+
    static int amdgpu_pmops_resume(struct device *dev)
    {
      struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -2181,6
+2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)
      r = amdgpu_device_resume(drm_dev, true);
      if (amdgpu_acpi_is_s0ix_active(adev))
              adev->in_s0ix = false;
+   adev->pm_completed = false;
      return r;
    }
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops amdgpu_pm_ops

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
      .runtime_suspend = amdgpu_pmops_runtime_suspend,
      .runtime_resume = amdgpu_pmops_runtime_resume,
      .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
    };
 
    static int amdgpu_flush(struct file *f, fl_owner_t id)
#9 lore raw

[Public]

BTW, I'm not sure if 'reset always' on resume is a good idea for GPUs in a hive (assuming those systems also get suspended and get hiccups). At this point the hive isn't reinitialized.

Thanks,
Lijo

#10 lore raw
Quoted 5 lines · Lijo

[Public]

BTW, I'm not sure if 'reset always' on resume is a good idea for GPUs in a hive (assuming those systems also get suspended and get hiccups). At this point the hive isn't reinitialized.

Yeah, we should probably not reset if we are part of a hive.

Alex

Quoted 3 lines

Thanks,
Lijo

#11 lore raw

[Public]

Quoted 15 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, November 19, 2021 12:18 AM
To: Lazar, Lijo <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Christian König <[email protected]>; Liang, Prike <[email protected]>; Huang, Ray <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 4 lines · Lijo

[Public]

Quoted 8 lines
Quoted 1 line

BTW, I'm not sure if 'reset always' on resume is a good idea for GPUs in a

hive (assuming those systems also get suspended and get hiccups). At this point the hive isn't reinitialized.

Yeah, we should probably not reset if we are part of a hive.

Alex

For the GPU hive reset in this suspend abort case need treat specially, does that because of GPU hive need take care each node reset dependence and synchronous reset? For this purpose, can we skip the hive reset case and only do GPU reset under adev->gmc.xgmi.num_physical_nodes == 0 ?

Quoted 3 lines
Quoted 3 lines

Thanks,
Lijo

#12 lore raw
Quoted 19 lines · Prike

[Public]

Quoted 16 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, November 19, 2021 12:18 AM
To: Lazar, Lijo <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Christian König <[email protected]>; Liang, Prike <[email protected]>; Huang, Ray <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 5 lines · Lijo

[Public]

BTW, I'm not sure if 'reset always' on resume is a good idea for GPUs in a

Quoted 8 lines
Quoted 7 lines

hive (assuming those systems also get suspended and get hiccups). At this point the hive isn't reinitialized.

Yeah, we should probably not reset if we are part of a hive.

Alex

For the GPU hive reset in this suspend abort case need treat specially, does that because of GPU hive need take care each node reset dependence and synchronous reset? For this purpose, can we skip the hive reset case and only do GPU reset under adev->gmc.xgmi.num_physical_nodes == 0 ?

Yes, exactly. For the aborted suspend reset, we can check the value before doing a reset. I think you want to check if adev->gmc.xgmi.num_physical_nodes <= 1.

Alex

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Thanks,
Lijo

#13 lore raw

[Public]

Quoted 47 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Monday, November 22, 2021 11:48 PM
To: Liang, Prike <[email protected]>
Cc: Lazar, Lijo <[email protected]>; Deucher, Alexander <[email protected]>; Christian König <[email protected]>; Huang, Ray <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 15 lines · Prike

[Public]

Quoted 12 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, November 19, 2021 12:18 AM
To: Lazar, Lijo <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Christian König <[email protected]>; Liang, Prike <[email protected]>; Huang, Ray <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

On Thu, Nov 18, 2021 at 10:01 AM Lazar, Lijo <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines

[Public]

BTW, I'm not sure if 'reset always' on resume is a good idea for GPUs in a

Quoted 8 lines
Quoted 7 lines

hive (assuming those systems also get suspended and get hiccups). At this point the hive isn't reinitialized.

Yeah, we should probably not reset if we are part of a hive.

Alex

For the GPU hive reset in this suspend abort case need treat specially, does

that because of GPU hive need take care each node reset dependence and synchronous reset? For this purpose, can we skip the hive reset case and only do GPU reset under adev->gmc.xgmi.num_physical_nodes == 0 ?

Quoted 6 lines

Yes, exactly. For the aborted suspend reset, we can check the value before doing a reset. I think you want to check if adev->gmc.xgmi.num_physical_nodes <= 1.

Alex

Thanks for the clarification and will add this checking for GPU reset in the amdgpu_device_resume().

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Thanks,
Lijo

#14 lore raw
In reply to Lazar, Lijo

[Public]

Quoted 143 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 10:28 PM
To: Alex Deucher <[email protected]>
Cc: Christian König <[email protected]>; Liang, Prike <[email protected]>; Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 10 lines · Alex Deucher
Quoted 9 lines · Lijo
Quoted 5 lines · Christian König

Am 18.11.21 um 15:09 schrieb Lazar, Lijo:

Quoted 4 lines · Alex Deucher
Quoted 3 lines
Quoted 1 line · Prike
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

[Public]

Quoted 6 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, November 18, 2021 4:01 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang,

Ray

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

<[email protected]>
Subject: Re: [PATCH] drm/amdgpu: reset asic after system-wide suspend aborted

Quoted 1 line · Prike Liang

Do ASIC reset at the moment Sx suspend aborted behind of

amdgpu

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 8 lines

suspend to keep AMDGPU in a clean reset state and that can avoid re-initialize device improperly error.

---
    drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  4 ++++
    drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 19

+++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1056

Quoted 12 lines
    3 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index b85b67a..8bd9833 100644
@@ -1053,6 +1053,7 @@ struct amdgpu_device {
      bool                            in_s3;
      bool                            in_s4;
      bool                            in_s0ix;
+   bool                            pm_completed;

PM framework maintains separate flags, why not use the same?

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
           dev->power.is_suspended = false;
           dev->power.is_noirq_suspended = false;
           dev->power.is_late_suspended = false;

Thanks for pointing it out and I miss that flag. In this case we can use the PM flag is_noirq_suspended for checking AMDGPU

device

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

whether is finished suspend.

Quoted 5 lines

BTW, Alex posted a patch which does similar thing, though it tries reset if suspend fails.

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%

2Flore.kernel.org%2Fall%2FDM6PR12MB26195F8E099407B4B6966FEBE4999

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

%40&amp;data=04%7C01%7Clijo.lazar%40amd.com%7C2ce211aeee

b448f6cb

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

2c08d9aa9f4741%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63 77

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

28423343483218%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL CJQI

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

joiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=nyzhG

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

wTJV83YZkit34Bb%2B5tBxGEMvFzCyZPjz8eSDgc%3D&amp;reserved=0

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

DM6PR12MB2619.namprd12.prod.outlook.com/

If that reset also failed, then no point in another reset, or keep it as part of resume.

Alex's patch seems always do the ASIC reset at the end of AMDGPU device, but that may needn't on the normal AMDGPU device suspend. However, this patch shows that can handle the system suspend

aborted

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

after AMDGPU suspend case well, so now seems we only need take

care

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

suspend abort case here.

Yeah, I was thinking we'd take this patch rather than mine to minimize the number of resets.

Wondering if suspend fails whether there is a need to call resume. It may not get to resume() to do a reset, that needs to be checked.

Quoted 8 lines
Quoted 4 lines

I would rather do it so that we reset the ASIC during resume when we detect that the hardware is in a bad state.

This way it should also work with things like kexec and virtualization.

I was thinking from the power framework perspective. If the device's suspend() callback returns failure, why would the framework needs to call a resume() on that device.

Quoted 16 lines

The device's suspend callback succeeds, but some other device or event in the system causes the overall suspend to abort. As such the GPU is never powered off by the platform so it's left in a partially initialized state. The system then calls the resume() callbacks for all of the devices that were previously suspended to bring them back to a working system. GPU reset is just a convenient way to get the device back into a known good state. Unfortunately, I'm not sure if there is a good way to detect whether the GPU is in a known good state or not until we try and re-init the IPs and at that point the IPs are not fully initialized so it's complex to try and unwind that, reset, and try again. It's probably easiest to just reset the GPU on resume all the time. If the GPU was powered down, the reset should work fine since we are resetting a GPU that just came out of reset. If the GPU was not powered down, the reset will put the GPU into a known good state.

Quoted 5 lines

https://elixir.bootlin.com/linux/latest/source/drivers/base/power/main.c#L
925

I don't have a machine to trace the path. The flag is set only if suspend is succesful.

The PM flags are set on the PM opt callback processed successfully and then reset after relevant PM resume callback complete undoing process. Regards to sort out the system suspend abort after AMDGPU suspend seems not easy only use PM flags(is_suspended, .is_late_suspended ,is_noirq_suspended) since in the AMDGPU device resume phase only leave the flags is_suspended =1 and is_late_suspended/ is_noirq_suspended =0 no matter normal system suspend or system suspend process abort after AMDGPU suspend. In this patch the flag pm_completed only can handle the case which abort system suspend before call AMDGPU noirq suspend, and can't well cover all the system abort corner case such as system abort after AMDGPU noirq phase. So, how about check the PM suspend state by using the sys file /sys/power/suspend_stats/failed_suspend instead of tracing the flags of PM framework or driver callback defined and only do the GPU reset in the amdgpu_device_resume() when detect failed suspend?

If we give up checking suspend state and always do the GPU reset in the amdgpu_device_resume(), then that may have a side effect on the system resume latency?

Quoted 101 lines

Thanks,
Lijo

Quoted 22 lines

Alex

Quoted 20 lines

Thanks,
Lijo

Quoted 16 lines

Regards,
Christian.

Quoted 12 lines

Thanks,
Lijo

Quoted 7 lines

Alex

Quoted 4 lines
Quoted 4 lines

Thanks,
Lijo

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct

Quoted 8 lines
      atomic_t                        in_gpu_reset;
      enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index ec42a6f..a12ed54 100644
@@ -3983,6 +3983,10 @@ int amdgpu_device_resume(struct

drm_device

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

*dev, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct · line 3984

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
      if (adev->in_s0ix)
              amdgpu_gfx_state_change_set(adev,

sGpuChangeState_D0Entry);

Quoted 1 line
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
+   if (!adev->pm_completed) {
+           dev_warn(adev->dev, "suspend aborted will do asic

reset\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
+           amdgpu_asic_reset(adev);
+   }
      /* post card */
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int

Quoted 8 lines
      if (amdgpu_device_need_post(adev)) {
              r = amdgpu_device_asic_init(adev); diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index eee3cf8..9f90017 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -2168,6 +2168,23 @@ static int

amdgpu_pmops_suspend(struct

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

device *dev)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
      return r;
    }
 
+/*
+ * Actually the PM suspend whether is completed should be

confirmed

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -0
+ * by checking the sysfs
+sys/power/suspend_stats/failed_suspend.However,
+ * in this function only check the AMDGPU device whether is

suspended
+ * completely in the system-wide suspend process.
+ */

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
+static int amdgpu_pmops_noirq_suspend(struct device *dev) {
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
+   struct amdgpu_device *adev = drm_to_adev(drm_dev);
+
+   dev_dbg(dev, "amdgpu suspend completely.\n");
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
+   adev->pm_completed = true;
+
+   return 0;
+}
+
    static int amdgpu_pmops_resume(struct device *dev)
    {
      struct drm_device *drm_dev = dev_get_drvdata(dev); @@ -

2181,6

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops

Quoted 9 lines

+2198,7 @@ static int amdgpu_pmops_resume(struct device *dev)

      r = amdgpu_device_resume(drm_dev, true);
      if (amdgpu_acpi_is_s0ix_active(adev))
              adev->in_s0ix = false;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
+   adev->pm_completed = false;
      return r;
    }
@@ -2397,6 +2415,7 @@ static const struct dev_pm_ops

amdgpu_pm_ops

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

= {

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
      .runtime_suspend = amdgpu_pmops_runtime_suspend,
      .runtime_resume = amdgpu_pmops_runtime_resume,
      .runtime_idle = amdgpu_pmops_runtime_idle,
+   .suspend_noirq = amdgpu_pmops_noirq_suspend,
    };
 
    static int amdgpu_flush(struct file *f, fl_owner_t id)