drm/amd/amdgpu: S4 issue for amdgpu

Submitted by Qu, Jim on Sept. 1, 2016, 6:22 a.m.

Details

Message ID 1472710922-7977-1-git-send-email-Jim.Qu@amd.com
State New
Headers show
Series "drm/amd/amdgpu: S4 issue for amdgpu" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Qu, Jim Sept. 1, 2016, 6:22 a.m.
reset the asic if adapter is not powerdown when doing freeze()
thaw() and restore(), in order to get a valid state of adapter.

Change-Id: Id2e4587c06b556eb651ab9277ffc903f780dea56
Signed-off-by: JimQu <Jim.Qu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++--
 2 files changed, 19 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 52cec16..5fc76bbf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1936,8 +1936,14 @@  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");
 	}
 
+	amdgpu_atombios_fini(adev);
+
 	if (fbcon) {
 		console_lock();
 		amdgpu_fbdev_set_suspend(adev, 1);
@@ -1965,21 +1971,23 @@  int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
 	if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
 		return 0;
 
-	if (fbcon) {
+	if (fbcon)
 		console_lock();
-	}
+
+	amdgpu_atombios_init(adev);
+
 	if (resume) {
 		pci_set_power_state(dev->pdev, PCI_D0);
 		pci_restore_state(dev->pdev);
-		if (pci_enable_device(dev->pdev)) {
+		if (r = pci_enable_device(dev->pdev)) {
 			if (fbcon)
 				console_unlock();
-			return -1;
+			return r;
 		}
 	}
 
 	/* post card */
-	if (!amdgpu_card_posted(adev))
+	if (!amdgpu_card_posted(adev) || !resume)
 		amdgpu_atom_asic_init(adev->mode_info.atom_context);
 
 	r = amdgpu_resume(adev);
@@ -1998,8 +2006,11 @@  int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
 	}
 
 	r = amdgpu_late_init(adev);
-	if (r)
+	if (r) {
+		if (fbcon)
+			console_unlock();
 		return r;
+	}
 
 	/* pin cursors */
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 06816cf..02941db3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -601,8 +601,8 @@  static const struct dev_pm_ops amdgpu_pm_ops = {
 	.resume = amdgpu_pmops_resume,
 	.freeze = amdgpu_pmops_freeze,
 	.thaw = amdgpu_pmops_thaw,
-	.poweroff = amdgpu_pmops_freeze,
-	.restore = amdgpu_pmops_resume,
+	.poweroff = amdgpu_pmops_suspend,
+	.restore = amdgpu_pmops_thaw,
 	.runtime_suspend = amdgpu_pmops_runtime_suspend,
 	.runtime_resume = amdgpu_pmops_runtime_resume,
 	.runtime_idle = amdgpu_pmops_runtime_idle,

Comments

On Thu, Sep 1, 2016 at 2:22 AM, jimqu <Jim.Qu@amd.com> wrote:
> reset the asic if adapter is not powerdown when doing freeze()
> thaw() and restore(), in order to get a valid state of adapter.
>
> Change-Id: Id2e4587c06b556eb651ab9277ffc903f780dea56
> Signed-off-by: JimQu <Jim.Qu@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++--
>  2 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 52cec16..5fc76bbf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1936,8 +1936,14 @@ 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");
>         }
>
> +       amdgpu_atombios_fini(adev);
> +

Why do you need atombios_fini() here?  All it does it free the driver
allocations.

>         if (fbcon) {
>                 console_lock();
>                 amdgpu_fbdev_set_suspend(adev, 1);
> @@ -1965,21 +1971,23 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
>         if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
>                 return 0;
>
> -       if (fbcon) {
> +       if (fbcon)
>                 console_lock();
> -       }
> +
> +       amdgpu_atombios_init(adev);
> +

Same question here.  This doesn't actually change any hw state.

>         if (resume) {
>                 pci_set_power_state(dev->pdev, PCI_D0);
>                 pci_restore_state(dev->pdev);
> -               if (pci_enable_device(dev->pdev)) {
> +               if (r = pci_enable_device(dev->pdev)) {
>                         if (fbcon)
>                                 console_unlock();
> -                       return -1;
> +                       return r;
>                 }
>         }
>
>         /* post card */
> -       if (!amdgpu_card_posted(adev))
> +       if (!amdgpu_card_posted(adev) || !resume)
>                 amdgpu_atom_asic_init(adev->mode_info.atom_context);
>
>         r = amdgpu_resume(adev);
> @@ -1998,8 +2006,11 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
>         }
>
>         r = amdgpu_late_init(adev);
> -       if (r)
> +       if (r) {
> +               if (fbcon)
> +                       console_unlock();
>                 return r;
> +       }
>
>         /* pin cursors */
>         list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 06816cf..02941db3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -601,8 +601,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = {
>         .resume = amdgpu_pmops_resume,
>         .freeze = amdgpu_pmops_freeze,
>         .thaw = amdgpu_pmops_thaw,
> -       .poweroff = amdgpu_pmops_freeze,
> -       .restore = amdgpu_pmops_resume,
> +       .poweroff = amdgpu_pmops_suspend,
> +       .restore = amdgpu_pmops_thaw,
>         .runtime_suspend = amdgpu_pmops_runtime_suspend,
>         .runtime_resume = amdgpu_pmops_runtime_resume,
>         .runtime_idle = amdgpu_pmops_runtime_idle,
> --
> 1.9.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Alex:

Weird, last day, I used the fiji to check the S4 issue, there are some atom errors, but it did not observed if add atombios_fini/init.
today, I change another fiji and  also check the issue with the patch which comment out the atombios_fini/init. but could not see the atombios error.
I will confirm it and update the patch.

Error like:

[   81.167263] [drm:atom_op_jump [amdgpu]] *ERROR* atombios stuck in loop for more than 5secs aborting
[   81.167276] [drm:amdgpu_atom_execute_table_locked [amdgpu]] *ERROR* atombios stuck executing D208 (len 239, WS 4, PS 0) @ 0xD2AB
[   81.167288] [drm:amdgpu_atom_execute_table_locked [amdgpu]] *ERROR* atombios stuck executing B586 (len 96, WS 0, PS 4) @ 0xB5C2
[   81.167299] [drm:amdgpu_atom_execute_table_locked [amdgpu]] *ERROR* atombios stuck executing B104 (len 183, WS 0, PS 8) @ 0xB1AC

Thanks
JimQu

________________________________________
发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Alex Deucher <alexdeucher@gmail.com>
发送时间: 2016年9月1日 21:42:46
收件人: Qu, Jim
抄送: amd-gfx list
主题: Re: [PATCH] drm/amd/amdgpu: S4 issue for amdgpu

On Thu, Sep 1, 2016 at 2:22 AM, jimqu <Jim.Qu@amd.com> wrote:
> reset the asic if adapter is not powerdown when doing freeze()

> thaw() and restore(), in order to get a valid state of adapter.

>

> Change-Id: Id2e4587c06b556eb651ab9277ffc903f780dea56

> Signed-off-by: JimQu <Jim.Qu@amd.com>

> ---

>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++------

>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++--

>  2 files changed, 19 insertions(+), 8 deletions(-)

>

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> index 52cec16..5fc76bbf 100644

> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> @@ -1936,8 +1936,14 @@ 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");

>         }

>

> +       amdgpu_atombios_fini(adev);

> +


Why do you need atombios_fini() here?  All it does it free the driver
allocations.

>         if (fbcon) {

>                 console_lock();

>                 amdgpu_fbdev_set_suspend(adev, 1);

> @@ -1965,21 +1971,23 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)

>         if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)

>                 return 0;

>

> -       if (fbcon) {

> +       if (fbcon)

>                 console_lock();

> -       }

> +

> +       amdgpu_atombios_init(adev);

> +


Same question here.  This doesn't actually change any hw state.

>         if (resume) {

>                 pci_set_power_state(dev->pdev, PCI_D0);

>                 pci_restore_state(dev->pdev);

> -               if (pci_enable_device(dev->pdev)) {

> +               if (r = pci_enable_device(dev->pdev)) {

>                         if (fbcon)

>                                 console_unlock();

> -                       return -1;

> +                       return r;

>                 }

>         }

>

>         /* post card */

> -       if (!amdgpu_card_posted(adev))

> +       if (!amdgpu_card_posted(adev) || !resume)

>                 amdgpu_atom_asic_init(adev->mode_info.atom_context);

>

>         r = amdgpu_resume(adev);

> @@ -1998,8 +2006,11 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)

>         }

>

>         r = amdgpu_late_init(adev);

> -       if (r)

> +       if (r) {

> +               if (fbcon)

> +                       console_unlock();

>                 return r;

> +       }

>

>         /* pin cursors */

>         list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> index 06816cf..02941db3 100644

> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> @@ -601,8 +601,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = {

>         .resume = amdgpu_pmops_resume,

>         .freeze = amdgpu_pmops_freeze,

>         .thaw = amdgpu_pmops_thaw,

> -       .poweroff = amdgpu_pmops_freeze,

> -       .restore = amdgpu_pmops_resume,

> +       .poweroff = amdgpu_pmops_suspend,

> +       .restore = amdgpu_pmops_thaw,

>         .runtime_suspend = amdgpu_pmops_runtime_suspend,

>         .runtime_resume = amdgpu_pmops_runtime_resume,

>         .runtime_idle = amdgpu_pmops_runtime_idle,

> --

> 1.9.1

>

> _______________________________________________

> 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
Hi Alex:

The atombios issue seems to be caused by my test driver. and I reinstall a clear driver without atombios_fini/init. it is OK for S4. So please ignore the atombios_fini/init functions in the patch, I will delete them if get RB.

Thanks
JimQu

________________________________________
发件人: Qu, Jim
发送时间: 2016年9月2日 9:07:26
收件人: Alex Deucher
抄送: amd-gfx list
主题: 答复: [PATCH] drm/amd/amdgpu: S4 issue for amdgpu

Hi Alex:

Weird, last day, I used the fiji to check the S4 issue, there are some atom errors, but it did not observed if add atombios_fini/init.
today, I change another fiji and  also check the issue with the patch which comment out the atombios_fini/init. but could not see the atombios error.
I will confirm it and update the patch.

Error like:

[   81.167263] [drm:atom_op_jump [amdgpu]] *ERROR* atombios stuck in loop for more than 5secs aborting
[   81.167276] [drm:amdgpu_atom_execute_table_locked [amdgpu]] *ERROR* atombios stuck executing D208 (len 239, WS 4, PS 0) @ 0xD2AB
[   81.167288] [drm:amdgpu_atom_execute_table_locked [amdgpu]] *ERROR* atombios stuck executing B586 (len 96, WS 0, PS 4) @ 0xB5C2
[   81.167299] [drm:amdgpu_atom_execute_table_locked [amdgpu]] *ERROR* atombios stuck executing B104 (len 183, WS 0, PS 8) @ 0xB1AC

Thanks
JimQu

________________________________________
发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Alex Deucher <alexdeucher@gmail.com>
发送时间: 2016年9月1日 21:42:46
收件人: Qu, Jim
抄送: amd-gfx list
主题: Re: [PATCH] drm/amd/amdgpu: S4 issue for amdgpu

On Thu, Sep 1, 2016 at 2:22 AM, jimqu <Jim.Qu@amd.com> wrote:
> reset the asic if adapter is not powerdown when doing freeze()

> thaw() and restore(), in order to get a valid state of adapter.

>

> Change-Id: Id2e4587c06b556eb651ab9277ffc903f780dea56

> Signed-off-by: JimQu <Jim.Qu@amd.com>

> ---

>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++------

>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++--

>  2 files changed, 19 insertions(+), 8 deletions(-)

>

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> index 52cec16..5fc76bbf 100644

> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> @@ -1936,8 +1936,14 @@ 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");

>         }

>

> +       amdgpu_atombios_fini(adev);

> +


Why do you need atombios_fini() here?  All it does it free the driver
allocations.

>         if (fbcon) {

>                 console_lock();

>                 amdgpu_fbdev_set_suspend(adev, 1);

> @@ -1965,21 +1971,23 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)

>         if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)

>                 return 0;

>

> -       if (fbcon) {

> +       if (fbcon)

>                 console_lock();

> -       }

> +

> +       amdgpu_atombios_init(adev);

> +


Same question here.  This doesn't actually change any hw state.

>         if (resume) {

>                 pci_set_power_state(dev->pdev, PCI_D0);

>                 pci_restore_state(dev->pdev);

> -               if (pci_enable_device(dev->pdev)) {

> +               if (r = pci_enable_device(dev->pdev)) {

>                         if (fbcon)

>                                 console_unlock();

> -                       return -1;

> +                       return r;

>                 }

>         }

>

>         /* post card */

> -       if (!amdgpu_card_posted(adev))

> +       if (!amdgpu_card_posted(adev) || !resume)

>                 amdgpu_atom_asic_init(adev->mode_info.atom_context);

>

>         r = amdgpu_resume(adev);

> @@ -1998,8 +2006,11 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)

>         }

>

>         r = amdgpu_late_init(adev);

> -       if (r)

> +       if (r) {

> +               if (fbcon)

> +                       console_unlock();

>                 return r;

> +       }

>

>         /* pin cursors */

>         list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> index 06816cf..02941db3 100644

> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> @@ -601,8 +601,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = {

>         .resume = amdgpu_pmops_resume,

>         .freeze = amdgpu_pmops_freeze,

>         .thaw = amdgpu_pmops_thaw,

> -       .poweroff = amdgpu_pmops_freeze,

> -       .restore = amdgpu_pmops_resume,

> +       .poweroff = amdgpu_pmops_suspend,

> +       .restore = amdgpu_pmops_thaw,

>         .runtime_suspend = amdgpu_pmops_runtime_suspend,

>         .runtime_resume = amdgpu_pmops_runtime_resume,

>         .runtime_idle = amdgpu_pmops_runtime_idle,

> --

> 1.9.1

>

> _______________________________________________

> 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
> -----Original Message-----

> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf

> Of Qu, Jim

> Sent: Thursday, September 01, 2016 9:07 PM

> To: Alex Deucher

> Cc: amd-gfx list

> Subject: 答复: [PATCH] drm/amd/amdgpu: S4 issue for amdgpu

> 

> Hi Alex:

> 

> Weird, last day, I used the fiji to check the S4 issue, there are some atom

> errors, but it did not observed if add atombios_fini/init.

> today, I change another fiji and  also check the issue with the patch which

> comment out the atombios_fini/init. but could not see the atombios error.

> I will confirm it and update the patch.

> 

> Error like:

> 

> [   81.167263] [drm:atom_op_jump [amdgpu]] *ERROR* atombios stuck in

> loop for more than 5secs aborting

> [   81.167276] [drm:amdgpu_atom_execute_table_locked [amdgpu]]

> *ERROR* atombios stuck executing D208 (len 239, WS 4, PS 0) @ 0xD2AB

> [   81.167288] [drm:amdgpu_atom_execute_table_locked [amdgpu]]

> *ERROR* atombios stuck executing B586 (len 96, WS 0, PS 4) @ 0xB5C2

> [   81.167299] [drm:amdgpu_atom_execute_table_locked [amdgpu]]

> *ERROR* atombios stuck executing B104 (len 183, WS 0, PS 8) @ 0xB1AC


Errors like that are usually a symptom of the GPU being is a bad state rather than some software state.

Alex

> 

> Thanks

> JimQu

> 

> ________________________________________

> 发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Alex

> Deucher <alexdeucher@gmail.com>

> 发送时间: 2016年9月1日 21:42:46

> 收件人: Qu, Jim

> 抄送: amd-gfx list

> 主题: Re: [PATCH] drm/amd/amdgpu: S4 issue for amdgpu

> 

> On Thu, Sep 1, 2016 at 2:22 AM, jimqu <Jim.Qu@amd.com> wrote:

> > reset the asic if adapter is not powerdown when doing freeze()

> > thaw() and restore(), in order to get a valid state of adapter.

> >

> > Change-Id: Id2e4587c06b556eb651ab9277ffc903f780dea56

> > Signed-off-by: JimQu <Jim.Qu@amd.com>

> > ---

> >  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23

> +++++++++++++++++------

> >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++--

> >  2 files changed, 19 insertions(+), 8 deletions(-)

> >

> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> > index 52cec16..5fc76bbf 100644

> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

> > @@ -1936,8 +1936,14 @@ 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");

> >         }

> >

> > +       amdgpu_atombios_fini(adev);

> > +

> 

> Why do you need atombios_fini() here?  All it does it free the driver

> allocations.

> 

> >         if (fbcon) {

> >                 console_lock();

> >                 amdgpu_fbdev_set_suspend(adev, 1);

> > @@ -1965,21 +1971,23 @@ int amdgpu_device_resume(struct drm_device

> *dev, bool resume, bool fbcon)

> >         if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)

> >                 return 0;

> >

> > -       if (fbcon) {

> > +       if (fbcon)

> >                 console_lock();

> > -       }

> > +

> > +       amdgpu_atombios_init(adev);

> > +

> 

> Same question here.  This doesn't actually change any hw state.

> 

> >         if (resume) {

> >                 pci_set_power_state(dev->pdev, PCI_D0);

> >                 pci_restore_state(dev->pdev);

> > -               if (pci_enable_device(dev->pdev)) {

> > +               if (r = pci_enable_device(dev->pdev)) {

> >                         if (fbcon)

> >                                 console_unlock();

> > -                       return -1;

> > +                       return r;

> >                 }

> >         }

> >

> >         /* post card */

> > -       if (!amdgpu_card_posted(adev))

> > +       if (!amdgpu_card_posted(adev) || !resume)

> >                 amdgpu_atom_asic_init(adev->mode_info.atom_context);

> >

> >         r = amdgpu_resume(adev);

> > @@ -1998,8 +2006,11 @@ int amdgpu_device_resume(struct drm_device

> *dev, bool resume, bool fbcon)

> >         }

> >

> >         r = amdgpu_late_init(adev);

> > -       if (r)

> > +       if (r) {

> > +               if (fbcon)

> > +                       console_unlock();

> >                 return r;

> > +       }

> >

> >         /* pin cursors */

> >         list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {

> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

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

> > index 06816cf..02941db3 100644

> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

> > @@ -601,8 +601,8 @@ static const struct dev_pm_ops amdgpu_pm_ops =

> {

> >         .resume = amdgpu_pmops_resume,

> >         .freeze = amdgpu_pmops_freeze,

> >         .thaw = amdgpu_pmops_thaw,

> > -       .poweroff = amdgpu_pmops_freeze,

> > -       .restore = amdgpu_pmops_resume,

> > +       .poweroff = amdgpu_pmops_suspend,

> > +       .restore = amdgpu_pmops_thaw,

> >         .runtime_suspend = amdgpu_pmops_runtime_suspend,

> >         .runtime_resume = amdgpu_pmops_runtime_resume,

> >         .runtime_idle = amdgpu_pmops_runtime_idle,

> > --

> > 1.9.1

> >

> > _______________________________________________

> > 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

> _______________________________________________

> amd-gfx mailing list

> amd-gfx@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
On Thu, Sep 1, 2016 at 2:22 AM, jimqu <Jim.Qu@amd.com> wrote:
> reset the asic if adapter is not powerdown when doing freeze()
> thaw() and restore(), in order to get a valid state of adapter.
>
> Change-Id: Id2e4587c06b556eb651ab9277ffc903f780dea56
> Signed-off-by: JimQu <Jim.Qu@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++--
>  2 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 52cec16..5fc76bbf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1936,8 +1936,14 @@ 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");
>         }
>
> +       amdgpu_atombios_fini(adev);
> +
>         if (fbcon) {
>                 console_lock();
>                 amdgpu_fbdev_set_suspend(adev, 1);
> @@ -1965,21 +1971,23 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
>         if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
>                 return 0;
>
> -       if (fbcon) {
> +       if (fbcon)
>                 console_lock();
> -       }
> +
> +       amdgpu_atombios_init(adev);
> +
>         if (resume) {
>                 pci_set_power_state(dev->pdev, PCI_D0);
>                 pci_restore_state(dev->pdev);
> -               if (pci_enable_device(dev->pdev)) {
> +               if (r = pci_enable_device(dev->pdev)) {
>                         if (fbcon)
>                                 console_unlock();
> -                       return -1;
> +                       return r;
>                 }
>         }
>
>         /* post card */
> -       if (!amdgpu_card_posted(adev))
> +       if (!amdgpu_card_posted(adev) || !resume)
>                 amdgpu_atom_asic_init(adev->mode_info.atom_context);
>
>         r = amdgpu_resume(adev);
> @@ -1998,8 +2006,11 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
>         }
>
>         r = amdgpu_late_init(adev);
> -       if (r)
> +       if (r) {
> +               if (fbcon)
> +                       console_unlock();

This looks like a bug fix and should be split out into a separate patch.


>                 return r;
> +       }
>
>         /* pin cursors */
>         list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 06816cf..02941db3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -601,8 +601,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = {
>         .resume = amdgpu_pmops_resume,
>         .freeze = amdgpu_pmops_freeze,
>         .thaw = amdgpu_pmops_thaw,
> -       .poweroff = amdgpu_pmops_freeze,
> -       .restore = amdgpu_pmops_resume,
> +       .poweroff = amdgpu_pmops_suspend,
> +       .restore = amdgpu_pmops_thaw,

I would suggest adding new amdgpu_pmops_[poweroff|restore] callbacks
that wrap the amdgpu_device_[suspend|resume] callbacks just like the
other ones so we don't accidentally break poweroff or restore if we
change suspend or thaw.

Alex

>         .runtime_suspend = amdgpu_pmops_runtime_suspend,
>         .runtime_resume = amdgpu_pmops_runtime_resume,
>         .runtime_idle = amdgpu_pmops_runtime_idle,
> --
> 1.9.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx