All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>,
	intel-gfx@lists.freedesktop.org,
	Chris Wilson <chris.p.wilson@intel.com>,
	dri-devel@lists.freedesktop.org,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>,
	John Harrison <John.C.Harrison@Intel.com>,
	Nirmoy Das <nirmoy.das@intel.com>
Subject: [PATCH v3 2/2] drm/i915: Never return 0 if not all requests retired
Date: Mon, 21 Nov 2022 15:56:55 +0100	[thread overview]
Message-ID: <20221121145655.75141-3-janusz.krzysztofik@linux.intel.com> (raw)
In-Reply-To: <20221121145655.75141-1-janusz.krzysztofik@linux.intel.com>

Users of intel_gt_retire_requests_timeout() expect 0 return value on
success.  However, we have no protection from passing back 0 potentially
returned by a call to dma_fence_wait_timeout() when it succedes right
after its timeout has expired.

Replace 0 with -ETIME before potentially using the timeout value as return
code, so -ETIME is returned if there are still some requests not retired
after timeout, 0 otherwise.

v3: Use conditional expression, more compact but also better reflecting
    intention standing behind the change.

v2: Move the added lines down so flush_submission() is not affected.

Fixes: f33a8a51602c ("drm/i915: Merge wait_for_timelines with retire_request")
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: stable@vger.kernel.org # v5.5+
---
 drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
index edb881d756309..1dfd01668c79c 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
@@ -199,7 +199,7 @@ out_active:	spin_lock(&timelines->lock);
 	if (remaining_timeout)
 		*remaining_timeout = timeout;
 
-	return active_count ? timeout : 0;
+	return active_count ? timeout ?: -ETIME : 0;
 }
 
 static void retire_work_handler(struct work_struct *work)
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: 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,
	Chris Wilson <chris.p.wilson@intel.com>,
	dri-devel@lists.freedesktop.org,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Nirmoy Das <nirmoy.das@intel.com>
Subject: [Intel-gfx] [PATCH v3 2/2] drm/i915: Never return 0 if not all requests retired
Date: Mon, 21 Nov 2022 15:56:55 +0100	[thread overview]
Message-ID: <20221121145655.75141-3-janusz.krzysztofik@linux.intel.com> (raw)
In-Reply-To: <20221121145655.75141-1-janusz.krzysztofik@linux.intel.com>

Users of intel_gt_retire_requests_timeout() expect 0 return value on
success.  However, we have no protection from passing back 0 potentially
returned by a call to dma_fence_wait_timeout() when it succedes right
after its timeout has expired.

Replace 0 with -ETIME before potentially using the timeout value as return
code, so -ETIME is returned if there are still some requests not retired
after timeout, 0 otherwise.

v3: Use conditional expression, more compact but also better reflecting
    intention standing behind the change.

v2: Move the added lines down so flush_submission() is not affected.

Fixes: f33a8a51602c ("drm/i915: Merge wait_for_timelines with retire_request")
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: stable@vger.kernel.org # v5.5+
---
 drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
index edb881d756309..1dfd01668c79c 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
@@ -199,7 +199,7 @@ out_active:	spin_lock(&timelines->lock);
 	if (remaining_timeout)
 		*remaining_timeout = timeout;
 
-	return active_count ? timeout : 0;
+	return active_count ? timeout ?: -ETIME : 0;
 }
 
 static void retire_work_handler(struct work_struct *work)
-- 
2.25.1


  parent reply	other threads:[~2022-11-21 14:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 14:56 [PATCH v3 0/2] drm/i915: Fix timeout handling when retiring requests Janusz Krzysztofik
2022-11-21 14:56 ` [Intel-gfx] " Janusz Krzysztofik
2022-11-21 14:56 ` [PATCH v3 1/2] drm/i915: Fix negative value passed as remaining time Janusz Krzysztofik
2022-11-21 14:56   ` [Intel-gfx] " Janusz Krzysztofik
2022-11-21 17:40   ` Andrzej Hajda
2022-11-21 17:40     ` Andrzej Hajda
2022-11-21 23:19     ` Janusz Krzysztofik
2022-11-21 23:19       ` Janusz Krzysztofik
2022-11-22 10:41       ` Tvrtko Ursulin
2022-11-22 10:41         ` Tvrtko Ursulin
2022-11-23 11:29         ` Janusz Krzysztofik
2022-11-23 11:29           ` Janusz Krzysztofik
2022-11-21 14:56 ` Janusz Krzysztofik [this message]
2022-11-21 14:56   ` [Intel-gfx] [PATCH v3 2/2] drm/i915: Never return 0 if not all requests retired Janusz Krzysztofik
2022-11-22 10:50   ` Tvrtko Ursulin
2022-11-22 10:50     ` [Intel-gfx] " Tvrtko Ursulin
2022-11-23  9:28     ` Janusz Krzysztofik
2022-11-23  9:28       ` [Intel-gfx] " Janusz Krzysztofik
2022-11-23 12:57       ` Tvrtko Ursulin
2022-11-23 12:57         ` [Intel-gfx] " Tvrtko Ursulin
2022-11-23 16:21         ` Janusz Krzysztofik
2022-11-23 16:21           ` [Intel-gfx] " Janusz Krzysztofik
2022-11-24 12:27           ` Tvrtko Ursulin
2022-11-24 12:27             ` [Intel-gfx] " Tvrtko Ursulin
2022-11-23 15:42   ` Andrzej Hajda
2022-11-23 15:42     ` [Intel-gfx] " Andrzej Hajda
2022-11-21 15:37 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for drm/i915: Fix timeout handling when retiring requests (rev3) Patchwork
2022-11-21 15:56 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-11-21 18:03 ` [Intel-gfx] ✓ Fi.CI.IGT: " 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=20221121145655.75141-3-janusz.krzysztofik@linux.intel.com \
    --to=janusz.krzysztofik@linux.intel.com \
    --cc=John.C.Harrison@Intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=chris.p.wilson@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=matthew.brost@intel.com \
    --cc=nirmoy.das@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 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.