]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/i915: split out i915_timer_util.[ch]
authorJani Nikula <jani.nikula@intel.com>
Thu, 11 Sep 2025 09:17:38 +0000 (12:17 +0300)
committerJani Nikula <jani.nikula@intel.com>
Fri, 12 Sep 2025 08:08:45 +0000 (11:08 +0300)
Move timer related utilities from i915_utils.[ch] to separate new files
i915_timer_util.[ch]. Clean up related includes.

Note: Arguably none of this should exist in i915 in the first place. At
least isolate it better.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/0a83d9489626121dcefcd4c1a05317399b5708f3.1757582214.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/Makefile
drivers/gpu/drm/i915/gt/intel_execlists_submission.c
drivers/gpu/drm/i915/gt/sysfs_engines.c
drivers/gpu/drm/i915/i915_timer_util.c [new file with mode: 0644]
drivers/gpu/drm/i915/i915_timer_util.h [new file with mode: 0644]
drivers/gpu/drm/i915/i915_utils.c
drivers/gpu/drm/i915/i915_utils.h

index db150a0c33ceb764535e1f1868ace6821cec674c..e58c0c158b3ab2e362e68b0b41f649a4087d2f54 100644 (file)
@@ -32,6 +32,7 @@ i915-y += \
        i915_scatterlist.o \
        i915_switcheroo.o \
        i915_sysfs.o \
+       i915_timer_util.o \
        i915_utils.o \
        intel_clock_gating.o \
        intel_cpu_info.o \
index 03baa7fa0a27c0e696067cdd39a0649557c335ff..52c8fddedfce45af7074ced176263fe72792e11d 100644 (file)
  * preemption, but just sampling the new tail pointer).
  *
  */
+
 #include <linux/interrupt.h>
 #include <linux/string_helpers.h>
 
+#include "gen8_engine_cs.h"
 #include "i915_drv.h"
 #include "i915_reg.h"
+#include "i915_timer_util.h"
 #include "i915_trace.h"
 #include "i915_vgpu.h"
-#include "gen8_engine_cs.h"
 #include "intel_breadcrumbs.h"
 #include "intel_context.h"
 #include "intel_engine_heartbeat.h"
index aab2759067d2ecb8fba3f6b664b29e92587611da..4a81bc396b21a650570e2ceeb3fc9e126f980e34 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/sysfs.h>
 
 #include "i915_drv.h"
+#include "i915_timer_util.h"
 #include "intel_engine.h"
 #include "intel_engine_heartbeat.h"
 #include "sysfs_engines.h"
diff --git a/drivers/gpu/drm/i915/i915_timer_util.c b/drivers/gpu/drm/i915/i915_timer_util.c
new file mode 100644 (file)
index 0000000..ee4cfd8
--- /dev/null
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: MIT
+/* Copyright © 2025 Intel Corporation */
+
+#include <linux/jiffies.h>
+
+#include "i915_timer_util.h"
+
+void cancel_timer(struct timer_list *t)
+{
+       if (!timer_active(t))
+               return;
+
+       timer_delete(t);
+       WRITE_ONCE(t->expires, 0);
+}
+
+void set_timer_ms(struct timer_list *t, unsigned long timeout)
+{
+       if (!timeout) {
+               cancel_timer(t);
+               return;
+       }
+
+       timeout = msecs_to_jiffies(timeout);
+
+       /*
+        * Paranoia to make sure the compiler computes the timeout before
+        * loading 'jiffies' as jiffies is volatile and may be updated in
+        * the background by a timer tick. All to reduce the complexity
+        * of the addition and reduce the risk of losing a jiffy.
+        */
+       barrier();
+
+       /* Keep t->expires = 0 reserved to indicate a canceled timer. */
+       mod_timer(t, jiffies + timeout ?: 1);
+}
diff --git a/drivers/gpu/drm/i915/i915_timer_util.h b/drivers/gpu/drm/i915/i915_timer_util.h
new file mode 100644 (file)
index 0000000..f35ad73
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: MIT */
+/* Copyright © 2025 Intel Corporation */
+
+#ifndef __I915_TIMER_UTIL_H__
+#define __I915_TIMER_UTIL_H__
+
+#include <linux/timer.h>
+#include <asm/rwonce.h>
+
+void cancel_timer(struct timer_list *t);
+void set_timer_ms(struct timer_list *t, unsigned long timeout);
+
+static inline bool timer_active(const struct timer_list *t)
+{
+       return READ_ONCE(t->expires);
+}
+
+static inline bool timer_expired(const struct timer_list *t)
+{
+       return timer_active(t) && !timer_pending(t);
+}
+
+#endif /* __I915_TIMER_UTIL_H__ */
index b60c28fbd207c1ec510f10a7732a1a1261886990..49f7ed413132254c5b15ff465e891e98fb203a90 100644 (file)
@@ -47,36 +47,6 @@ bool i915_error_injected(void)
 
 #endif
 
-void cancel_timer(struct timer_list *t)
-{
-       if (!timer_active(t))
-               return;
-
-       timer_delete(t);
-       WRITE_ONCE(t->expires, 0);
-}
-
-void set_timer_ms(struct timer_list *t, unsigned long timeout)
-{
-       if (!timeout) {
-               cancel_timer(t);
-               return;
-       }
-
-       timeout = msecs_to_jiffies(timeout);
-
-       /*
-        * Paranoia to make sure the compiler computes the timeout before
-        * loading 'jiffies' as jiffies is volatile and may be updated in
-        * the background by a timer tick. All to reduce the complexity
-        * of the addition and reduce the risk of losing a jiffy.
-        */
-       barrier();
-
-       /* Keep t->expires = 0 reserved to indicate a canceled timer. */
-       mod_timer(t, jiffies + timeout ?: 1);
-}
-
 bool i915_vtd_active(struct drm_i915_private *i915)
 {
        if (device_iommu_mapped(i915->drm.dev))
index dff02a944a579448e27febde3437b773fb6248d2..6278a74d08c2aa36755800381225578e3d2035d1 100644 (file)
@@ -38,7 +38,6 @@
 #endif
 
 struct drm_i915_private;
-struct timer_list;
 
 #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
                             __stringify(x), (long)(x))
@@ -270,19 +269,6 @@ static inline void __add_taint_for_CI(unsigned int taint)
        add_taint(taint, LOCKDEP_STILL_OK);
 }
 
-void cancel_timer(struct timer_list *t);
-void set_timer_ms(struct timer_list *t, unsigned long timeout);
-
-static inline bool timer_active(const struct timer_list *t)
-{
-       return READ_ONCE(t->expires);
-}
-
-static inline bool timer_expired(const struct timer_list *t)
-{
-       return timer_active(t) && !timer_pending(t);
-}
-
 static inline bool i915_run_as_guest(void)
 {
 #if IS_ENABLED(CONFIG_X86)