drm/xe/oa: Set stream->pollin in xe_oa_buffer_check_unlocked
authorAshutosh Dixit <ashutosh.dixit@intel.com>
Wed, 15 Jan 2025 22:20:29 +0000 (14:20 -0800)
committerAshutosh Dixit <ashutosh.dixit@intel.com>
Fri, 24 Jan 2025 02:07:03 +0000 (18:07 -0800)
We rely on stream->pollin to decide whether or not to block during
poll/read calls. However, currently there are blocking read code paths
which don't even set stream->pollin. The best place to consistently set
stream->pollin for all code paths is therefore to set it in
xe_oa_buffer_check_unlocked.

Fixes: e936f885f1e9 ("drm/xe/oa/uapi: Expose OA stream fd")
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250115222029.3002103-1-ashutosh.dixit@intel.com
drivers/gpu/drm/xe/xe_oa.c

index 6a08e6c92835f14269763f919f22cab5ef4d005b..fa873f3d0a9d10ea9b22f065f9eaa64b34cd9817 100644 (file)
@@ -237,7 +237,6 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
        u32 tail, hw_tail, partial_report_size, available;
        int report_size = stream->oa_buffer.format->size;
        unsigned long flags;
-       bool pollin;
 
        spin_lock_irqsave(&stream->oa_buffer.ptr_lock, flags);
 
@@ -282,11 +281,11 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
        stream->oa_buffer.tail = tail;
 
        available = xe_oa_circ_diff(stream, stream->oa_buffer.tail, stream->oa_buffer.head);
-       pollin = available >= stream->wait_num_reports * report_size;
+       stream->pollin = available >= stream->wait_num_reports * report_size;
 
        spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags);
 
-       return pollin;
+       return stream->pollin;
 }
 
 static enum hrtimer_restart xe_oa_poll_check_timer_cb(struct hrtimer *hrtimer)
@@ -294,10 +293,8 @@ static enum hrtimer_restart xe_oa_poll_check_timer_cb(struct hrtimer *hrtimer)
        struct xe_oa_stream *stream =
                container_of(hrtimer, typeof(*stream), poll_check_timer);
 
-       if (xe_oa_buffer_check_unlocked(stream)) {
-               stream->pollin = true;
+       if (xe_oa_buffer_check_unlocked(stream))
                wake_up(&stream->poll_wq);
-       }
 
        hrtimer_forward_now(hrtimer, ns_to_ktime(stream->poll_period_ns));