[PATCH v9 1/2] drm/xe: Get GT clock to nanosecs
Lucas De Marchi
lucas.demarchi at intel.com
Fri Jun 14 14:57:32 UTC 2024
On Thu, Jun 13, 2024 at 03:34:10PM GMT, Riana Tauro wrote:
>From: Aravind Iddamsetty <aravind.iddamsetty at linux.intel.com>
>
>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
>v4: rebase
>v5: add doc
>
>Reviewed-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
>Reviewed-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
>Signed-off-by: Aravind Iddamsetty <aravind.iddamsetty at linux.intel.com>
>Signed-off-by: Riana Tauro <riana.tauro at intel.com>
>---
> drivers/gpu/drm/xe/xe_gt_clock.c | 13 +++++++++++++
> drivers/gpu/drm/xe/xe_gt_clock.h | 2 +-
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_gt_clock.c b/drivers/gpu/drm/xe/xe_gt_clock.c
>index 86c2d62b4bdc..17bd8851ef3c 100644
>--- a/drivers/gpu/drm/xe/xe_gt_clock.c
>+++ b/drivers/gpu/drm/xe/xe_gt_clock.c
>@@ -99,3 +99,16 @@ u64 xe_gt_clock_interval_to_ms(struct xe_gt *gt, u64 count)
> {
> return div_u64_roundup(count * MSEC_PER_SEC, gt->info.reference_clock);
> }
>+
>+/**
>+ * xe_gt_clock_cycles_to_ns - Convert sampled GT clock ticks to nsec
>+ *
>+ * @gt: GT instance
>+ * @count: count of GT clock ticks
>+ *
>+ * Returns: time in nsec
>+ */
>+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.reference_clock);
other than the changed unit (nsec vs msec), this is the same as the function above,
no reason for a different function name.
nit: we should be using the longer nsec/msec/sec convention rather than
ns/ms as it makes less ambiguous in code, matches other macros/functions.
Suggestion:
s/xe_gt_clock_interval_to_ms/xe_gt_clock_cycles_to_msec/ and make it use
DIV_ROUND_CLOSEST_ULL.
s/xe_gt_clock_cycles_to_ns/xe_gt_clock_cycles_to_nsec/.
+Matt Brost to ack
Lucas De Marchi
More information about the Intel-xe
mailing list