Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
	Jose Souza <jose.souza@intel.com>,
	"Lionel Landwerlin" <lionel.g.landwerlin@intel.com>
Subject: Re: [PATCH 2/8] drm/xe/oa: Introduce 'struct xe_oa_fence'
Date: Thu, 8 Aug 2024 23:29:37 +0000	[thread overview]
Message-ID: <ZrVU4ZSaicZU1UNC@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240808174139.4027534-3-ashutosh.dixit@intel.com>

On Thu, Aug 08, 2024 at 10:41:33AM -0700, Ashutosh Dixit wrote:
> Here we introduce 'struct xe_oa_fence' which will contain the fence used
> for signalling xe_syncs (in a later patch). The struct also contains the
> work struct used for signalling the fences. Otherwise, this patch is a
> simple refactor of the previous patch. In this patch the work function is
> executed synchronously.
> 
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_oa.c | 73 ++++++++++++++++++++++++++++++--------
>  1 file changed, 59 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> index d842c801fb9f1..f97d64ffb460f 100644
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
> @@ -90,6 +90,15 @@ struct xe_oa_config_bo {
>  	struct xe_bb *bb;
>  };
>  
> +struct xe_oa_fence {

See my comment here [1], quite sure this is not needed.

Matt

[1] https://patchwork.freedesktop.org/patch/607602/?series=137058&rev=1#comment_1104294

> +	/* @xe: pointer to xe device */
> +	struct xe_device *xe;
> +	/* @work: work to signal that OA configuration is applied */
> +	struct work_struct work;
> +	/* @config_fence: dma fence for OA config to be applied */
> +	struct dma_fence *config_fence;
> +};
> +
>  #define DRM_FMT(x) DRM_XE_OA_FMT_TYPE_##x
>  
>  static const struct xe_oa_format oa_formats[] = {
> @@ -905,14 +914,51 @@ xe_oa_alloc_config_buffer(struct xe_oa_stream *stream, struct xe_oa_config *oa_c
>  	return oa_bo;
>  }
>  
> -static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config *config)
> +static void xe_oa_fence_work_fn(struct work_struct *w)
>  {
>  #define NOA_PROGRAM_ADDITIONAL_DELAY_US 500
> -	struct xe_oa_config_bo *oa_bo;
> +	struct xe_oa_fence *ofence = container_of(w, typeof(*ofence), work);
>  	int err = 0, us = NOA_PROGRAM_ADDITIONAL_DELAY_US;
> -	struct dma_fence *fence;
>  	long timeout;
>  
> +	/* Wait till all previous batches have executed */
> +	timeout = dma_fence_wait_timeout(ofence->config_fence, false, 5 * HZ);
> +	dma_fence_put(ofence->config_fence);
> +	if (timeout < 0)
> +		err = timeout;
> +	else if (!timeout)
> +		err = -ETIME;
> +	if (err)
> +		drm_dbg(&ofence->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);
> +
> +	kfree(ofence);
> +}
> +
> +static struct xe_oa_fence *xe_oa_fence_init(struct xe_device *xe, struct dma_fence *config_fence)
> +{
> +	struct xe_oa_fence *ofence;
> +
> +	ofence = kzalloc(sizeof(*ofence), GFP_KERNEL);
> +	if (!ofence)
> +		return ERR_PTR(-ENOMEM);
> +
> +	ofence->xe = xe;
> +	INIT_WORK(&ofence->work, xe_oa_fence_work_fn);
> +	ofence->config_fence = config_fence;
> +
> +	return ofence;
> +}
> +
> +static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config *config)
> +{
> +	struct xe_oa_config_bo *oa_bo;
> +	struct xe_oa_fence *ofence;
> +	struct dma_fence *fence;
> +	int err;
> +
>  	/* Emit OA configuration batch */
>  	oa_bo = xe_oa_alloc_config_buffer(stream, config);
>  	if (IS_ERR(oa_bo)) {
> @@ -924,18 +970,17 @@ static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config
>  	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);
> +	ofence = xe_oa_fence_init(stream->oa->xe, fence);
> +	if (IS_ERR(ofence)) {
> +		err = PTR_ERR(ofence);
> +		goto put_fence;
> +	}
>  
> -	/* Additional empirical delay needed for NOA programming after registers are written */
> -	usleep_range(us, 2 * us);
> +	xe_oa_fence_work_fn(&ofence->work);
> +
> +	return 0;
> +put_fence:
> +	dma_fence_put(fence);
>  exit:
>  	return err;
>  }
> -- 
> 2.41.0
> 

  parent reply	other threads:[~2024-08-08 23:31 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
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 [this message]
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=ZrVU4ZSaicZU1UNC@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --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