All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fix shutdown and poweroff process failed with s0ix
@ 2021-02-22  8:24 Prike Liang
  2021-02-22 18:25 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Prike Liang @ 2021-02-22  8:24 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Prike Liang, ray.huang

In the shutdown and poweroff opt on the s0i3 system we still need
un-gate the gfx clock gating and power gating before destory amdgpu device.

Bug: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2F-%2Fissues%2F1499&data=04%7C01%7CPrike.Liang%40amd.com%7C24759f57e2644f26deaf08d8d4302cc3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637492650673813454%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=I0rH%2FFt2cs%2BdNwvNdqWKPE%2B3bOosUyBodViUsEwb6tE%3D&reserved=0
Fixes: 628c36d7b238e2 ("drm/amdgpu: update amdgpu device suspend/resume sequence for s0i3 support")

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Prike Liang <Prike.Liang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 9 ++++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 9bf7f49..0035c91 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1007,6 +1007,12 @@ struct amdgpu_device {
 	bool                            in_suspend;
 	bool				in_hibernate;
 
+	/*
+	 * The combination flag in_poweroff_reboot_com used to identify the poweroff
+	 * and reboot opt in the s0i3 system-wide suspend.
+	 */
+	bool 				in_poweroff_reboot_com;
+
 	atomic_t 			in_gpu_reset;
 	enum pp_mp1_state               mp1_state;
 	struct rw_semaphore reset_sem;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2f9ad7e..f0f7ed4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2676,7 +2676,8 @@ static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)
 {
 	int i, r;
 
-	if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
+	if (adev->in_poweroff_reboot_com ||
+	    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
 		amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
 		amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
 	}
@@ -3739,7 +3740,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 
 	amdgpu_fence_driver_suspend(adev);
 
-	if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
+	if (adev->in_poweroff_reboot_com ||
+	    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
 		r = amdgpu_device_ip_suspend_phase2(adev);
 	else
 		amdgpu_gfx_state_change_set(adev, sGpuChangeState_D3Entry);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index b7ee587..b539628 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1278,7 +1278,9 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
 	 */
 	if (!amdgpu_passthrough(adev))
 		adev->mp1_state = PP_MP1_STATE_UNLOAD;
+	adev->in_poweroff_reboot_com = true;
 	amdgpu_device_ip_suspend(adev);
+	adev->in_poweroff_reboot_com = false;
 	adev->mp1_state = PP_MP1_STATE_NONE;
 }
 
@@ -1320,8 +1322,13 @@ static int amdgpu_pmops_thaw(struct device *dev)
 static int amdgpu_pmops_poweroff(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_to_adev(drm_dev);
+	int r;
 
-	return amdgpu_device_suspend(drm_dev, true);
+	adev->in_poweroff_reboot_com = true;
+	r =  amdgpu_device_suspend(drm_dev, true);
+	adev->in_poweroff_reboot_com = false;
+	return r;
 }
 
 static int amdgpu_pmops_restore(struct device *dev)
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amdgpu: fix shutdown and poweroff process failed with s0ix
  2021-02-22  8:24 [PATCH] drm/amdgpu: fix shutdown and poweroff process failed with s0ix Prike Liang
@ 2021-02-22 18:25 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2021-02-22 18:25 UTC (permalink / raw)
  To: Prike Liang; +Cc: Alex Deucher, Huang Rui, amd-gfx list

On Mon, Feb 22, 2021 at 3:25 AM Prike Liang <Prike.Liang@amd.com> wrote:
>
> In the shutdown and poweroff opt on the s0i3 system we still need
> un-gate the gfx clock gating and power gating before destory amdgpu device.
>
> Bug: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2F-%2Fissues%2F1499&amp;data=04%7C01%7CPrike.Liang%40amd.com%7C24759f57e2644f26deaf08d8d4302cc3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637492650673813454%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=I0rH%2FFt2cs%2BdNwvNdqWKPE%2B3bOosUyBodViUsEwb6tE%3D&amp;reserved=0
> Fixes: 628c36d7b238e2 ("drm/amdgpu: update amdgpu device suspend/resume sequence for s0i3 support")
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Prike Liang <Prike.Liang@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 6 ++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 9 ++++++++-
>  3 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 9bf7f49..0035c91 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1007,6 +1007,12 @@ struct amdgpu_device {
>         bool                            in_suspend;
>         bool                            in_hibernate;
>
> +       /*
> +        * The combination flag in_poweroff_reboot_com used to identify the poweroff
> +        * and reboot opt in the s0i3 system-wide suspend.
> +        */
> +       bool                            in_poweroff_reboot_com;
> +
>         atomic_t                        in_gpu_reset;
>         enum pp_mp1_state               mp1_state;
>         struct rw_semaphore reset_sem;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 2f9ad7e..f0f7ed4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2676,7 +2676,8 @@ static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)
>  {
>         int i, r;
>
> -       if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
> +       if (adev->in_poweroff_reboot_com ||
> +           !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
>                 amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
>                 amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
>         }
> @@ -3739,7 +3740,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
>
>         amdgpu_fence_driver_suspend(adev);
>
> -       if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
> +       if (adev->in_poweroff_reboot_com ||
> +           !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
>                 r = amdgpu_device_ip_suspend_phase2(adev);
>         else
>                 amdgpu_gfx_state_change_set(adev, sGpuChangeState_D3Entry);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index b7ee587..b539628 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1278,7 +1278,9 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
>          */
>         if (!amdgpu_passthrough(adev))
>                 adev->mp1_state = PP_MP1_STATE_UNLOAD;
> +       adev->in_poweroff_reboot_com = true;
>         amdgpu_device_ip_suspend(adev);
> +       adev->in_poweroff_reboot_com = false;
>         adev->mp1_state = PP_MP1_STATE_NONE;
>  }
>
> @@ -1320,8 +1322,13 @@ static int amdgpu_pmops_thaw(struct device *dev)
>  static int amdgpu_pmops_poweroff(struct device *dev)
>  {
>         struct drm_device *drm_dev = dev_get_drvdata(dev);
> +       struct amdgpu_device *adev = drm_to_adev(drm_dev);
> +       int r;
>
> -       return amdgpu_device_suspend(drm_dev, true);
> +       adev->in_poweroff_reboot_com = true;
> +       r =  amdgpu_device_suspend(drm_dev, true);
> +       adev->in_poweroff_reboot_com = false;
> +       return r;
>  }
>
>  static int amdgpu_pmops_restore(struct device *dev)
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-22 18:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22  8:24 [PATCH] drm/amdgpu: fix shutdown and poweroff process failed with s0ix Prike Liang
2021-02-22 18:25 ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.