]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Promote relaxed_ms_sleep
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 27 Jan 2026 19:37:21 +0000 (20:37 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 2 Feb 2026 21:35:41 +0000 (22:35 +0100)
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>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260127193727.601-2-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_guc_submit.c
drivers/gpu/drm/xe/xe_sleep.h [new file with mode: 0644]

index 1f4625ddae0eaa751529794a2104152fc541af0c..bab930ca62e3f2c20e9056f48334fe792dfc438a 100644 (file)
@@ -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"
@@ -1032,24 +1031,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);
@@ -1834,7 +1815,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 (file)
index 0000000..a772f1a
--- /dev/null
@@ -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