[PATCH] drm/amd/amdgpu: S4 issue for amdgpu
Alex Deucher
alexdeucher at gmail.com
Fri Sep 2 15:17:57 UTC 2016
On Thu, Sep 1, 2016 at 2:22 AM, jimqu <Jim.Qu at 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 at 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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
More information about the amd-gfx
mailing list