File tree Expand file tree Collapse file tree 7 files changed +64
-45
lines changed
Expand file tree Collapse file tree 7 files changed +64
-45
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ i915-y += \
3232 i915_scatterlist.o \
3333 i915_switcheroo.o \
3434 i915_sysfs.o \
35+ i915_timer_util.o \
3536 i915_utils.o \
3637 intel_clock_gating.o \
3738 intel_cpu_info.o \
Original file line number Diff line number Diff line change 106106 * preemption, but just sampling the new tail pointer).
107107 *
108108 */
109+
109110#include <linux/interrupt.h>
110111#include <linux/string_helpers.h>
111112
113+ #include "gen8_engine_cs.h"
112114#include "i915_drv.h"
113115#include "i915_reg.h"
116+ #include "i915_timer_util.h"
114117#include "i915_trace.h"
115118#include "i915_vgpu.h"
116- #include "gen8_engine_cs.h"
117119#include "intel_breadcrumbs.h"
118120#include "intel_context.h"
119121#include "intel_engine_heartbeat.h"
Original file line number Diff line number Diff line change 77#include <linux/sysfs.h>
88
99#include "i915_drv.h"
10+ #include "i915_timer_util.h"
1011#include "intel_engine.h"
1112#include "intel_engine_heartbeat.h"
1213#include "sysfs_engines.h"
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+ /* Copyright © 2025 Intel Corporation */
3+
4+ #include <linux/jiffies.h>
5+
6+ #include "i915_timer_util.h"
7+
8+ void cancel_timer (struct timer_list * t )
9+ {
10+ if (!timer_active (t ))
11+ return ;
12+
13+ timer_delete (t );
14+ WRITE_ONCE (t -> expires , 0 );
15+ }
16+
17+ void set_timer_ms (struct timer_list * t , unsigned long timeout )
18+ {
19+ if (!timeout ) {
20+ cancel_timer (t );
21+ return ;
22+ }
23+
24+ timeout = msecs_to_jiffies (timeout );
25+
26+ /*
27+ * Paranoia to make sure the compiler computes the timeout before
28+ * loading 'jiffies' as jiffies is volatile and may be updated in
29+ * the background by a timer tick. All to reduce the complexity
30+ * of the addition and reduce the risk of losing a jiffy.
31+ */
32+ barrier ();
33+
34+ /* Keep t->expires = 0 reserved to indicate a canceled timer. */
35+ mod_timer (t , jiffies + timeout ?: 1 );
36+ }
Original file line number Diff line number Diff line change 1+ /* SPDX-License-Identifier: MIT */
2+ /* Copyright © 2025 Intel Corporation */
3+
4+ #ifndef __I915_TIMER_UTIL_H__
5+ #define __I915_TIMER_UTIL_H__
6+
7+ #include <linux/timer.h>
8+ #include <asm/rwonce.h>
9+
10+ void cancel_timer (struct timer_list * t );
11+ void set_timer_ms (struct timer_list * t , unsigned long timeout );
12+
13+ static inline bool timer_active (const struct timer_list * t )
14+ {
15+ return READ_ONCE (t -> expires );
16+ }
17+
18+ static inline bool timer_expired (const struct timer_list * t )
19+ {
20+ return timer_active (t ) && !timer_pending (t );
21+ }
22+
23+ #endif /* __I915_TIMER_UTIL_H__ */
Original file line number Diff line number Diff line change @@ -47,36 +47,6 @@ bool i915_error_injected(void)
4747
4848#endif
4949
50- void cancel_timer (struct timer_list * t )
51- {
52- if (!timer_active (t ))
53- return ;
54-
55- timer_delete (t );
56- WRITE_ONCE (t -> expires , 0 );
57- }
58-
59- void set_timer_ms (struct timer_list * t , unsigned long timeout )
60- {
61- if (!timeout ) {
62- cancel_timer (t );
63- return ;
64- }
65-
66- timeout = msecs_to_jiffies (timeout );
67-
68- /*
69- * Paranoia to make sure the compiler computes the timeout before
70- * loading 'jiffies' as jiffies is volatile and may be updated in
71- * the background by a timer tick. All to reduce the complexity
72- * of the addition and reduce the risk of losing a jiffy.
73- */
74- barrier ();
75-
76- /* Keep t->expires = 0 reserved to indicate a canceled timer. */
77- mod_timer (t , jiffies + timeout ?: 1 );
78- }
79-
8050bool i915_vtd_active (struct drm_i915_private * i915 )
8151{
8252 if (device_iommu_mapped (i915 -> drm .dev ))
Original file line number Diff line number Diff line change 3838#endif
3939
4040struct drm_i915_private ;
41- struct timer_list ;
4241
4342#define MISSING_CASE (x ) WARN(1, "Missing case (%s == %ld)\n", \
4443 __stringify(x), (long)(x))
@@ -270,19 +269,6 @@ static inline void __add_taint_for_CI(unsigned int taint)
270269 add_taint (taint , LOCKDEP_STILL_OK );
271270}
272271
273- void cancel_timer (struct timer_list * t );
274- void set_timer_ms (struct timer_list * t , unsigned long timeout );
275-
276- static inline bool timer_active (const struct timer_list * t )
277- {
278- return READ_ONCE (t -> expires );
279- }
280-
281- static inline bool timer_expired (const struct timer_list * t )
282- {
283- return timer_active (t ) && !timer_pending (t );
284- }
285-
286272static inline bool i915_run_as_guest (void )
287273{
288274#if IS_ENABLED (CONFIG_X86 )
You can’t perform that action at this time.
0 commit comments