Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
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>,
	"Souza, Jose" <jose.souza@intel.com>,
	"Landwerlin, Lionel G" <lionel.g.landwerlin@intel.com>
Subject: Re: [PATCH 1/8] drm/xe/oa: Separate batch submission from waiting for completion
Date: Mon, 19 Aug 2024 18:01:11 -0700	[thread overview]
Message-ID: <87o75odn3c.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <CH0PR11MB5444526CFCAD32B626B615D1E5B92@CH0PR11MB5444.namprd11.prod.outlook.com>

On Thu, 08 Aug 2024 13:18:21 -0700, Cavitt, Jonathan wrote:
>

Hi Jonathan,

> -----Original Message-----
> From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Ashutosh Dixit
> Sent: Thursday, August 8, 2024 10:42 AM
> To: intel-xe@lists.freedesktop.org
> Cc: Nerlige Ramappa, Umesh <umesh.nerlige.ramappa@intel.com>; Souza, Jose <jose.souza@intel.com>; Landwerlin, Lionel G <lionel.g.landwerlin@intel.com>
> Subject: [PATCH 1/8] drm/xe/oa: Separate batch submission from waiting for completion
> >
> > When we introduce xe_syncs, we don't wait for internal OA programming
> > batches to complete. That is, xe_syncs are signaled asynchronously. In
> > anticipation for this, separate out batch submission from waiting for
> > completion of those batches.
> >
> > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
>
> The added goto err in xe_oa_emit_oa_config had me briefly
> worried due to the fence variable not getting freed, but it
> seems the new organization of the series never sets the
> fence variable in the case of an error.

The patch still had a bug. fence should be initialized to NULL for
xe_bb_free() and dma_fence_put() to work if xe_oa_submit_bb() returns
error. Hopefully fixed in v2 where the patch is reworked along lines
suggested by Matt.

> So, LGTM.
> Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>

Thanks.
--
Ashutosh


> -Jonathan Cavitt
> > ---
> >  drivers/gpu/drm/xe/xe_oa.c | 45 ++++++++++++++++++++++++--------------
> >  1 file changed, 28 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> > index 3ef92eb8fbb1e..d842c801fb9f1 100644
> > --- a/drivers/gpu/drm/xe/xe_oa.c
> > +++ b/drivers/gpu/drm/xe/xe_oa.c
> > @@ -563,11 +563,10 @@ static __poll_t xe_oa_poll(struct file *file, poll_table *wait)
> >	return ret;
> >  }
> >
> > -static int xe_oa_submit_bb(struct xe_oa_stream *stream, struct xe_bb *bb)
> > +static int xe_oa_submit_bb(struct xe_oa_stream *stream, struct xe_bb *bb,
> > +			   struct dma_fence **fence)
> >  {
> >	struct xe_sched_job *job;
> > -	struct dma_fence *fence;
> > -	long timeout;
> >	int err = 0;
> >
> >	/* Kernel configuration is issued on stream->k_exec_q, not stream->exec_q */
> > @@ -578,15 +577,8 @@ static int xe_oa_submit_bb(struct xe_oa_stream *stream, struct xe_bb *bb)
> >	}
> >
> >	xe_sched_job_arm(job);
> > -	fence = dma_fence_get(&job->drm.s_fence->finished);
> > +	*fence = dma_fence_get(&job->drm.s_fence->finished);
> >	xe_sched_job_push(job);
> > -
> > -	timeout = dma_fence_wait_timeout(fence, false, HZ);
> > -	dma_fence_put(fence);
> > -	if (timeout < 0)
> > -		err = timeout;
> > -	else if (!timeout)
> > -		err = -ETIME;
> >  exit:
> >	return err;
> >  }
> > @@ -652,6 +644,7 @@ static void xe_oa_store_flex(struct xe_oa_stream *stream, struct xe_lrc *lrc,
> >  static int xe_oa_modify_ctx_image(struct xe_oa_stream *stream, struct xe_lrc *lrc,
> >				  const struct flex *flex, u32 count)
> >  {
> > +	struct dma_fence *fence;
> >	struct xe_bb *bb;
> >	int err;
> >
> > @@ -663,14 +656,16 @@ static int xe_oa_modify_ctx_image(struct xe_oa_stream *stream, struct xe_lrc *lr
> >
> >	xe_oa_store_flex(stream, lrc, bb, flex, count);
> >
> > -	err = xe_oa_submit_bb(stream, bb);
> > -	xe_bb_free(bb, NULL);
> > +	err = xe_oa_submit_bb(stream, bb, &fence);
> > +	xe_bb_free(bb, fence);
> > +	dma_fence_put(fence);
> >  exit:
> >	return err;
> >  }
> >
> >  static int xe_oa_load_with_lri(struct xe_oa_stream *stream, struct xe_oa_reg *reg_lri)
> >  {
> > +	struct dma_fence *fence;
> >	struct xe_bb *bb;
> >	int err;
> >
> > @@ -682,8 +677,9 @@ static int xe_oa_load_with_lri(struct xe_oa_stream *stream, struct xe_oa_reg *re
> >
> >	write_cs_mi_lri(bb, reg_lri, 1);
> >
> > -	err = xe_oa_submit_bb(stream, bb);
> > -	xe_bb_free(bb, NULL);
> > +	err = xe_oa_submit_bb(stream, bb, &fence);
> > +	xe_bb_free(bb, fence);
> > +	dma_fence_put(fence);
> >  exit:
> >	return err;
> >  }
> > @@ -913,15 +909,30 @@ static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config
> >  {
> >  #define NOA_PROGRAM_ADDITIONAL_DELAY_US 500
> >	struct xe_oa_config_bo *oa_bo;
> > -	int err, us = NOA_PROGRAM_ADDITIONAL_DELAY_US;
> > +	int err = 0, us = NOA_PROGRAM_ADDITIONAL_DELAY_US;
> > +	struct dma_fence *fence;
> > +	long timeout;
> >
> > +	/* Emit OA configuration batch */
> >	oa_bo = xe_oa_alloc_config_buffer(stream, config);
> >	if (IS_ERR(oa_bo)) {
> >		err = PTR_ERR(oa_bo);
> >		goto exit;
> >	}
> >
> > -	err = xe_oa_submit_bb(stream, oa_bo->bb);
> > +	err = xe_oa_submit_bb(stream, oa_bo->bb, &fence);
> > +	if (err)
> > +		goto exit;
> > +
> > +	/* Wait till all previous batches have executed */
> > +	timeout = dma_fence_wait_timeout(fence, false, 5 * HZ);
> > +	dma_fence_put(fence);
> > +	if (timeout < 0)
> > +		err = timeout;
> > +	else if (!timeout)
> > +		err = -ETIME;
> > +	if (err)
> > +		drm_dbg(&stream->oa->xe->drm, "dma_fence_wait_timeout err %d\n", err);
> >
> >	/* Additional empirical delay needed for NOA programming after registers are written */
> >	usleep_range(us, 2 * us);
> > --
> > 2.41.0
> >
> >

  reply	other threads:[~2024-08-20  1:11 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08 17:41 [PATCH 0/8] drm/xe/oa: xe_syncs for OA Ashutosh Dixit
2024-08-08 17:41 ` [PATCH 1/8] drm/xe/oa: Separate batch submission from waiting for completion Ashutosh Dixit
2024-08-08 20:18   ` Cavitt, Jonathan
2024-08-20  1:01     ` Dixit, Ashutosh [this message]
2024-08-08 23:04   ` Matthew Brost
2024-08-20  1:00     ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 2/8] drm/xe/oa: Introduce 'struct xe_oa_fence' Ashutosh Dixit
2024-08-08 20:58   ` Cavitt, Jonathan
2024-08-20  1:03     ` Dixit, Ashutosh
2024-08-08 23:29   ` Matthew Brost
2024-08-08 17:41 ` [PATCH 3/8] drm/xe/oa/uapi: Define and parse OA sync properties Ashutosh Dixit
2024-08-08 21:05   ` Cavitt, Jonathan
2024-08-08 23:13   ` Matthew Brost
2024-08-20  1:04     ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 4/8] drm/xe/oa: Add input fence dependencies Ashutosh Dixit
2024-08-08 21:09   ` Cavitt, Jonathan
2024-08-20  1:05     ` Dixit, Ashutosh
2024-08-08 23:25   ` Matthew Brost
2024-08-20  1:06     ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 5/8] drm/xe/oa: Signal output fences Ashutosh Dixit
2024-08-08 21:16   ` Cavitt, Jonathan
2024-08-20  1:30     ` Dixit, Ashutosh
2024-08-08 23:19   ` Matthew Brost
2024-08-09  4:15     ` Dixit, Ashutosh
2024-08-09  4:50       ` Matthew Brost
2024-08-13 21:35         ` Dixit, Ashutosh
2024-08-20  1:30         ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 6/8] drm/xe/oa: Move functions up so they can be reused for config ioctl Ashutosh Dixit
2024-08-08 21:18   ` Cavitt, Jonathan
2024-08-08 17:41 ` [PATCH 7/8] drm/xe/oa: Add syncs support to OA " Ashutosh Dixit
2024-08-08 21:39   ` Cavitt, Jonathan
2024-08-20  1:40     ` Dixit, Ashutosh
2024-08-08 17:41 ` [PATCH 8/8] drm/xe/oa: Allow only certain property changes from " Ashutosh Dixit
2024-08-08 22:15   ` Cavitt, Jonathan
2024-08-20  1:45     ` Dixit, Ashutosh
2024-08-08 19:04 ` ✓ CI.Patch_applied: success for drm/xe/oa: xe_syncs for OA Patchwork
2024-08-08 19:04 ` ✓ CI.checkpatch: " Patchwork
2024-08-08 19:05 ` ✓ CI.KUnit: " Patchwork
2024-08-08 19:17 ` ✓ CI.Build: " Patchwork
2024-08-08 19:19 ` ✓ CI.Hooks: " Patchwork
2024-08-08 19:21 ` ✓ CI.checksparse: " Patchwork
2024-08-08 19:51 ` ✓ CI.BAT: " Patchwork
2024-08-08 22:26 ` ✗ CI.FULL: failure " Patchwork

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=87o75odn3c.wl-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=jose.souza@intel.com \
    --cc=lionel.g.landwerlin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox