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

drm/xe: Add xe_gt_clock_interval_to_ms helper

Add helper to convert GT clock ticks to msec. Useful for determining if
timeouts occur by examing GT clock ticks.

v6:
- s/nom/n , s/dom/d (Jonathan)
- include math64 (CI)

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240611144053.2805091-6-matthew.brost@intel.com

+21
+20
drivers/gpu/drm/xe/xe_gt_clock.c
··· 3 3 * Copyright © 2022 Intel Corporation 4 4 */ 5 5 6 + #include <linux/math64.h> 7 + 6 8 #include "xe_gt_clock.h" 7 9 8 10 #include "regs/xe_gt_regs.h" ··· 80 78 81 79 gt->info.reference_clock = freq; 82 80 return 0; 81 + } 82 + 83 + static u64 div_u64_roundup(u64 n, u32 d) 84 + { 85 + return div_u64(n + d - 1, d); 86 + } 87 + 88 + /** 89 + * xe_gt_clock_interval_to_ms - Convert sampled GT clock ticks to msec 90 + * 91 + * @gt: the &xe_gt 92 + * @count: count of GT clock ticks 93 + * 94 + * Returns: time in msec 95 + */ 96 + u64 xe_gt_clock_interval_to_ms(struct xe_gt *gt, u64 count) 97 + { 98 + return div_u64_roundup(count * MSEC_PER_SEC, gt->info.reference_clock); 83 99 }
+1
drivers/gpu/drm/xe/xe_gt_clock.h
··· 11 11 struct xe_gt; 12 12 13 13 int xe_gt_clock_init(struct xe_gt *gt); 14 + u64 xe_gt_clock_interval_to_ms(struct xe_gt *gt, u64 count); 14 15 15 16 #endif