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

Configure Feed

Select the types of activity you want to include in your feed.

drm/i915: split out separate files for jiffies timeout and wait helpers

Add i915_jiffies.h and intel_display_jiffies.h for jiffies timeout and
wait helpers, and use them separately from i915 and display. This helps
reduce the display dependency on i915_utils.h.

Long term, both msecs_to_jiffies_timeout() and
wait_remaining_ms_from_jiffies() really belong in core kernel headers,
but for now unblock display refactoring.

Reviewed-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://patch.msgid.link/d8bc62b3a81afa05c849dde9b0f633572eaf5611.1761146196.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+73 -37
+43
drivers/gpu/drm/i915/display/intel_display_jiffies.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #ifndef __INTEL_DISPLAY_JIFFIES_H__ 5 + #define __INTEL_DISPLAY_JIFFIES_H__ 6 + 7 + #include <linux/jiffies.h> 8 + 9 + static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m) 10 + { 11 + unsigned long j = msecs_to_jiffies(m); 12 + 13 + return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1); 14 + } 15 + 16 + /* 17 + * If you need to wait X milliseconds between events A and B, but event B 18 + * doesn't happen exactly after event A, you record the timestamp (jiffies) of 19 + * when event A happened, then just before event B you call this function and 20 + * pass the timestamp as the first argument, and X as the second argument. 21 + */ 22 + static inline void 23 + wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms) 24 + { 25 + unsigned long target_jiffies, tmp_jiffies, remaining_jiffies; 26 + 27 + /* 28 + * Don't re-read the value of "jiffies" every time since it may change 29 + * behind our back and break the math. 30 + */ 31 + tmp_jiffies = jiffies; 32 + target_jiffies = timestamp_jiffies + 33 + msecs_to_jiffies_timeout(to_wait_ms); 34 + 35 + if (time_after(target_jiffies, tmp_jiffies)) { 36 + remaining_jiffies = target_jiffies - tmp_jiffies; 37 + while (remaining_jiffies) 38 + remaining_jiffies = 39 + schedule_timeout_uninterruptible(remaining_jiffies); 40 + } 41 + } 42 + 43 + #endif /* __INTEL_DISPLAY_JIFFIES_H__ */
+1
drivers/gpu/drm/i915/display/intel_dp.c
··· 64 64 #include "intel_ddi.h" 65 65 #include "intel_de.h" 66 66 #include "intel_display_driver.h" 67 + #include "intel_display_jiffies.h" 67 68 #include "intel_display_regs.h" 68 69 #include "intel_display_rpm.h" 69 70 #include "intel_display_types.h"
+1
drivers/gpu/drm/i915/display/intel_hdcp.c
··· 22 22 #include "i915_utils.h" 23 23 #include "intel_connector.h" 24 24 #include "intel_de.h" 25 + #include "intel_display_jiffies.h" 25 26 #include "intel_display_power.h" 26 27 #include "intel_display_power_well.h" 27 28 #include "intel_display_regs.h"
+1
drivers/gpu/drm/i915/display/intel_pmdemand.c
··· 12 12 #include "intel_bw.h" 13 13 #include "intel_cdclk.h" 14 14 #include "intel_de.h" 15 + #include "intel_display_jiffies.h" 15 16 #include "intel_display_regs.h" 16 17 #include "intel_display_trace.h" 17 18 #include "intel_pmdemand.h"
+1
drivers/gpu/drm/i915/display/intel_pps.c
··· 12 12 #include "i915_reg.h" 13 13 #include "i915_utils.h" 14 14 #include "intel_de.h" 15 + #include "intel_display_jiffies.h" 15 16 #include "intel_display_power_well.h" 16 17 #include "intel_display_regs.h" 17 18 #include "intel_display_types.h"
+1
drivers/gpu/drm/i915/display/intel_vblank.c
··· 12 12 #include "intel_color.h" 13 13 #include "intel_crtc.h" 14 14 #include "intel_de.h" 15 + #include "intel_display_jiffies.h" 15 16 #include "intel_display_regs.h" 16 17 #include "intel_display_types.h" 17 18 #include "intel_vblank.h"
+3 -2
drivers/gpu/drm/i915/gem/i915_gem_mman.c
··· 16 16 #include "i915_gem_evict.h" 17 17 #include "i915_gem_gtt.h" 18 18 #include "i915_gem_ioctls.h" 19 - #include "i915_gem_object.h" 20 19 #include "i915_gem_mman.h" 20 + #include "i915_gem_object.h" 21 + #include "i915_gem_ttm.h" 22 + #include "i915_jiffies.h" 21 23 #include "i915_mm.h" 22 24 #include "i915_trace.h" 23 25 #include "i915_user_extensions.h" 24 - #include "i915_gem_ttm.h" 25 26 #include "i915_vma.h" 26 27 27 28 static inline bool
+1
drivers/gpu/drm/i915/gem/i915_gem_ttm.c
··· 10 10 #include <drm/drm_buddy.h> 11 11 12 12 #include "i915_drv.h" 13 + #include "i915_jiffies.h" 13 14 #include "i915_ttm_buddy_manager.h" 14 15 #include "intel_memory_region.h" 15 16 #include "intel_region_ttm.h"
+1
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c
··· 4 4 */ 5 5 6 6 #include "i915_drv.h" 7 + #include "i915_jiffies.h" 7 8 #include "i915_request.h" 8 9 9 10 #include "intel_context.h"
+1
drivers/gpu/drm/i915/gt/selftest_execlists.c
··· 11 11 #include "gt/intel_reset.h" 12 12 #include "gt/selftest_engine_heartbeat.h" 13 13 14 + #include "i915_jiffies.h" 14 15 #include "i915_selftest.h" 15 16 #include "selftests/i915_random.h" 16 17 #include "selftests/igt_flush_test.h"
+1 -1
drivers/gpu/drm/i915/i915_config.c
··· 6 6 #include <linux/kernel.h> 7 7 8 8 #include "i915_config.h" 9 - #include "i915_utils.h" 9 + #include "i915_jiffies.h" 10 10 11 11 unsigned long 12 12 i915_fence_context_timeout(const struct drm_i915_private *i915, u64 context)
+16
drivers/gpu/drm/i915/i915_jiffies.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #ifndef __I915_JIFFIES_H__ 5 + #define __I915_JIFFIES_H__ 6 + 7 + #include <linux/jiffies.h> 8 + 9 + static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m) 10 + { 11 + unsigned long j = msecs_to_jiffies(m); 12 + 13 + return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1); 14 + } 15 + 16 + #endif /* __I915_JIFFIES_H__ */
-34
drivers/gpu/drm/i915/i915_utils.h
··· 100 100 return (n != 0 && ((n & (n - 1)) == 0)); 101 101 } 102 102 103 - static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m) 104 - { 105 - unsigned long j = msecs_to_jiffies(m); 106 - 107 - return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1); 108 - } 109 - 110 - /* 111 - * If you need to wait X milliseconds between events A and B, but event B 112 - * doesn't happen exactly after event A, you record the timestamp (jiffies) of 113 - * when event A happened, then just before event B you call this function and 114 - * pass the timestamp as the first argument, and X as the second argument. 115 - */ 116 - static inline void 117 - wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms) 118 - { 119 - unsigned long target_jiffies, tmp_jiffies, remaining_jiffies; 120 - 121 - /* 122 - * Don't re-read the value of "jiffies" every time since it may change 123 - * behind our back and break the math. 124 - */ 125 - tmp_jiffies = jiffies; 126 - target_jiffies = timestamp_jiffies + 127 - msecs_to_jiffies_timeout(to_wait_ms); 128 - 129 - if (time_after(target_jiffies, tmp_jiffies)) { 130 - remaining_jiffies = target_jiffies - tmp_jiffies; 131 - while (remaining_jiffies) 132 - remaining_jiffies = 133 - schedule_timeout_uninterruptible(remaining_jiffies); 134 - } 135 - } 136 - 137 103 #define KHz(x) (1000 * (x)) 138 104 #define MHz(x) KHz(1000 * (x)) 139 105
+1
drivers/gpu/drm/i915/selftests/i915_selftest.c
··· 30 30 31 31 #include "i915_driver.h" 32 32 #include "i915_drv.h" 33 + #include "i915_jiffies.h" 33 34 #include "i915_selftest.h" 34 35 #include "i915_wait_util.h" 35 36 #include "igt_flush_test.h"