Re: [PATCH 3/3] drm/amdgpu: Hot-fix timestamp misordering
From: Tvrtko Ursulin
Date: Fri Nov 27 2026 - 04:58:04 EST
On 26/11/2026 17:20, Philipp Stanner wrote:
dma_fence timestamps could so far be written and read without any memory
ordering, a bug that presumably got overlooked because x86 is strongly
ordered.
Hot-fix amdgpu's manual timestamp evaluation until we found a more
suitable solution for mainline linux.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: af0b54167009 ("drm/amdgpu: Convert to common fdinfo format v5")
Not sure the fixes target is strictly correct since timestamp access goes even further back, but I guess it is good enough for GPU stats.
Please just add some sort of an impact assessment and bug description to the commit text. With that:
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxx>
Regards,
Tvrtko
Signed-off-by: Philipp Stanner <phasta@xxxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 2f0349233695..415f23aa08a0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -177,11 +177,11 @@ static ktime_t amdgpu_ctx_fence_time(struct dma_fence *fence)
/* When the fence is not even scheduled it can't have spend time */
s_fence = to_drm_sched_fence(fence);
- if (!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &s_fence->scheduled.flags))
+ if (!test_bit_acquire(DMA_FENCE_FLAG_TIMESTAMP_BIT, &s_fence->scheduled.flags))
return ns_to_ktime(0);
/* When it is still running account how much already spend */
- if (!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &s_fence->finished.flags))
+ if (!test_bit_acquire(DMA_FENCE_FLAG_TIMESTAMP_BIT, &s_fence->finished.flags))
return ktime_sub(ktime_get(), s_fence->scheduled.timestamp);
return ktime_sub(s_fence->finished.timestamp,