From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: "Cavitt, Jonathan" <jonathan.cavitt@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
"Nerlige Ramappa, Umesh" <umesh.nerlige.ramappa@intel.com>
Subject: Re: [PATCH] drm/xe/oa: Set stream->pollin in xe_oa_buffer_check_unlocked
Date: Wed, 15 Jan 2025 15:46:37 -0800 [thread overview]
Message-ID: <85r053ej36.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <CH0PR11MB5444B7A2FF4192998FD5B0EAE5192@CH0PR11MB5444.namprd11.prod.outlook.com>
On Wed, 15 Jan 2025 14:57:24 -0800, Cavitt, Jonathan wrote:
>
> -----Original Message-----
> From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Ashutosh Dixit
> Sent: Wednesday, January 15, 2025 2:20 PM
> To: intel-xe@lists.freedesktop.org
> Cc: Nerlige Ramappa, Umesh <umesh.nerlige.ramappa@intel.com>
> Subject: [PATCH] drm/xe/oa: Set stream->pollin in xe_oa_buffer_check_unlocked
> >
> > 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>
>
> Minor concern below, but I don't think it's a problem, so I won't block on it.
> Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
>
> > ---
> > drivers/gpu/drm/xe/xe_oa.c | 9 +++------
> > 1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> > index eeb96b5f49e2a..e27c1752aa57c 100644
> > --- a/drivers/gpu/drm/xe/xe_oa.c
> > +++ b/drivers/gpu/drm/xe/xe_oa.c
> > @@ -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;
>
> It looks like we call xe_oa_buffer_check_unlocked in two places.
>
> The first is below, where we call it during xe_oa_poll_check_timer_cb. I see we're
> operating on the stream->pollin value here because we're migrating the
> "stream->polling = true" code from xe_oa_poll_check_timer_cb into the
> xe_oa_buffer_check_unlocked function.
>
> However, the second location is during xe_oa_wait_unlocked. There, we perform
> xe_oa_buffer_check_unlocked in a wait_event_interruptible loop. Is it safe to be
> modifying the stream->pollin value in that case?
>
> I'm sure it's fine, but it's something to consider.
Yes it's fine. Actually it is one of the cases where stream->pollin is not
set (when wait_event_interruptible does *not* block). Because currently we
are setting stream->pollin only when OA data is detected from the timer
callback (when we are blocked and unblocked by the timer). But we should
really be setting stream->pollin in all cases (i.e. also in those cases
where we don't block), which is what this patch is doing.
So one of those cases where stream->pollin is not set is when
wait_event_interruptible does not block. Another potential case is what
Umesh is thinking about and might post.
Thanks,
Ashutosh
> >
> > 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));
> >
> > --
> > 2.47.1
> >
> >
next prev parent reply other threads:[~2025-01-15 23:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 22:20 [PATCH] drm/xe/oa: Set stream->pollin in xe_oa_buffer_check_unlocked Ashutosh Dixit
2025-01-15 22:49 ` ✓ CI.Patch_applied: success for " Patchwork
2025-01-15 22:49 ` ✓ CI.checkpatch: " Patchwork
2025-01-15 22:50 ` ✓ CI.KUnit: " Patchwork
2025-01-15 22:57 ` [PATCH] " Cavitt, Jonathan
2025-01-15 23:46 ` Dixit, Ashutosh [this message]
2025-01-15 23:08 ` ✓ CI.Build: success for " Patchwork
2025-01-15 23:11 ` ✓ CI.Hooks: " Patchwork
2025-01-15 23:12 ` ✓ CI.checksparse: " Patchwork
2025-01-15 23:38 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-01-16 2:18 ` ✗ Xe.CI.Full: " Patchwork
2025-01-17 20:24 ` [PATCH] " Umesh Nerlige Ramappa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85r053ej36.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jonathan.cavitt@intel.com \
--cc=umesh.nerlige.ramappa@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.