Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: [PATCH v2 1/6] drm/xe: Promote relaxed_ms_sleep
Date: Tue, 27 Jan 2026 20:37:21 +0100	[thread overview]
Message-ID: <20260127193727.601-2-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20260127193727.601-1-michal.wajdeczko@intel.com>

We want to have single place with sleep related helpers for better
code reuse. Create xe_sleep.h and move relaxed_ms_sleep() there.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
 drivers/gpu/drm/xe/xe_guc_submit.c | 23 ++-----------------
 drivers/gpu/drm/xe/xe_sleep.h      | 36 ++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 21 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/xe_sleep.h

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 456f549c16f6..4ea14f2794f4 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -8,9 +8,7 @@
 #include <linux/bitfield.h>
 #include <linux/bitmap.h>
 #include <linux/circ_buf.h>
-#include <linux/delay.h>
 #include <linux/dma-fence-array.h>
-#include <linux/math64.h>
 
 #include <drm/drm_managed.h>
 
@@ -42,6 +40,7 @@
 #include "xe_pm.h"
 #include "xe_ring_ops_types.h"
 #include "xe_sched_job.h"
+#include "xe_sleep.h"
 #include "xe_trace.h"
 #include "xe_uc_fw.h"
 #include "xe_vm.h"
@@ -1028,24 +1027,6 @@ static u32 wq_space_until_wrap(struct xe_exec_queue *q)
 	return (WQ_SIZE - q->guc->wqi_tail);
 }
 
-static inline void relaxed_ms_sleep(unsigned int delay_ms)
-{
-	unsigned long min_us, max_us;
-
-	if (!delay_ms)
-		return;
-
-	if (delay_ms > 20) {
-		msleep(delay_ms);
-		return;
-	}
-
-	min_us = mul_u32_u32(delay_ms, 1000);
-	max_us = min_us + 500;
-
-	usleep_range(min_us, max_us);
-}
-
 static int wq_wait_for_space(struct xe_exec_queue *q, u32 wqi_size)
 {
 	struct xe_guc *guc = exec_queue_to_guc(q);
@@ -1830,7 +1811,7 @@ static void __guc_exec_queue_process_msg_suspend(struct xe_sched_msg *msg)
 				since_resume_ms;
 
 			if (wait_ms > 0 && q->guc->resume_time)
-				relaxed_ms_sleep(wait_ms);
+				xe_sleep_relaxed_ms(wait_ms);
 
 			set_exec_queue_suspended(q);
 			disable_scheduling(q, false);
diff --git a/drivers/gpu/drm/xe/xe_sleep.h b/drivers/gpu/drm/xe/xe_sleep.h
new file mode 100644
index 000000000000..a772f1a37395
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_sleep.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _XE_SLEEP_H_
+#define _XE_SLEEP_H_
+
+#include <linux/delay.h>
+#include <linux/math64.h>
+
+/**
+ * xe_sleep_relaxed_ms() - Sleep for an approximate time.
+ * @delay_ms: time in msec to sleep
+ *
+ * For smaller timeouts, sleep with 0.5ms accuracy.
+ */
+static inline void xe_sleep_relaxed_ms(unsigned int delay_ms)
+{
+	unsigned long min_us, max_us;
+
+	if (!delay_ms)
+		return;
+
+	if (delay_ms > 20) {
+		msleep(delay_ms);
+		return;
+	}
+
+	min_us = mul_u32_u32(delay_ms, 1000);
+	max_us = min_us + 500;
+
+	usleep_range(min_us, max_us);
+}
+
+#endif
-- 
2.47.1


  reply	other threads:[~2026-01-27 19:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 19:37 [PATCH v2 0/6] drm/xe/guc: Make MMIO communication more robust Michal Wajdeczko
2026-01-27 19:37 ` Michal Wajdeczko [this message]
2026-01-27 19:46   ` [PATCH v2 1/6] drm/xe: Promote relaxed_ms_sleep Matthew Brost
2026-01-27 19:37 ` [PATCH v2 2/6] drm/xe: Move exponential sleep logic to helper Michal Wajdeczko
2026-01-27 19:49   ` Matthew Brost
2026-01-27 19:37 ` [PATCH v2 3/6] drm/xe/guc: Limit sleep while waiting for H2G credits Michal Wajdeczko
2026-01-27 19:51   ` Matthew Brost
2026-01-27 19:37 ` [PATCH v2 4/6] drm/xe/guc: Drop redundant register read Michal Wajdeczko
2026-01-27 19:37 ` [PATCH v2 5/6] drm/xe/guc: Wait before retrying sending H2G Michal Wajdeczko
2026-01-27 19:56   ` Matthew Brost
2026-01-27 19:37 ` [PATCH v2 6/6] drm/xe/guc: Allow second H2G retry on FLR Michal Wajdeczko
2026-01-27 19:57   ` Matthew Brost
2026-01-27 19:47 ` ✗ CI.checkpatch: warning for drm/xe/guc: Make MMIO communication more robust (rev2) Patchwork
2026-01-27 19:48 ` ✓ CI.KUnit: success " Patchwork
2026-01-27 20:21 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-28  2:54 ` ✗ Xe.CI.Full: failure " Patchwork
2026-01-29 18:57   ` Michal Wajdeczko
2026-02-02 21:34     ` Michal Wajdeczko
2026-01-29 20:23 ` ✗ CI.checkpatch: warning for drm/xe/guc: Make MMIO communication more robust (rev3) Patchwork
2026-01-29 20:25 ` ✓ CI.KUnit: success " Patchwork
2026-01-29 21:01 ` ✓ Xe.CI.BAT: " 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=20260127193727.601-2-michal.wajdeczko@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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