summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichal Wajdeczko <michal.wajdeczko@intel.com>2026-01-27 20:37:21 +0100
committerMichal Wajdeczko <michal.wajdeczko@intel.com>2026-02-02 22:35:41 +0100
commit94a2ceb1906d2bcbf2c6afbc5ede400eea3872c8 (patch)
treeb108e737dfa30af33ffb86ee8524558aebfe9dbc /drivers
parent316b05ae7ed90544733f5c01e14f64d6e84a80dc (diff)
downloadlinux-94a2ceb1906d2bcbf2c6afbc5ede400eea3872c8.tar.gz
linux-94a2ceb1906d2bcbf2c6afbc5ede400eea3872c8.zip
drm/xe: Promote relaxed_ms_sleep
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
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/xe/xe_guc_submit.c23
-rw-r--r--drivers/gpu/drm/xe/xe_sleep.h36
2 files changed, 38 insertions, 21 deletions
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 1f4625ddae0e..bab930ca62e3 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"
@@ -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
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