summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/xe/xe_mmio.h
diff options
context:
space:
mode:
authorRodrigo Vivi <rodrigo.vivi@intel.com>2023-01-12 17:25:03 -0500
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-12 14:05:59 -0500
commit0f06dc101972d598d1c6bb356436c3dbf1e4b646 (patch)
tree5c7188145bc70047a8732ea9c2e12831cd660a64 /drivers/gpu/drm/xe/xe_mmio.h
parentdd08ebf6c3525a7ea2186e636df064ea47281987 (diff)
downloadlinux-stable-0f06dc101972d598d1c6bb356436c3dbf1e4b646.tar.gz
linux-stable-0f06dc101972d598d1c6bb356436c3dbf1e4b646.tar.bz2
linux-stable-0f06dc101972d598d1c6bb356436c3dbf1e4b646.zip
drm/xe: Implement a local xe_mmio_wait32
Then, move the i915_utils.h include to its user. The overall goal is to kill all the usages of the i915_utils stuff. Yes, wait_for also depends on <linux/delay.h>, so they go together to where it is needed. It will be likely needed anyway directly for udelay or usleep_range. Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_mmio.h')
-rw-r--r--drivers/gpu/drm/xe/xe_mmio.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/gpu/drm/xe/xe_mmio.h b/drivers/gpu/drm/xe/xe_mmio.h
index 09d24467096f..7352b622ca87 100644
--- a/drivers/gpu/drm/xe/xe_mmio.h
+++ b/drivers/gpu/drm/xe/xe_mmio.h
@@ -10,13 +10,6 @@
#include "xe_gt_types.h"
-/*
- * FIXME: This header has been deemed evil and we need to kill it. Temporarily
- * including so we can use 'wait_for' and unblock initial development. A follow
- * should replace 'wait_for' with a sane version and drop including this header.
- */
-#include "i915_utils.h"
-
struct drm_device;
struct drm_file;
struct xe_device;
@@ -93,8 +86,26 @@ static inline int xe_mmio_wait32(struct xe_gt *gt,
u32 reg, u32 val,
u32 mask, u32 timeout_ms)
{
- return wait_for((xe_mmio_read32(gt, reg) & mask) == val,
- timeout_ms);
+ ktime_t cur = ktime_get_raw();
+ const ktime_t end = ktime_add_ms(cur, timeout_ms);
+ s64 wait = 10;
+
+ for (;;) {
+ if ((xe_mmio_read32(gt, reg) & mask) == val)
+ return 0;
+
+ cur = ktime_get_raw();
+ if (!ktime_before(cur, end))
+ return -ETIMEDOUT;
+
+ if (ktime_after(ktime_add_us(cur, wait), end))
+ wait = ktime_us_delta(end, cur);
+
+ usleep_range(wait, wait << 1);
+ wait <<= 1;
+ }
+
+ return -ETIMEDOUT;
}
int xe_mmio_ioctl(struct drm_device *dev, void *data,