Skip to contentSkip to conversation

Misc runpm and baco fixes

PATCH In review Alex Deucher 2 participants 12 messages Oct 10, 2019 – Oct 12, 2019 6 messages not in the archive

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

cover Misc runpm and baco fixes

While cleaning up the runtime pm code in amdgpu,
I came across a few things. These patches fix
them up. Please review!

Alex Deucher (5):
drm/amdgpu: move pci_save_state into suspend path drm/amdgpu: move gpu reset out of amdgpu_device_suspend drm/amdgpu: simplify ATPX detection drm/amdgpu: remove in_baco_reset hack drm/amdgpu/soc15: add support for baco reset with swSMU

 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  2 -
 .../gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c  | 12 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  6 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       |  7 ++-
 drivers/gpu/drm/amd/amdgpu/soc15.c            | 53 ++++++++++++-------
 .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c    |  4 +-
 6 files changed, 43 insertions(+), 41 deletions(-)
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): 20191010152619.31011-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/5 drm/amdgpu: move pci_save_state into suspend path

for amdgpu_device_suspend. This follows the logic in the resume path.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index f25275abf408..9b9b15360194 100644
@@ -3168,8 +3168,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 	 */
 	amdgpu_bo_evict_vram(adev);
 
-	pci_save_state(dev->pdev);
 	if (suspend) {
+		pci_save_state(dev->pdev);
 		/* Shut down the device */
 		pci_disable_device(dev->pdev);
 		pci_set_power_state(dev->pdev, PCI_D3hot);
Signature · 6 lines
2.20.1

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

PATCH 2/5 drm/amdgpu: move gpu reset out of amdgpu_device_suspend

In reply to a message not in the archive

Move it into the caller. There are cases were we don't want it. We need it for hibernation, but we don't need it for runtime pm.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index 9b9b15360194..91bdb246e405 100644
@@ -3173,10 +3173,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 		/* Shut down the device */
 		pci_disable_device(dev->pdev);
 		pci_set_power_state(dev->pdev, PCI_D3hot);
-	} else {
-		r = amdgpu_asic_reset(adev);
-		if (r)
-			DRM_ERROR("amdgpu asic reset failed\n");
 	}
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -1
index d43c46de7807..64141386e603 100644
@@ -1118,8 +1118,13 @@ static int amdgpu_pmops_resume(struct device *dev)
 static int amdgpu_pmops_freeze(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_dev->dev_private;
+	int r;
 
-	return amdgpu_device_suspend(drm_dev, false, true);
+	r = amdgpu_device_suspend(drm_dev, false, true);
+	if (r)
+		return r;
+	return amdgpu_asic_reset(adev);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
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): 20191010152619.31011-3-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#5 lore raw

RE: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

It seems amdgpu_pmops_runtime_suspend() needs to be updated accordingly also.

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 10, 2019 11:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Move it into the caller. There are cases were we don't want it. We need it for hibernation, but we don't need it for runtime pm.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index 9b9b15360194..91bdb246e405 100644
@@ -3173,10 +3173,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 		/* Shut down the device */
 		pci_disable_device(dev->pdev);
 		pci_set_power_state(dev->pdev, PCI_D3hot);
-	} else {
-		r = amdgpu_asic_reset(adev);
-		if (r)
-			DRM_ERROR("amdgpu asic reset failed\n");
 	}
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -1
index d43c46de7807..64141386e603 100644
@@ -1118,8 +1118,13 @@ static int amdgpu_pmops_resume(struct device *dev)
 static int amdgpu_pmops_freeze(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_dev->dev_private;
+	int r;
 
-	return amdgpu_device_suspend(drm_dev, false, true);
+	r = amdgpu_device_suspend(drm_dev, false, true);
+	if (r)
+		return r;
+	return amdgpu_asic_reset(adev);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
Signature · 10 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): BN8PR12MB3329E4B5DE6B027D43B38F5AE4970-h6+T2+wrnx3WSNCBJ7MpiAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#7 lore raw

RE: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Quoted 1 line

There are cases were we don't want it.

Typo: were -> where?

-----Original Message-----
From: Quan, Evan
Sent: Friday, October 11, 2019 12:07 PM
To: Alex Deucher <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

It seems amdgpu_pmops_runtime_suspend() needs to be updated accordingly also.

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 10, 2019 11:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Move it into the caller. There are cases were we don't want it. We need it for hibernation, but we don't need it for runtime pm.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index 9b9b15360194..91bdb246e405 100644
@@ -3173,10 +3173,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 		/* Shut down the device */
 		pci_disable_device(dev->pdev);
 		pci_set_power_state(dev->pdev, PCI_D3hot);
-	} else {
-		r = amdgpu_asic_reset(adev);
-		if (r)
-			DRM_ERROR("amdgpu asic reset failed\n");
 	}
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -2
index d43c46de7807..64141386e603 100644
@@ -1118,8 +1118,13 @@ static int amdgpu_pmops_resume(struct device *dev)  static int amdgpu_pmops_freeze(struct device *dev)  {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_dev->dev_private;
+	int r;
 
-	return amdgpu_device_suspend(drm_dev, false, true);
+	r = amdgpu_device_suspend(drm_dev, false, true);
+	if (r)
+		return r;
+	return amdgpu_asic_reset(adev);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
--

2.20.1

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

#8 lore raw

Re: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

In reply to a message not in the archive
Quoted 2 lines · Evan

It seems amdgpu_pmops_runtime_suspend() needs to be updated accordingly also.

I purposely left that out. I think that is a bug. We don't need to reset the GPU for runtime suspend. We only need it for hibernation because of the whole freeze/thaw dance.

Alex

Quoted 55 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 10, 2019 11:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Move it into the caller. There are cases were we don't want it. We need it for hibernation, but we don't need it for runtime pm.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index 9b9b15360194..91bdb246e405 100644
@@ -3173,10 +3173,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
                /* Shut down the device */
                pci_disable_device(dev->pdev);
                pci_set_power_state(dev->pdev, PCI_D3hot);
-       } else {
-               r = amdgpu_asic_reset(adev);
-               if (r)
-                       DRM_ERROR("amdgpu asic reset failed\n");
        }
 
        return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -2
index d43c46de7807..64141386e603 100644
@@ -1118,8 +1118,13 @@ static int amdgpu_pmops_resume(struct device *dev)
 static int amdgpu_pmops_freeze(struct device *dev)
 {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
+       struct amdgpu_device *adev = drm_dev->dev_private;
+       int r;
 
-       return amdgpu_device_suspend(drm_dev, false, true);
+       r = amdgpu_device_suspend(drm_dev, false, true);
+       if (r)
+               return r;
+       return amdgpu_asic_reset(adev);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
--

2.20.1

Quoted 4 lines

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

_______________________________________________
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): CADnq5_Pbi+K=62tY0sJdOARy74wpnh+Owfq3wQb0tcyXE2XtFw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Reviewed-by Evan Quan
#10 lore raw

RE: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Thanks for the clarification. That will be fine then.

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, October 11, 2019 9:25 PM
To: Quan, Evan <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Quoted 2 lines · Evan

It seems amdgpu_pmops_runtime_suspend() needs to be updated accordingly also.

I purposely left that out. I think that is a bug. We don't need to reset the GPU for runtime suspend. We only need it for hibernation because of the whole freeze/thaw dance.

Alex

Quoted 57 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 10, 2019 11:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Move it into the caller. There are cases were we don't want it. We need it for hibernation, but we don't need it for runtime pm.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index 9b9b15360194..91bdb246e405 100644
@@ -3173,10 +3173,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
                /* Shut down the device */
                pci_disable_device(dev->pdev);
                pci_set_power_state(dev->pdev, PCI_D3hot);
-       } else {
-               r = amdgpu_asic_reset(adev);
-               if (r)
-                       DRM_ERROR("amdgpu asic reset failed\n");
        }
 
        return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -2
index d43c46de7807..64141386e603 100644
@@ -1118,8 +1118,13 @@ static int amdgpu_pmops_resume(struct device 
 *dev)  static int amdgpu_pmops_freeze(struct device *dev)  {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
+       struct amdgpu_device *adev = drm_dev->dev_private;
+       int r;
 
-       return amdgpu_device_suspend(drm_dev, false, true);
+       r = amdgpu_device_suspend(drm_dev, false, true);
+       if (r)
+               return r;
+       return amdgpu_asic_reset(adev);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
--

2.20.1

Quoted 4 lines

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

_______________________________________________
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): MN2PR12MB3344923284A5FF12F631B634E4960-rweVpJHSKToDMgCC8P//[email protected]

#12 lore raw

Re: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Thanks. I'll make note of this in the commit message.

Quoted 72 lines · Evan

Thanks for the clarification. That will be fine then.

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, October 11, 2019 9:25 PM
To: Quan, Evan <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Quoted 2 lines · Evan

It seems amdgpu_pmops_runtime_suspend() needs to be updated accordingly also.

I purposely left that out. I think that is a bug. We don't need to reset the GPU for runtime suspend. We only need it for hibernation because of the whole freeze/thaw dance.

Alex

Quoted 53 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 10, 2019 11:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/5] drm/amdgpu: move gpu reset out of amdgpu_device_suspend

Move it into the caller. There are cases were we don't want it. We need it for hibernation, but we don't need it for runtime pm.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -4
index 9b9b15360194..91bdb246e405 100644
@@ -3173,10 +3173,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
                /* Shut down the device */
                pci_disable_device(dev->pdev);
                pci_set_power_state(dev->pdev, PCI_D3hot);
-       } else {
-               r = amdgpu_asic_reset(adev);
-               if (r)
-                       DRM_ERROR("amdgpu asic reset failed\n");
        }
 
        return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -1
index d43c46de7807..64141386e603 100644
@@ -1118,8 +1118,13 @@ static int amdgpu_pmops_resume(struct device
 *dev)  static int amdgpu_pmops_freeze(struct device *dev)  {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
+       struct amdgpu_device *adev = drm_dev->dev_private;
+       int r;
 
-       return amdgpu_device_suspend(drm_dev, false, true);
+       r = amdgpu_device_suspend(drm_dev, false, true);
+       if (r)
+               return r;
+       return amdgpu_asic_reset(adev);
 }
 
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
 static int amdgpu_pmops_thaw(struct device *dev)
--

2.20.1

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

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

#13 lore raw

PATCH 3/5 drm/amdgpu: simplify ATPX detection

In reply to a message not in the archive

Use the base class rather than the specific class and drop the second loop.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +1 -11
index 3e35a8f2c5e5..a97fb759e2f4 100644
@@ -613,17 +613,7 @@ static bool amdgpu_atpx_detect(void)
 	bool d3_supported = false;
 	struct pci_dev *parent_pdev;
 
-	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
-		vga_count++;
-
-		has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
-
-		parent_pdev = pci_upstream_bridge(pdev);
-		d3_supported |= parent_pdev && parent_pdev->bridge_d3;
-		amdgpu_atpx_get_quirks(pdev);
-	}
-
-	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
+	while ((pdev = pci_get_class(PCI_BASE_CLASS_DISPLAY << 16, pdev)) != NULL) {
 		vga_count++;
 
 		has_atpx |= (amdgpu_atpx_pci_probe_handle(pdev) == true);
Signature · 6 lines
2.20.1

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

PATCH 4/5 drm/amdgpu: remove in_baco_reset hack

In reply to a message not in the archive

It was a vega20 specific hack. Check if we are in reset and what reset method we are using.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h                | 2 --
 drivers/gpu/drm/amd/amdgpu/soc15.c                 | 2 --
 drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 4 ++--
 3 files changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -2
index c82579c93265..438775d54a6a 100644
@@ -959,8 +959,6 @@ struct amdgpu_device {
 	int asic_reset_res;
 	struct work_struct		xgmi_reset_work;
 
-	bool                            in_baco_reset;
-
 	long				gfx_timeout;
 	long				sdma_timeout;
 	long				video_timeout;
drivers/gpu/drm/amd/amdgpu/soc15.c +0 -2
index fc6cfbced170..d17568dd9e87 100644
@@ -507,8 +507,6 @@ static int soc15_asic_baco_reset(struct amdgpu_device *adev)
 
 	dev_info(adev->dev, "GPU BACO reset\n");
 
-	adev->in_baco_reset = 1;
-
 	return 0;
 }
 
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +2 -2
index f5915308e643..892f9f5389b9 100644
@@ -490,8 +490,8 @@ static int vega20_setup_asic_task(struct pp_hwmgr *hwmgr)
 			"Failed to init sclk threshold!",
 			return ret);
 
-	if (adev->in_baco_reset) {
-		adev->in_baco_reset = 0;
+	if (adev->in_gpu_reset &&
+	    (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)) {
 
 		ret = vega20_baco_apply_vdci_flush_workaround(hwmgr);
 		if (ret)
Signature · 6 lines
2.20.1

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

PATCH 5/5 drm/amdgpu/soc15: add support for baco reset with swSMU

In reply to a message not in the archive

Add support for vega20 when the swSMU path is used.

---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 53 +++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +34 -19
index d17568dd9e87..b3291a19a771 100644
@@ -478,36 +478,51 @@ static int soc15_asic_mode1_reset(struct amdgpu_device *adev)
 
 static int soc15_asic_get_baco_capability(struct amdgpu_device *adev, bool *cap)
 {
-	void *pp_handle = adev->powerplay.pp_handle;
-	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	if (is_support_sw_smu(adev)) {
+		struct smu_context *smu = &adev->smu;
 
-	if (!pp_funcs || !pp_funcs->get_asic_baco_capability) {
-		*cap = false;
-		return -ENOENT;
-	}
+		*cap = smu_baco_is_support(smu);
+		return 0;
+	} else {
+		void *pp_handle = adev->powerplay.pp_handle;
+		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 
-	return pp_funcs->get_asic_baco_capability(pp_handle, cap);
+		if (!pp_funcs || !pp_funcs->get_asic_baco_capability) {
+			*cap = false;
+			return -ENOENT;
+		}
+
+		return pp_funcs->get_asic_baco_capability(pp_handle, cap);
+	}
 }
 
 static int soc15_asic_baco_reset(struct amdgpu_device *adev)
 {
-	void *pp_handle = adev->powerplay.pp_handle;
-	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	if (is_support_sw_smu(adev)) {
+		struct smu_context *smu = &adev->smu;
 
-	if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state)
-		return -ENOENT;
+		dev_info(adev->dev, "GPU BACO reset\n");
+
+		return smu_baco_reset(smu);
+	} else {
+		void *pp_handle = adev->powerplay.pp_handle;
+		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 
-	/* enter BACO state */
-	if (pp_funcs->set_asic_baco_state(pp_handle, 1))
-		return -EIO;
+		if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state)
+			return -ENOENT;
 
-	/* exit BACO state */
-	if (pp_funcs->set_asic_baco_state(pp_handle, 0))
-		return -EIO;
+		/* enter BACO state */
+		if (pp_funcs->set_asic_baco_state(pp_handle, 1))
+			return -EIO;
 
-	dev_info(adev->dev, "GPU BACO reset\n");
+		/* exit BACO state */
+		if (pp_funcs->set_asic_baco_state(pp_handle, 0))
+			return -EIO;
 
-	return 0;
+		dev_info(adev->dev, "GPU BACO reset\n");
+
+		return 0;
+	}
 }
 
 static int soc15_mode2_reset(struct amdgpu_device *adev)
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): 20191010152619.31011-6-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#17 lore raw

RE: [PATCH 5/5] drm/amdgpu/soc15: add support for baco reset with swSMU

Except patch2, series is reviewed-by: Evan Quan <[email protected]>

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, October 10, 2019 11:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 5/5] drm/amdgpu/soc15: add support for baco reset with swSMU

Add support for vega20 when the swSMU path is used.

---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 53 +++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +34 -20
index d17568dd9e87..b3291a19a771 100644
@@ -478,36 +478,51 @@ static int soc15_asic_mode1_reset(struct amdgpu_device *adev)
 
 static int soc15_asic_get_baco_capability(struct amdgpu_device *adev, bool *cap)  {
-	void *pp_handle = adev->powerplay.pp_handle;
-	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	if (is_support_sw_smu(adev)) {
+		struct smu_context *smu = &adev->smu;
 
-	if (!pp_funcs || !pp_funcs->get_asic_baco_capability) {
-		*cap = false;
-		return -ENOENT;
-	}
+		*cap = smu_baco_is_support(smu);
+		return 0;
+	} else {
+		void *pp_handle = adev->powerplay.pp_handle;
+		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 
-	return pp_funcs->get_asic_baco_capability(pp_handle, cap);
+		if (!pp_funcs || !pp_funcs->get_asic_baco_capability) {
+			*cap = false;
+			return -ENOENT;
+		}
+
+		return pp_funcs->get_asic_baco_capability(pp_handle, cap);
+	}
 }
 
 static int soc15_asic_baco_reset(struct amdgpu_device *adev)  {
-	void *pp_handle = adev->powerplay.pp_handle;
-	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	if (is_support_sw_smu(adev)) {
+		struct smu_context *smu = &adev->smu;
 
-	if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state)
-		return -ENOENT;
+		dev_info(adev->dev, "GPU BACO reset\n");
+
+		return smu_baco_reset(smu);
+	} else {
+		void *pp_handle = adev->powerplay.pp_handle;
+		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 
-	/* enter BACO state */
-	if (pp_funcs->set_asic_baco_state(pp_handle, 1))
-		return -EIO;
+		if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state)
+			return -ENOENT;
 
-	/* exit BACO state */
-	if (pp_funcs->set_asic_baco_state(pp_handle, 0))
-		return -EIO;
+		/* enter BACO state */
+		if (pp_funcs->set_asic_baco_state(pp_handle, 1))
+			return -EIO;
 
-	dev_info(adev->dev, "GPU BACO reset\n");
+		/* exit BACO state */
+		if (pp_funcs->set_asic_baco_state(pp_handle, 0))
+			return -EIO;
 
-	return 0;
+		dev_info(adev->dev, "GPU BACO reset\n");
+
+		return 0;
+	}
 }
 
 static int soc15_mode2_reset(struct amdgpu_device *adev)
--

2.20.1

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