提交 74b0b157 编写于 作者: J jimqu 提交者: Alex Deucher

drm/amd/amdgpu: S4 issue for amdgpu (v2)

reset the asic if adapter is not powerdown when doing freeze()
thaw() and restore(), in order to get a valid state of adapter.

v2: squash in warning fix from Rex
Signed-off-by: NJimQu <Jim.Qu@amd.com>
Acked-by: NChristian König <christian.koenig@amd.com>
Tested By: Shawn Starr <shawn.starr@rogers.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 3aecd24c
...@@ -1895,6 +1895,10 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) ...@@ -1895,6 +1895,10 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
/* Shut down the device */ /* Shut down the device */
pci_disable_device(dev->pdev); pci_disable_device(dev->pdev);
pci_set_power_state(dev->pdev, PCI_D3hot); pci_set_power_state(dev->pdev, PCI_D3hot);
} else {
r = amdgpu_asic_reset(adev);
if (r)
DRM_ERROR("amdgpu asic reset failed\n");
} }
if (fbcon) { if (fbcon) {
...@@ -1925,22 +1929,26 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) ...@@ -1925,22 +1929,26 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF) dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
return 0; return 0;
if (fbcon) { if (fbcon)
console_lock(); console_lock();
}
if (resume) { if (resume) {
pci_set_power_state(dev->pdev, PCI_D0); pci_set_power_state(dev->pdev, PCI_D0);
pci_restore_state(dev->pdev); pci_restore_state(dev->pdev);
if (pci_enable_device(dev->pdev)) { r = pci_enable_device(dev->pdev);
if (r) {
if (fbcon) if (fbcon)
console_unlock(); console_unlock();
return -1; return r;
} }
} }
/* post card */ /* post card */
if (!amdgpu_card_posted(adev)) if (!amdgpu_card_posted(adev) || !resume) {
amdgpu_atom_asic_init(adev->mode_info.atom_context); r = amdgpu_atom_asic_init(adev->mode_info.atom_context);
if (r)
DRM_ERROR("amdgpu asic init failed\n");
}
r = amdgpu_resume(adev); r = amdgpu_resume(adev);
if (r) if (r)
......
...@@ -487,6 +487,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev) ...@@ -487,6 +487,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
static int amdgpu_pmops_suspend(struct device *dev) static int amdgpu_pmops_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev); struct drm_device *drm_dev = pci_get_drvdata(pdev);
return amdgpu_device_suspend(drm_dev, true, true); return amdgpu_device_suspend(drm_dev, true, true);
} }
...@@ -509,6 +510,7 @@ static int amdgpu_pmops_resume(struct device *dev) ...@@ -509,6 +510,7 @@ static int amdgpu_pmops_resume(struct device *dev)
static int amdgpu_pmops_freeze(struct device *dev) static int amdgpu_pmops_freeze(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev); struct drm_device *drm_dev = pci_get_drvdata(pdev);
return amdgpu_device_suspend(drm_dev, false, true); return amdgpu_device_suspend(drm_dev, false, true);
} }
...@@ -516,6 +518,23 @@ static int amdgpu_pmops_freeze(struct device *dev) ...@@ -516,6 +518,23 @@ static int amdgpu_pmops_freeze(struct device *dev)
static int amdgpu_pmops_thaw(struct device *dev) static int amdgpu_pmops_thaw(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev);
return amdgpu_device_resume(drm_dev, false, true);
}
static int amdgpu_pmops_poweroff(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev);
return amdgpu_device_suspend(drm_dev, true, true);
}
static int amdgpu_pmops_restore(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev); struct drm_device *drm_dev = pci_get_drvdata(pdev);
return amdgpu_device_resume(drm_dev, false, true); return amdgpu_device_resume(drm_dev, false, true);
} }
...@@ -622,8 +641,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = { ...@@ -622,8 +641,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = {
.resume = amdgpu_pmops_resume, .resume = amdgpu_pmops_resume,
.freeze = amdgpu_pmops_freeze, .freeze = amdgpu_pmops_freeze,
.thaw = amdgpu_pmops_thaw, .thaw = amdgpu_pmops_thaw,
.poweroff = amdgpu_pmops_freeze, .poweroff = amdgpu_pmops_poweroff,
.restore = amdgpu_pmops_resume, .restore = amdgpu_pmops_restore,
.runtime_suspend = amdgpu_pmops_runtime_suspend, .runtime_suspend = amdgpu_pmops_runtime_suspend,
.runtime_resume = amdgpu_pmops_runtime_resume, .runtime_resume = amdgpu_pmops_runtime_resume,
.runtime_idle = amdgpu_pmops_runtime_idle, .runtime_idle = amdgpu_pmops_runtime_idle,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册