[PATCH v2] drm/xe: Explicitly cast to u64 to avoid overflow

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Fri Jun 14 06:24:15 UTC 2024


Without casting whole expression will be calculated on u32 what
means adding U32_MAX effectively decreases the result by one due to
overflow. Fix this and use explicit cast to u64.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Matthew Brost <matthew.brost at intel.com>
---
v2: Fix spacing
---
 drivers/gpu/drm/xe/xe_guc_submit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 74552391dc5a..f46d1e18f8e7 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -967,7 +967,7 @@ static bool check_timeout(struct xe_exec_queue *q, struct xe_sched_job *job)
 	xe_gt_assert(gt, timeout_ms < 100 * MSEC_PER_SEC);
 
 	if (ctx_timestamp < ctx_job_timestamp)
-		diff = ctx_timestamp + U32_MAX - ctx_job_timestamp;
+		diff = (u64)ctx_timestamp + U32_MAX - ctx_job_timestamp;
 	else
 		diff = ctx_timestamp - ctx_job_timestamp;
 
-- 
2.34.1



More information about the Intel-xe mailing list