[Intel-xe] [PATCH v2 1/2] drm/xe: Get GT clock to nanosecs
Aravind Iddamsetty
aravind.iddamsetty at intel.com
Tue Jun 27 12:21:12 UTC 2023
Helpers to get GT clock to nanosecs
Signed-off-by: Aravind Iddamsetty <aravind.iddamsetty at intel.com>
---
drivers/gpu/drm/xe/xe_gt_clock.c | 10 ++++++++++
drivers/gpu/drm/xe/xe_gt_clock.h | 4 +++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_gt_clock.c b/drivers/gpu/drm/xe/xe_gt_clock.c
index 7cf11078ff57..3689c7d5cf53 100644
--- a/drivers/gpu/drm/xe/xe_gt_clock.c
+++ b/drivers/gpu/drm/xe/xe_gt_clock.c
@@ -78,3 +78,13 @@ int xe_gt_clock_init(struct xe_gt *gt)
gt->info.clock_freq = freq;
return 0;
}
+
+static u64 div_u64_roundup(u64 nom, u32 den)
+{
+ return div_u64(nom + den - 1, den);
+}
+
+u64 xe_gt_clock_interval_to_ns(const struct xe_gt *gt, u64 count)
+{
+ return div_u64_roundup(count * NSEC_PER_SEC, gt->info.clock_freq);
+}
diff --git a/drivers/gpu/drm/xe/xe_gt_clock.h b/drivers/gpu/drm/xe/xe_gt_clock.h
index 511923afd224..91fc9b7e83f5 100644
--- a/drivers/gpu/drm/xe/xe_gt_clock.h
+++ b/drivers/gpu/drm/xe/xe_gt_clock.h
@@ -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_interval_to_ns(const struct xe_gt *gt, u64 count);
#endif
--
2.25.1
More information about the Intel-xe
mailing list