From: Stephen Boyd <swboyd@chromium.org>
To: Rob Clark <robdclark@gmail.com>, dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@chromium.org>,
freedreno@lists.freedesktop.org,
Jonathan Marek <jonathan@marek.ca>,
David Airlie <airlied@linux.ie>,
linux-arm-msm@vger.kernel.org,
Vladimir Lypak <vladimir.lypak@gmail.com>,
Abhinav Kumar <quic_abhinavk@quicinc.com>,
Jordan Crouse <jordan@cosmicpenguin.net>,
Akhil P Oommen <quic_akhilpo@quicinc.com>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Sean Paul <sean@poorly.run>,
linux-kernel@vger.kernel.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH 1/2] drm/msm/gpu: Wait for idle before suspending
Date: Fri, 7 Jan 2022 16:27:07 -0800 [thread overview]
Message-ID: <CAE-0n53N0GQ2UXYNpDOf_WVvvUa3cu95ePGYfYk7jZwPTqJ-XA@mail.gmail.com> (raw)
In-Reply-To: <20220106181449.696988-2-robdclark@gmail.com>
Quoting Rob Clark (2022-01-06 10:14:46)
> From: Rob Clark <robdclark@chromium.org>
>
> System suspend uses pm_runtime_force_suspend(), which cheekily bypasses
> the runpm reference counts. This doesn't actually work so well when the
> GPU is active. So add a reasonable delay waiting for the GPU to become
> idle.
Maybe also say:
Failure to wait during system wide suspend leads to GPU hangs seen on
resume.
>
> Alternatively we could just return -EBUSY in this case, but that has the
> disadvantage of causing system suspend to fail.
>
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
> drivers/gpu/drm/msm/adreno/adreno_device.c | 9 +++++++++
> drivers/gpu/drm/msm/msm_gpu.c | 3 +++
> drivers/gpu/drm/msm/msm_gpu.h | 3 +++
> 3 files changed, 15 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
> index 93005839b5da..b677ca3fd75e 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_device.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
> @@ -611,6 +611,15 @@ static int adreno_resume(struct device *dev)
> static int adreno_suspend(struct device *dev)
> {
> struct msm_gpu *gpu = dev_to_gpu(dev);
> + int ret = 0;
Please don't assign and then immediately overwrite.
> +
> + ret = wait_event_timeout(gpu->retire_event,
> + !msm_gpu_active(gpu),
> + msecs_to_jiffies(1000));
> + if (ret == 0) {
The usual pattern is
long timeleft;
timeleft = wait_event_timeout(...)
if (!timeleft) {
/* no time left; timed out */
Can it be the same pattern here? It helps because people sometimes
forget that wait_event_timeout() returns the time that is left and not
an error code when it times out.
> + dev_err(dev, "Timeout waiting for GPU to suspend\n");
> + return -EBUSY;
> + }
>
> return gpu->funcs->pm_suspend(gpu);
> }
next prev parent reply other threads:[~2022-01-08 0:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 18:14 [PATCH 0/2] drm/msm/gpu: System suspend fixes Rob Clark
2022-01-06 18:14 ` [PATCH 1/2] drm/msm/gpu: Wait for idle before suspending Rob Clark
2022-01-06 23:25 ` Bjorn Andersson
2022-01-07 9:05 ` AngeloGioacchino Del Regno
2022-01-08 0:27 ` Stephen Boyd [this message]
2022-01-08 17:41 ` Rob Clark
2022-01-06 18:14 ` [PATCH 2/2] drm/msm/gpu: Cancel idle/boost work on suspend Rob Clark
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=CAE-0n53N0GQ2UXYNpDOf_WVvvUa3cu95ePGYfYk7jZwPTqJ-XA@mail.gmail.com \
--to=swboyd@chromium.org \
--cc=airlied@linux.ie \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bjorn.andersson@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jonathan@marek.ca \
--cc=jordan@cosmicpenguin.net \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_akhilpo@quicinc.com \
--cc=robdclark@chromium.org \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
--cc=vladimir.lypak@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).