Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: Matthew Brost <matthew.brost@intel.com>,
	Tomasz Lis <tomasz.lis@intel.com>
Subject: Re: [PATCH v6 3/3] drm/xe/vf: Add debugfs entries to test VF double migration
Date: Thu, 27 Nov 2025 17:51:56 +0100	[thread overview]
Message-ID: <003f49d3-fd57-47e4-bea0-3a3ef61a0933@intel.com> (raw)
In-Reply-To: <20251124160719.29812-8-satyanarayana.k.v.p@intel.com>



On 11/24/2025 5:07 PM, Satyanarayana K V P wrote:
> VF migration sends a marker to the GUC before resource fixups begin,
> and repeats the marker with the RESFIX_DONE notification. This prevents
> the GUC from submitting jobs during double migration events.
> 
> To reliably test double migration, a second migration must be triggered
> while fixups from the first migration are still in progress. Since fixups
> complete quickly, reproducing this scenario is difficult. Introduce
> debugfs controls to add delays in the post-fixup phase, creating a
> deterministic window for subsequent migrations.
> 
> New debugfs entries:
> 	/sys/kernel/debug/dri/<card>/
> 	├── gt0

nit: use of top level gt0 is deprecated (this is a link added for backward comp)
maybe show real path:

	├── tile0
	│   ├── gt0
   

> 	│   ├── vf
> 	│   │   ├── resfix_stoppers
> 
> - resfix_stoppers: Predefined checkpoints that allow the migration process

drop -

> to pause at specific stages. The stages are given below.
> 
> VF_MIGRATION_WAIT_BEFORE_RESFIX_START	- BIT(0)
> VF_MIGRATION_WAIT_BEFORE_FIXUPS		- BIT(1)
> VF_MIGRATION_WAIT_BEFORE_RESTART_JOBS	- BIT(2)
> VF_MIGRATION_WAIT_BEFORE_RESFIX_DONE	- BIT(3)
> 
> Each state will pause with a 1-second delay per iteration, continuing until
> its corresponding bit is cleared.
> 
> Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Tomasz Lis <tomasz.lis@intel.com>
> 
> ---
> V5 -> V6:
> - Fixed review comments (Michal W).
> - Removed timeout and VF KMD waits infinately when resfix_stoppers bits are
> set.
> - Created helper macro for WAIT positions.
> 
> V4 -> V5:
> - Updated debugfs entries (Michal W).
> 
> V3 -> V4:
> - New commit
> 
> V2 -> V3:
> - None.
> 
> V1 -> V2:
> - None.
> ---
>  drivers/gpu/drm/xe/xe_gt_sriov_vf.c         | 38 +++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_gt_sriov_vf_debugfs.c |  5 +++
>  drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h   |  8 +++++
>  3 files changed, 51 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> index 8e3fba6521f0..aabc3064c3ef 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> @@ -5,6 +5,7 @@
>  
>  #include <linux/bitfield.h>
>  #include <linux/bsearch.h>
> +#include <linux/delay.h>
>  
>  #include <drm/drm_managed.h>
>  #include <drm/drm_print.h>
> @@ -1228,6 +1229,35 @@ static int vf_post_migration_resfix_done(struct xe_gt *gt, u16 marker)
>  	return vf_resfix_done(gt, marker);
>  }
>  
> +#define VF_MIGRATION_WAIT_NO_WAIT			0

do we need this?

> +#define VF_MIGRATION_WAIT_BEFORE_RESFIX_START		BIT(0)
> +#define VF_MIGRATION_WAIT_BEFORE_FIXUPS			BIT(1)
> +#define VF_MIGRATION_WAIT_BEFORE_RESTART_JOBS		BIT(2)
> +#define VF_MIGRATION_WAIT_BEFORE_RESFIX_DONE		BIT(3)

nit: maybe define them as enum? and "BEFORE" tag seems little redundant

enum VF_MIGRATION_WAIT_POINTS {
	VF_MIGRATION_WAIT_RESFIX_START = BIT(0),
	...



> +
> +#define VF_MIGRATION_WAIT_DELAY_IN_MS			1000

move it under below #ifdef 

> +
> +#define VF_MIGRATION_INJECT_WAIT(gt, _POS) ({	\
> +	struct xe_gt *__gt = (gt);		\
> +	vf_post_migration_inject_wait(__gt, VF_MIGRATION_WAIT_##_POS); \
> +	})

nit: please make sure to align to the same column trailing \

> +
> +#ifdef CONFIG_DRM_XE_DEBUG
> +static void vf_post_migration_inject_wait(struct xe_gt *gt, int wait)

s/int/enum

> +{
> +	uint delay_ms = VF_MIGRATION_WAIT_DELAY_IN_MS;

do we need this ?

> +
> +	while (gt->sriov.vf.migration.debug.resfix_stoppers &  wait) {

double space before 'wait'

> +		xe_gt_dbg(gt, "*TESTING* injecting delay due to resfix_stoppers = 0x%x\n",

from this message we might still don't know where we wait if multiple bits are set
maybe just print the 'wait' bit, or all info:

	"*TESTING* injecting %u ms delay due to resfix_stoppers=%#x, to continue clear %#x\n",
	VF_MIGRATION_WAIT_DELAY_IN_MS, gt->sriov.vf.migration.debug.resfix_stoppers, wait


> +			  gt->sriov.vf.migration.debug.resfix_stoppers);
> +
> +		msleep(delay_ms);
> +	}
> +}
> +#else
> +static void vf_post_migration_inject_wait(struct xe_gt *gt, int wait) { }

nit: maybe instead defining empty stub function, just define stub for macro ?

> +#endif
> +
>  /*
>   * Reset the marker to 1 after it overflows since GuC requires a non-zero
>   * marker to be set.
> @@ -1266,18 +1296,26 @@ static void vf_post_migration_recovery(struct xe_gt *gt)
>  		goto fail;
>  	}
>  
> +	VF_MIGRATION_INJECT_WAIT(gt, BEFORE_RESFIX_START);

do we want to have all these wait points defined here in vf_post_migration_recovery()
or maybe we should add those macros inside relevant functions?

	vf_post_migration_resfix_start_marker(gt)
	{
		VF_MIGRATION_INJECT_WAIT(gt, RESFIX_START);
		...
	}


> +
>  	marker = vf_post_migration_resfix_start_marker(gt);
>  
>  	err = vf_resfix_start(gt, marker);
>  	if (err)
>  		goto fail;
>  
> +	VF_MIGRATION_INJECT_WAIT(gt, BEFORE_FIXUPS);
> +
>  	err = vf_post_migration_fixups(gt);
>  	if (err)
>  		goto fail;
>  
> +	VF_MIGRATION_INJECT_WAIT(gt, BEFORE_RESTART_JOBS);
> +
>  	vf_post_migration_rearm(gt);
>  
> +	VF_MIGRATION_INJECT_WAIT(gt, BEFORE_RESFIX_DONE);
> +
>  	err = vf_post_migration_resfix_done(gt, marker);
>  	if (err == -EREMCHG)
>  		goto queue;
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf_debugfs.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf_debugfs.c
> index 2ed5b6780d30..66d5ffd0e371 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf_debugfs.c
> @@ -69,4 +69,9 @@ void xe_gt_sriov_vf_debugfs_register(struct xe_gt *gt, struct dentry *root)
>  	vfdentry->d_inode->i_private = gt;
>  
>  	drm_debugfs_create_files(vf_info, ARRAY_SIZE(vf_info), vfdentry, minor);
> +
> +	if (IS_ENABLED(CONFIG_DRM_XE_DEBUG)) {

add here small info about location of this new entry (like it's done for other files)

/*
 *      /sys/kernel/debug/dri/BDF/
 *      ├── tile0
 *          ├── gt0
 *              ├── vf
 *                  ├── resfix_stoppers
 */

> +		debugfs_create_x8("resfix_stoppers", 0600, vfdentry,
> +				  &gt->sriov.vf.migration.debug.resfix_stoppers);
> +	}
>  }
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h
> index 66c0062a42c6..3ece00f74e46 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf_types.h
> @@ -52,6 +52,14 @@ struct xe_gt_sriov_vf_migration {
>  	wait_queue_head_t wq;
>  	/** @scratch: Scratch memory for VF recovery */
>  	void *scratch;
> +	/** @debug: Debug hooks for delaying migration */
> +	struct {
> +		/**
> +		 * @debug.resfix_stoppers: Stop and wait at different stages
> +		 * during post migration recovery
> +		 */
> +		u8 resfix_stoppers;
> +	} debug;
>  	/**
>  	 * @resfix_marker: Marker sent on start and on end of post-migration
>  	 * steps.


  reply	other threads:[~2025-11-27 16:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24 16:07 [PATCH v6 0/3] VF double migration Satyanarayana K V P
2025-11-24 16:07 ` [PATCH v6 1/3] drm/xe/vf: Enable VF migration only on supported GuC versions Satyanarayana K V P
2025-11-27 14:45   ` Michal Wajdeczko
2025-11-24 16:07 ` [PATCH v6 2/3] drm/xe/vf: Introduce RESFIX start marker support Satyanarayana K V P
2025-11-27 16:17   ` Michal Wajdeczko
2025-11-24 16:07 ` [PATCH v6 3/3] drm/xe/vf: Add debugfs entries to test VF double migration Satyanarayana K V P
2025-11-27 16:51   ` Michal Wajdeczko [this message]
2025-11-25  3:30 ` ✓ CI.KUnit: success for VF double migration (rev6) Patchwork
2025-11-25  4:08 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-25  6:55 ` ✗ Xe.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=003f49d3-fd57-47e4-bea0-3a3ef61a0933@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=satyanarayana.k.v.p@intel.com \
    --cc=tomasz.lis@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