Skip to contentSkip to conversation

drm/amd/amdgpu: S4 issue for amdgpu

PATCH Superseded jimqu 3 participants 6 messages Sep 1, 2016 – Sep 2, 2016 3 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

jimqu

author
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: S4 issue for amdgpu

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
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +17 -6
index 52cec16..5fc76bbf 100644
@@ -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) {
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
index 06816cf..02941db3 100644
@@ -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,
Signature · 6 lines
1.9.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): 1472710922-7977-1-git-send-email-Jim.Qu-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 16 lines · jimqu

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
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 52cec16..5fc76bbf 100644
@@ -1936,8 +1936,14 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
                /* Shut down the device */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) · line 1946

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
                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.

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        if (fbcon) {
                console_lock();
                amdgpu_fbdev_set_suspend(adev, 1);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) · line 1978

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
@@ -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.

Quoted 49 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -4
        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) {
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -3
index 06816cf..02941db3 100644
@@ -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

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_NP2Sy7MfwVLkbxMBPxzzX5fhM7PCEt2wuYAVq27y3EQw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#4 lore raw

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 <[email protected]> 代表 Alex Deucher <[email protected]> 发送时间: 2016年9月1日 21:42:46
收件人: Qu, Jim
抄送: amd-gfx list
主题: Re: [PATCH] drm/amd/amdgpu: S4 issue for amdgpu

Quoted 16 lines · jimqu

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
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 52cec16..5fc76bbf 100644
@@ -1936,8 +1936,14 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
                /* Shut down the device */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) · line 1946

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
                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.

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        if (fbcon) {
                console_lock();
                amdgpu_fbdev_set_suspend(adev, 1);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) · line 1978

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
@@ -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.

Quoted 49 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -4
        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) {
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -3
index 06816cf..02941db3 100644
@@ -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

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
_______________________________________________
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): BY2PR12MB0614D04D489140A6486995D599E50-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

author
#6 lore raw

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 <[email protected]> 代表 Alex Deucher <[email protected]> 发送时间: 2016年9月1日 21:42:46
收件人: Qu, Jim
抄送: amd-gfx list
主题: Re: [PATCH] drm/amd/amdgpu: S4 issue for amdgpu

Quoted 16 lines · jimqu

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
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 52cec16..5fc76bbf 100644
@@ -1936,8 +1936,14 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
                /* Shut down the device */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) · line 1946

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
                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.

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        if (fbcon) {
                console_lock();
                amdgpu_fbdev_set_suspend(adev, 1);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) · line 1978

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
@@ -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.

Quoted 49 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -4
        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) {
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -3
index 06816cf..02941db3 100644
@@ -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

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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw
In reply to a message not in the archive
Quoted 18 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] 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:

Quoted 8 lines
[   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

Quoted 120 lines

Thanks
JimQu

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

Quoted 7 lines · jimqu

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
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23

+++++++++++++++++------

Review

Quoted 4 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++--
 2 files changed, 19 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

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

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

Quoted 4 lines

index 52cec16..5fc76bbf 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1936,8 +1936,14 @@ int amdgpu_device_suspend(struct drm_device

*dev, bool suspend, bool fbcon)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) · line 1946

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
                /* 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.

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

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        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)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) · line 1978

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
        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.

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

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
        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)

Review

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
        }
 
        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) {
(quoted diff) +0 -0

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

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

Quoted 4 lines

index 06816cf..02941db3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -601,8 +601,8 @@ static const struct dev_pm_ops amdgpu_pm_ops =

{

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -3
        .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

Quoted 4 lines

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

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

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

#8 lore raw
In reply to a message not in the archive
Quoted 59 lines · jimqu

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
---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13 -5
index 52cec16..5fc76bbf 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) · line 2011

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
@@ -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.

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
                return r;
+       }
 
        /* pin cursors */
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
index 06816cf..02941db3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static const struct dev_pm_ops amdgpu_pm_ops = { · line 605

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
@@ -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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
        .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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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