Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: split out i915_timer_util.[ch]

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>

+64 -45
+1
drivers/gpu/drm/i915/Makefile
··· 32 32 i915_scatterlist.o \ 33 33 i915_switcheroo.o \ 34 34 i915_sysfs.o \ 35 + i915_timer_util.o \ 35 36 i915_utils.o \ 36 37 intel_clock_gating.o \ 37 38 intel_cpu_info.o \
+3 -1
drivers/gpu/drm/i915/gt/intel_execlists_submission.c
··· 106 106 * preemption, but just sampling the new tail pointer). 107 107 * 108 108 */ 109 + 109 110 #include <linux/interrupt.h> 110 111 #include <linux/string_helpers.h> 111 112 113 + #include "gen8_engine_cs.h" 112 114 #include "i915_drv.h" 113 115 #include "i915_reg.h" 116 + #include "i915_timer_util.h" 114 117 #include "i915_trace.h" 115 118 #include "i915_vgpu.h" 116 - #include "gen8_engine_cs.h" 117 119 #include "intel_breadcrumbs.h" 118 120 #include "intel_context.h" 119 121 #include "intel_engine_heartbeat.h"
+1
drivers/gpu/drm/i915/gt/sysfs_engines.c
··· 7 7 #include <linux/sysfs.h> 8 8 9 9 #include "i915_drv.h" 10 + #include "i915_timer_util.h" 10 11 #include "intel_engine.h" 11 12 #include "intel_engine_heartbeat.h" 12 13 #include "sysfs_engines.h"
+36
drivers/gpu/drm/i915/i915_timer_util.c
··· 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 + }
+23
drivers/gpu/drm/i915/i915_timer_util.h
··· 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__ */
-30
drivers/gpu/drm/i915/i915_utils.c
··· 47 47 48 48 #endif 49 49 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 - 80 50 bool i915_vtd_active(struct drm_i915_private *i915) 81 51 { 82 52 if (device_iommu_mapped(i915->drm.dev))
-14
drivers/gpu/drm/i915/i915_utils.h
··· 38 38 #endif 39 39 40 40 struct drm_i915_private; 41 - struct timer_list; 42 41 43 42 #define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \ 44 43 __stringify(x), (long)(x)) ··· 267 268 * the machine if the kernel is tainted. 268 269 */ 269 270 add_taint(taint, LOCKDEP_STILL_OK); 270 - } 271 - 272 - void cancel_timer(struct timer_list *t); 273 - void set_timer_ms(struct timer_list *t, unsigned long timeout); 274 - 275 - static inline bool timer_active(const struct timer_list *t) 276 - { 277 - return READ_ONCE(t->expires); 278 - } 279 - 280 - static inline bool timer_expired(const struct timer_list *t) 281 - { 282 - return timer_active(t) && !timer_pending(t); 283 271 } 284 272 285 273 static inline bool i915_run_as_guest(void)