Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Dugast <francois.dugast@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: [PATCH v1 02/21] drm/xe/uapi: Return correct error code for xe_wait_user_fence_ioctl
Date: Fri, 15 Dec 2023 15:45:34 +0000	[thread overview]
Message-ID: <20231215154553.7-3-francois.dugast@intel.com> (raw)
In-Reply-To: <20231215154553.7-1-francois.dugast@intel.com>

From: Bommu Krishnaiah <krishnaiah.bommu@intel.com>

Currently xe_wait_user_fence_ioctl is not checking exec_queue state
and blocking until timeout, with this patch wakeup the blocking wait
if exec_queue reset happen and returning proper error code

Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Kempczynski Zbigniew <Zbigniew.Kempczynski@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_exec_queue_types.h |  2 ++
 drivers/gpu/drm/xe/xe_execlist.c         |  7 ++++++
 drivers/gpu/drm/xe/xe_guc_submit.c       | 10 ++++++++
 drivers/gpu/drm/xe/xe_wait_user_fence.c  | 30 +++++++++++++++++++-----
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_exec_queue_types.h b/drivers/gpu/drm/xe/xe_exec_queue_types.h
index c7aefa1c8c31..bcf08b00d94a 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue_types.h
+++ b/drivers/gpu/drm/xe/xe_exec_queue_types.h
@@ -217,6 +217,8 @@ struct xe_exec_queue_ops {
 	 * signalled when this function is called.
 	 */
 	void (*resume)(struct xe_exec_queue *q);
+	/** @reset_status: check exec queue reset status */
+	bool (*reset_status)(struct xe_exec_queue *q);
 };
 
 #endif
diff --git a/drivers/gpu/drm/xe/xe_execlist.c b/drivers/gpu/drm/xe/xe_execlist.c
index 507b6baec3dc..96b5224eb478 100644
--- a/drivers/gpu/drm/xe/xe_execlist.c
+++ b/drivers/gpu/drm/xe/xe_execlist.c
@@ -442,6 +442,12 @@ static void execlist_exec_queue_resume(struct xe_exec_queue *q)
 	/* NIY */
 }
 
+static bool execlist_exec_queue_reset_status(struct xe_exec_queue *q)
+{
+	/* NIY */
+	return false;
+}
+
 static const struct xe_exec_queue_ops execlist_exec_queue_ops = {
 	.init = execlist_exec_queue_init,
 	.kill = execlist_exec_queue_kill,
@@ -453,6 +459,7 @@ static const struct xe_exec_queue_ops execlist_exec_queue_ops = {
 	.suspend = execlist_exec_queue_suspend,
 	.suspend_wait = execlist_exec_queue_suspend_wait,
 	.resume = execlist_exec_queue_resume,
+	.reset_status = execlist_exec_queue_reset_status,
 };
 
 int xe_execlist_init(struct xe_gt *gt)
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index ad5e19ecd33c..21ac68e3246f 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -854,6 +854,10 @@ static void simple_error_capture(struct xe_exec_queue *q)
 static void xe_guc_exec_queue_trigger_cleanup(struct xe_exec_queue *q)
 {
 	struct xe_guc *guc = exec_queue_to_guc(q);
+	struct xe_device *xe = guc_to_xe(guc);
+
+	/** to wakeup xe_wait_user_fence ioctl if exec queue is reset */
+	wake_up_all(&xe->ufence_wq);
 
 	if (xe_exec_queue_is_lr(q))
 		queue_work(guc_to_gt(guc)->ordered_wq, &q->guc->lr_tdr);
@@ -1394,6 +1398,11 @@ static void guc_exec_queue_resume(struct xe_exec_queue *q)
 	guc_exec_queue_add_msg(q, msg, RESUME);
 }
 
+static bool guc_exec_queue_reset_status(struct xe_exec_queue *q)
+{
+	return exec_queue_reset(q);
+}
+
 /*
  * All of these functions are an abstraction layer which other parts of XE can
  * use to trap into the GuC backend. All of these functions, aside from init,
@@ -1411,6 +1420,7 @@ static const struct xe_exec_queue_ops guc_exec_queue_ops = {
 	.suspend = guc_exec_queue_suspend,
 	.suspend_wait = guc_exec_queue_suspend_wait,
 	.resume = guc_exec_queue_resume,
+	.reset_status = guc_exec_queue_reset_status,
 };
 
 static void guc_exec_queue_stop(struct xe_guc *guc, struct xe_exec_queue *q)
diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c b/drivers/gpu/drm/xe/xe_wait_user_fence.c
index 59af65b6ed89..b0a7896f7fcb 100644
--- a/drivers/gpu/drm/xe/xe_wait_user_fence.c
+++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c
@@ -13,6 +13,7 @@
 #include "xe_device.h"
 #include "xe_gt.h"
 #include "xe_macros.h"
+#include "xe_exec_queue.h"
 
 static int do_compare(u64 addr, u64 value, u64 mask, u16 op)
 {
@@ -100,10 +101,12 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, void *data,
 			     struct drm_file *file)
 {
 	struct xe_device *xe = to_xe_device(dev);
+	struct xe_file *xef = to_xe_file(file);
 	DEFINE_WAIT_FUNC(w_wait, woken_wake_function);
 	struct drm_xe_wait_user_fence *args = data;
+	struct xe_exec_queue *q = NULL;
 	u64 addr = args->addr;
-	int err;
+	int err = 0;
 	long timeout;
 	ktime_t start;
 
@@ -121,6 +124,12 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, void *data,
 	if (XE_IOCTL_DBG(xe, addr & 0x7))
 		return -EINVAL;
 
+	if (args->exec_queue_id) {
+		q = xe_exec_queue_lookup(xef, args->exec_queue_id);
+		if (XE_IOCTL_DBG(xe, !q))
+			return -ENOENT;
+	}
+
 	timeout = to_jiffies_timeout(xe, args);
 
 	start = ktime_get();
@@ -136,6 +145,14 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, void *data,
 			break;
 		}
 
+		if (q) {
+			if (q->ops->reset_status(q)) {
+				drm_info(&xe->drm, "exec gueue reset detected\n");
+				err = -EIO;
+				break;
+			}
+		}
+
 		if (!timeout) {
 			err = -ETIME;
 			break;
@@ -151,10 +168,11 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, void *data,
 			args->timeout = 0;
 	}
 
-	if (XE_IOCTL_DBG(xe, err < 0))
-		return err;
-	else if (XE_IOCTL_DBG(xe, !timeout))
-		return -ETIME;
+	if (!timeout && !(err < 0))
+		err = -ETIME;
+
+	if (q)
+		xe_exec_queue_put(q);
 
-	return 0;
+	return err;
 }
-- 
2.34.1


  parent reply	other threads:[~2023-12-15 15:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 15:45 [PATCH v1 00/21] uAPI Alignment - More cleanup before upstream Francois Dugast
2023-12-15 15:45 ` [PATCH v1 01/21] drm/xe/uapi: add exec_queue_id member to drm_xe_wait_user_fence structure Francois Dugast
2023-12-15 15:45 ` Francois Dugast [this message]
2023-12-15 15:45 ` [PATCH v1 03/21] drm/xe/uapi: Remove DRM_IOCTL_XE_EXEC_QUEUE_SET_PROPERTY Francois Dugast
2023-12-15 15:45 ` [PATCH v1 04/21] drm/xe/uapi: Remove DRM_XE_UFENCE_WAIT_MASK_* Francois Dugast
2023-12-15 15:45 ` [PATCH v1 05/21] drm/xe/pmu: Remove PMU from Xe till uapi is finalized Francois Dugast
2023-12-15 15:45 ` [PATCH v1 06/21] drm/xe/uapi: Ensure every uapi struct has drm_xe prefix Francois Dugast
2023-12-15 15:45 ` [PATCH v1 07/21] drm/xe/uapi: Remove sync binds Francois Dugast
2023-12-15 15:45 ` [PATCH v1 08/21] drm/xe/uapi: Add a comment to each struct Francois Dugast
2023-12-15 15:45 ` [PATCH v1 09/21] drm/xe/uapi: Add missing documentation for struct members Francois Dugast
2023-12-15 15:45 ` [PATCH v1 10/21] drm/xe/uapi: Document use of size in drm_xe_device_query Francois Dugast
2023-12-15 15:45 ` [PATCH v1 11/21] drm/xe/uapi: Document drm_xe_query_config keys Francois Dugast
2023-12-15 15:45 ` [PATCH v1 12/21] drm/xe/uapi: Document DRM_XE_DEVICE_QUERY_HWCONFIG Francois Dugast
2023-12-15 15:45 ` [PATCH v1 13/21] drm/xe/uapi: Make constant comments visible in kernel doc Francois Dugast
2023-12-15 15:45 ` [PATCH v1 14/21] drm/xe/uapi: Order sections Francois Dugast
2023-12-15 15:45 ` [PATCH v1 15/21] drm/xe/uapi: More uAPI documentation additions and cosmetic updates Francois Dugast
2023-12-15 15:45 ` [PATCH v1 16/21] drm/xe/uapi: Document the memory_region bitmask Francois Dugast
2023-12-15 15:45 ` [PATCH v1 17/21] drm/xe/uapi: Add block diagram of a device Francois Dugast
2023-12-15 15:45 ` [PATCH v1 18/21] drm/xe/uapi: Add examples of user space code Francois Dugast
2023-12-15 15:45 ` [PATCH v1 19/21] drm/xe/uapi: Move CPU_CACHING defines before doc Francois Dugast
2023-12-15 15:45 ` [PATCH v1 20/21] drm/xe/uapi: Move DRM_XE_ACC_GRANULARITY_* where they are used Francois Dugast
2023-12-15 15:45 ` [PATCH v1 21/21] drm/xe/uapi: Remove reset uevent for now Francois Dugast
2023-12-15 16:35   ` Lucas De Marchi
2023-12-15 17:01 ` ✓ CI.Patch_applied: success for uAPI Alignment - More cleanup before upstream Patchwork
2023-12-15 17:02 ` ✗ CI.checkpatch: warning " Patchwork
2023-12-15 17:03 ` ✓ CI.KUnit: success " Patchwork
2023-12-15 17:03 ` [PATCH v1 00/21] " Souza, Jose
2023-12-15 17:13 ` ✓ CI.Build: success for " Patchwork
2023-12-15 17:14 ` ✓ CI.Hooks: " Patchwork
2023-12-15 17:15 ` ✓ CI.checksparse: " Patchwork
2023-12-15 17:51 ` ✗ CI.BAT: 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=20231215154553.7-3-francois.dugast@intel.com \
    --to=francois.dugast@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=rodrigo.vivi@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