From: Andrzej Hajda <andrzej.hajda@intel.com>
To: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>,
Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Chris Wilson <chris.p.wilson@intel.com>
Subject: Re: [Intel-gfx] [PATCH 1/3] drm/i915: Fix negative remaining time after retire requests
Date: Wed, 16 Nov 2022 14:13:38 +0100 [thread overview]
Message-ID: <58e39e38-eb47-2df1-f729-514c41dcd654@intel.com> (raw)
In-Reply-To: <20221116112532.36253-2-janusz.krzysztofik@linux.intel.com>
On 16.11.2022 12:25, Janusz Krzysztofik wrote:
> Commit b97060a99b01 ("drm/i915/guc: Update intel_gt_wait_for_idle to work
> with GuC") extended the API of intel_gt_retire_requests_timeout() with an
> extra argument 'remaining_timeout', intended for passing back unconsumed
> portion of requested timeout when 0 (success) is returned. However, when
> request retirement happens to succeed despite an error returned by
> dma_fence_wait_timeout(), the error code (a negative value) is passed back
> instead of remaining time. If a user then passes that negative value
> forward as requested timeout to another wait, an explicit WARN or BUG can
> be triggered.
>
> Instead of copying the value of timeout variable to *remaining_timeout
> before return, update the *remaining_timeout after each DMA fence wait.
> Set it to 0 on -ETIME, -EINTR or -ERESTARTSYS, and assume no time has been
> consumed on other errors returned from the wait.
>
> Fixes: b97060a99b01 ("drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC")
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> Cc: stable@vger.kernel.org # v5.15+
> ---
> drivers/gpu/drm/i915/gt/intel_gt_requests.c | 23 ++++++++++++++++++---
> 1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> index edb881d756309..ccaf2fd80625b 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> @@ -138,6 +138,9 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout,
> unsigned long active_count = 0;
> LIST_HEAD(free);
>
> + if (remaining_timeout)
> + *remaining_timeout = timeout;
> +
> flush_submission(gt, timeout); /* kick the ksoftirqd tasklets */
> spin_lock(&timelines->lock);
> list_for_each_entry_safe(tl, tn, &timelines->active_list, link) {
> @@ -163,6 +166,23 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout,
> timeout);
> dma_fence_put(fence);
>
> + if (remaining_timeout) {
> + /*
> + * If we get an error here but request
> + * retirement succeeds anyway
> + * (!active_count) and we return 0, the
> + * caller may want to spend remaining
> + * time on waiting for other events.
> + */
> + if (timeout == -ETIME ||
> + timeout == -EINTR ||
> + timeout == -ERESTARTSYS)
> + *remaining_timeout = 0;
> + else if (timeout >= 0)
> + *remaining_timeout = timeout;
> + /* else assume no time consumed */
Looks correct, but the crazy semantic of dma_fence_wait_timeout does not
make it easy to understand.
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Regards
Andrzej
> + }
> +
> /* Retirement is best effort */
> if (!mutex_trylock(&tl->mutex)) {
> active_count++;
> @@ -196,9 +216,6 @@ out_active: spin_lock(&timelines->lock);
> if (flush_submission(gt, timeout)) /* Wait, there's more! */
> active_count++;
>
> - if (remaining_timeout)
> - *remaining_timeout = timeout;
> -
> return active_count ? timeout : 0;
> }
>
next prev parent reply other threads:[~2022-11-16 13:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 11:25 [Intel-gfx] [PATCH 0/3] drm/i915: Fix timeout handling when retiring requests Janusz Krzysztofik
2022-11-16 11:25 ` [Intel-gfx] [PATCH 1/3] drm/i915: Fix negative remaining time after retire requests Janusz Krzysztofik
2022-11-16 13:13 ` Andrzej Hajda [this message]
2022-11-17 9:58 ` Das, Nirmoy
2022-11-16 11:25 ` [Intel-gfx] [PATCH 2/3] drm/i915: Never return 0 on timeout when retiring requests Janusz Krzysztofik
2022-11-16 14:15 ` Andrzej Hajda
2022-11-17 9:53 ` Das, Nirmoy
2022-11-16 11:25 ` [Intel-gfx] [PATCH 3/3] drm/i915: Never return 0 if request wait succeeds Janusz Krzysztofik
2022-11-16 14:42 ` Andrzej Hajda
2022-11-16 15:48 ` Janusz Krzysztofik
2022-11-16 19:06 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Fix timeout handling when retiring requests Patchwork
2022-11-17 3:27 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
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=58e39e38-eb47-2df1-f729-514c41dcd654@intel.com \
--to=andrzej.hajda@intel.com \
--cc=chris.p.wilson@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=tvrtko.ursulin@linux.intel.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