Skip to content

Commit 7276878

Browse files
harishchegondiLucas De Marchi
authored andcommitted
drm/xe: Fix conversion from clock ticks to milliseconds
When tick counts are large and multiplication by MSEC_PER_SEC is larger than 64 bits, the conversion from clock ticks to milliseconds can go bad. Use mul_u64_u32_div() instead. Cc: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Harish Chegondi <harish.chegondi@intel.com> Suggested-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Fixes: 49cc215 ("drm/xe: Add xe_gt_clock_interval_to_ms helper") Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Link: https://patch.msgid.link/1562f1b62d5be3fbaee100f09107f3cc49e40dd1.1763408584.git.harish.chegondi@intel.com (cherry picked from commit 96b93ac) Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent 0e23463 commit 7276878

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

drivers/gpu/drm/xe/xe_gt_clock.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ int xe_gt_clock_init(struct xe_gt *gt)
9393
return 0;
9494
}
9595

96-
static u64 div_u64_roundup(u64 n, u32 d)
97-
{
98-
return div_u64(n + d - 1, d);
99-
}
100-
10196
/**
10297
* xe_gt_clock_interval_to_ms - Convert sampled GT clock ticks to msec
10398
*
@@ -108,5 +103,5 @@ static u64 div_u64_roundup(u64 n, u32 d)
108103
*/
109104
u64 xe_gt_clock_interval_to_ms(struct xe_gt *gt, u64 count)
110105
{
111-
return div_u64_roundup(count * MSEC_PER_SEC, gt->info.reference_clock);
106+
return mul_u64_u32_div(count, MSEC_PER_SEC, gt->info.reference_clock);
112107
}

0 commit comments

Comments
 (0)