From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Stuart Summers <stuart.summers@intel.com>,
Matt Roper <matthew.d.roper@intel.com>,
"Riana Tauro" <riana.tauro@intel.com>,
Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Raag Jadav <raag.jadav@intel.com>
Subject: Re: [PATCH v5 6/7] drm/xe/lrc: Allow to add user commands mid context switch
Date: Wed, 17 Sep 2025 15:53:12 -0400 [thread overview]
Message-ID: <aMsRqP6Jp-n1uOIi@intel.com> (raw)
In-Reply-To: <20250916-wa-bb-cmds-v5-6-306bddbc15da@intel.com>
On Tue, Sep 16, 2025 at 02:15:43PM -0700, Lucas De Marchi wrote:
> Like done for post-context-restore commands, allow to add commands from
> configfs in the middle of context restore. Since currently the indirect
> ctx hardcodes the offset to CTX_INDIRECT_CTX_OFFSET_DEFAULT, this is
> executed in the very beginning of engine context restore.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_configfs.c | 15 +++++++++++++++
> drivers/gpu/drm/xe/xe_configfs.h | 4 ++++
> drivers/gpu/drm/xe/xe_lrc.c | 37 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 56 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
> index 9a30dc958c35c..90bc5a4b5da71 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.c
> +++ b/drivers/gpu/drm/xe/xe_configfs.c
> @@ -897,6 +897,21 @@ bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev)
> return ret;
> }
>
> +/**
> + * xe_configfs_get_ctx_restore_mid_bb - get configfs ctx_restore_mid_bb setting
> + * @pdev: pci device
> + * @class: hw engine class
> + * @cs: pointer to the bb to use - only valid during probe
> + *
> + * Return: Number of dwords used in the mid_ctx_restore setting in configfs
> + */
> +u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev,
> + enum xe_engine_class class,
> + const u32 **cs)
> +{
> + return 0;
> +}
> +
> /**
> * xe_configfs_get_ctx_restore_post_bb - get configfs ctx_restore_post_bb setting
> * @pdev: pci device
> diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
> index eff2645b5f593..c61e0e47ed94c 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.h
> +++ b/drivers/gpu/drm/xe/xe_configfs.h
> @@ -19,6 +19,8 @@ void xe_configfs_check_device(struct pci_dev *pdev);
> bool xe_configfs_get_survivability_mode(struct pci_dev *pdev);
> u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev);
> bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev);
> +u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> + const u32 **cs);
> u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> const u32 **cs);
> #else
> @@ -28,6 +30,8 @@ static inline void xe_configfs_check_device(struct pci_dev *pdev) { }
> static inline bool xe_configfs_get_survivability_mode(struct pci_dev *pdev) { return false; }
> static inline u64 xe_configfs_get_engines_allowed(struct pci_dev *pdev) { return U64_MAX; }
> static inline bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev) { return false; }
> +static inline u32 xe_configfs_get_ctx_restore_mid_bb(struct pci_dev *pdev, enum xe_engine_class,
> + const u32 **cs) { return 0; }
> static inline u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> const u32 **cs) { return 0; }
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> index 0ab99c210d882..47e9df7750725 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.c
> +++ b/drivers/gpu/drm/xe/xe_lrc.c
> @@ -77,11 +77,17 @@ lrc_to_xe(struct xe_lrc *lrc)
> static bool
> gt_engine_needs_indirect_ctx(struct xe_gt *gt, enum xe_engine_class class)
> {
> + struct xe_device *xe = gt_to_xe(gt);
> +
> if (XE_GT_WA(gt, 16010904313) &&
> (class == XE_ENGINE_CLASS_RENDER ||
> class == XE_ENGINE_CLASS_COMPUTE))
> return true;
>
> + if (xe_configfs_get_ctx_restore_mid_bb(to_pci_dev(xe->drm.dev),
> + class, NULL))
> + return true;
> +
> return false;
> }
>
> @@ -1133,6 +1139,35 @@ static ssize_t setup_configfs_post_ctx_restore_bb(struct xe_lrc *lrc,
> return cmd - batch;
> }
>
> +static ssize_t setup_configfs_mid_ctx_restore_bb(struct xe_lrc *lrc,
> + struct xe_hw_engine *hwe,
> + u32 *batch, size_t max_len)
> +{
> + struct xe_device *xe = gt_to_xe(lrc->gt);
> + const u32 *user_batch;
> + u32 *cmd = batch;
> + u32 count;
> +
> + count = xe_configfs_get_ctx_restore_mid_bb(to_pci_dev(xe->drm.dev),
> + hwe->class, &user_batch);
> + if (!count)
> + return 0;
> +
> + if (count > max_len)
> + return -ENOSPC;
> +
> + /*
> + * This should be used only for tests and validation. Taint the kernel
> + * as anything could be submitted directly in context switches
> + */
> + add_taint(TAINT_TEST, LOCKDEP_STILL_OK);
> +
> + memcpy(cmd, user_batch, count * sizeof(u32));
> + cmd += count;
> +
> + return cmd - batch;
> +}
> +
> static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc,
> struct xe_hw_engine *hwe,
> u32 *batch, size_t max_len)
> @@ -1283,8 +1318,10 @@ setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
> {
> static const struct bo_setup rcs_funcs[] = {
> { .setup = setup_timestamp_wa },
> + { .setup = setup_configfs_mid_ctx_restore_bb },
> };
> static const struct bo_setup xcs_funcs[] = {
> + { .setup = setup_configfs_mid_ctx_restore_bb },
> };
> struct bo_setup_state state = {
> .lrc = lrc,
>
> --
> 2.50.1
>
next prev parent reply other threads:[~2025-09-17 19:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 21:15 [PATCH v5 0/7] drm/xe: Add user commands to WA BB via configfs Lucas De Marchi
2025-09-16 21:15 ` [PATCH v5 1/7] drm/xe/configfs: Extract function to parse engine Lucas De Marchi
2025-09-16 21:15 ` [PATCH v5 2/7] drm/xe/configfs: Allow to select by class only Lucas De Marchi
2025-09-16 21:15 ` [PATCH v5 3/7] drm/xe/lrc: Allow to add user commands on context switch Lucas De Marchi
2025-09-17 16:32 ` Rodrigo Vivi
2025-09-16 21:15 ` [PATCH v5 4/7] drm/xe/configfs: Add post context restore bb Lucas De Marchi
2025-09-24 20:31 ` Kees Bakker
2025-09-24 21:34 ` Lucas De Marchi
2025-09-16 21:15 ` [PATCH v5 5/7] drm/xe/lrc: Allow INDIRECT_CTX for more engine classes Lucas De Marchi
2025-09-17 19:52 ` Rodrigo Vivi
2025-09-16 21:15 ` [PATCH v5 6/7] drm/xe/lrc: Allow to add user commands mid context switch Lucas De Marchi
2025-09-17 19:53 ` Rodrigo Vivi [this message]
2025-09-16 21:15 ` [PATCH v5 7/7] drm/xe/configfs: Add mid context restore bb Lucas De Marchi
2025-09-17 19:53 ` Rodrigo Vivi
2025-09-16 21:21 ` ✗ CI.checkpatch: warning for drm/xe: Add user commands to WA BB via configfs Patchwork
2025-09-16 21:23 ` ✓ CI.KUnit: success " Patchwork
2025-09-16 21:58 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-17 1:22 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-17 6:44 ` [PATCH v5 0/7] " Raag Jadav
2025-09-18 21:47 ` Lucas De Marchi
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=aMsRqP6Jp-n1uOIi@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=stuart.summers@intel.com \
--cc=tursulin@ursulin.net \
--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