drm/xe: Get GT clock to nanosecs
authorAravind Iddamsetty <aravind.iddamsetty@linux.intel.com>
Wed, 30 Aug 2023 03:16:50 +0000 (08:46 +0530)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:41:13 +0000 (11:41 -0500)
Helper to convert GT clock cycles to nanoseconds.

v2: Use DIV_ROUND_CLOSEST_ULL helper(Ashutosh)
v3: rename xe_gt_clock_interval_to_ns to xe_gt_clock_cycles_to_ns

Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Aravind Iddamsetty <aravind.iddamsetty@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_gt_clock.c
drivers/gpu/drm/xe/xe_gt_clock.h

index 9136937324f3463b2adb4a4e390371f23a41ab56..25a18eaad9c4b12c5d1e609b681b71c15465e459 100644 (file)
@@ -78,3 +78,8 @@ int xe_gt_clock_init(struct xe_gt *gt)
        gt->info.clock_freq = freq;
        return 0;
 }
+
+u64 xe_gt_clock_cycles_to_ns(const struct xe_gt *gt, u64 count)
+{
+       return DIV_ROUND_CLOSEST_ULL(count * NSEC_PER_SEC, gt->info.clock_freq);
+}
index 511923afd224a8c8e4939b7f8b5d6abde55f641d..aa162722f85964767e0880ff4006e9424e2df362 100644 (file)
@@ -6,8 +6,10 @@
 #ifndef _XE_GT_CLOCK_H_
 #define _XE_GT_CLOCK_H_
 
+#include <linux/types.h>
+
 struct xe_gt;
 
 int xe_gt_clock_init(struct xe_gt *gt);
-
+u64 xe_gt_clock_cycles_to_ns(const struct xe_gt *gt, u64 count);
 #endif