[Intel-xe] [PATCH v2 1/2] drm/xe: Get GT clock to nanosecs

Dixit, Ashutosh ashutosh.dixit at intel.com
Thu Jul 6 00:55:24 UTC 2023


On Tue, 27 Jun 2023 05:21:12 -0700, Aravind Iddamsetty wrote:
>

Hi Aravind,

> 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)

s/num/nom/

> +{
> +	return div_u64(nom + den - 1, den);
> +}
> +

Shouldn't need this function. Look at DIV_ROUND_CLOSEST_ULL in math.h or
DIV64_U64_ROUND_CLOSEST or DIV64_U64_ROUND_UP in math64.h.

> +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
>

Ashutosh


More information about the Intel-xe mailing list