From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Mario Limonciello <mario.limonciello@amd.com>,
amd-gfx@lists.freedesktop.org
Cc: Harry.Wentland@amd.com
Subject: Re: [PATCH v5 4/7] drm/amd: Capture errors in amdgpu_switcheroo_set_state()
Date: Mon, 9 Oct 2023 11:06:07 +0200 [thread overview]
Message-ID: <312fe578-928b-4213-9d35-21de517d1cc4@gmail.com> (raw)
In-Reply-To: <20231006185026.5536-5-mario.limonciello@amd.com>
Am 06.10.23 um 20:50 schrieb Mario Limonciello:
> amdgpu_switcheroo_set_state() calls lots of functions that could
> fail under memory pressure or for other reasons. Don't assume
> everything can successfully run sequentially, and check return codes
> for everything that returns one.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 36 +++++++++++++++++-----
> 1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index a362152cd0da..8dfcff783dab 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1749,23 +1749,45 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,
> /* don't suspend or resume card normally */
> dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
>
> - pci_set_power_state(pdev, PCI_D0);
> - amdgpu_device_load_pci_state(pdev);
> + r = pci_set_power_state(pdev, PCI_D0);
> + if (r) {
> + DRM_WARN("pci_set_power_state failed (%d)\n", r);
> + return;
> + }
> + if (!amdgpu_device_load_pci_state(pdev))
> + return;
> r = pci_enable_device(pdev);
> if (r)
> DRM_WARN("pci_enable_device failed (%d)\n", r);
> - amdgpu_device_resume(dev, true);
> + r = amdgpu_device_resume(dev, true);
> + if (r) {
> + DRM_WARN("amdgpu_device_resume failed (%d)\n", r);
> + return;
> + }
>
> dev->switch_power_state = DRM_SWITCH_POWER_ON;
> } else {
> pr_info("switched off\n");
> dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> - amdgpu_device_prepare(dev);
> - amdgpu_device_suspend(dev, true);
> - amdgpu_device_cache_pci_state(pdev);
> + r = amdgpu_device_prepare(dev);
> + if (r) {
> + DRM_WARN("amdgpu_device_prepare failed (%d)\n", r);
> + return;
> + }
> + r = amdgpu_device_suspend(dev, true);
> + if (r) {
> + DRM_WARN("amdgpu_device_suspend failed (%d)\n", r);
> + return;
> + }
> + if (!amdgpu_device_cache_pci_state(pdev))
> + return;
> /* Shut down the device */
> pci_disable_device(pdev);
> - pci_set_power_state(pdev, PCI_D3cold);
> + r = pci_set_power_state(pdev, PCI_D3cold);
> + if (r) {
> + DRM_WARN("pci_set_power_state failed (%d)\n", r);
> + return;
> + }
> dev->switch_power_state = DRM_SWITCH_POWER_OFF;
> }
> }
next prev parent reply other threads:[~2023-10-09 9:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 18:50 [PATCH v5 0/7] Better handle memory pressure at suspend Mario Limonciello
2023-10-06 18:50 ` [PATCH v5 1/7] drm/amd: Evict resources during PM ops prepare() callback Mario Limonciello
2023-10-09 8:44 ` Christian König
2023-10-09 14:37 ` Alex Deucher
2023-10-06 18:50 ` [PATCH v5 2/7] drm/amd: Add concept of running prepare() sequence for IP blocks Mario Limonciello
2023-10-09 8:46 ` Christian König
2023-10-09 14:34 ` Alex Deucher
2023-10-06 18:50 ` [PATCH v5 3/7] drm/amd: Split up UVD suspend into prepare and suspend steps Mario Limonciello
2023-10-09 14:43 ` Alex Deucher
2023-10-06 18:50 ` [PATCH v5 4/7] drm/amd: Capture errors in amdgpu_switcheroo_set_state() Mario Limonciello
2023-10-09 9:06 ` Christian König [this message]
2023-10-06 18:50 ` [PATCH v5 5/7] drm/amd/display: Catch errors from drm_atomic_helper_suspend() Mario Limonciello
2023-10-09 9:06 ` Christian König
2023-10-09 14:44 ` Alex Deucher
2023-10-06 18:50 ` [PATCH v5 6/7] drm/amd/display: Destroy DC context while keeping DML and DML2 Mario Limonciello
2023-10-09 14:45 ` Alex Deucher
2023-10-06 18:50 ` [PATCH v5 7/7] drm/amd/display: make dc_set_power_state() return type `void` again Mario Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=312fe578-928b-4213-9d35-21de517d1cc4@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=Harry.Wentland@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=mario.limonciello@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.