From d16e137e7f4b3ccb2b66081b9bc40bc0cbe5aef8 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 30 Mar 2020 12:14:11 +0300 Subject: [PATCH] drm/i915/perf: don't read head/tail pointers outside critical section Reading or writing those fields should only happen under stream->oa_buffer.ptr_lock. Signed-off-by: Lionel Landwerlin Fixes: d1df41eb72ef ("drm/i915/perf: rework aging tail workaround") Reviewed-by: Chris Wilson Acked-by: Ashutosh Dixit Link: https://patchwork.freedesktop.org/patch/msgid/20200330091411.37357-1-lionel.g.landwerlin@intel.com --- drivers/gpu/drm/i915/i915_perf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index dc0365d..28e3d76 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -463,6 +463,7 @@ static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream) u32 gtt_offset = i915_ggtt_offset(stream->oa_buffer.vma); int report_size = stream->oa_buffer.format_size; unsigned long flags; + bool pollin; u32 hw_tail; u64 now; @@ -532,10 +533,12 @@ static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream) stream->oa_buffer.aging_timestamp = now; } + pollin = OA_TAKEN(stream->oa_buffer.tail - gtt_offset, + stream->oa_buffer.head - gtt_offset) >= report_size; + spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags); - return OA_TAKEN(stream->oa_buffer.tail - gtt_offset, - stream->oa_buffer.head - gtt_offset) >= report_size; + return pollin; } /** -- 2.7.4