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 v4 5/6] drm/xe/lrc: Allow to add user commands on context switch
Date: Tue, 16 Sep 2025 16:27:45 -0400 [thread overview]
Message-ID: <aMnIQQWdJvWEA0pK@intel.com> (raw)
In-Reply-To: <20250911-wa-bb-cmds-v4-5-c8f7e48f7eae@intel.com>
On Thu, Sep 11, 2025 at 12:36:29PM -0700, Lucas De Marchi wrote:
> During validation it's useful to allows additional commands to be
> executed on context switch. Fetch the commands from configfs (to be
> added) and add them to the WA BB.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> v2: Fix warning when building without configfs
> ---
> drivers/gpu/drm/xe/xe_configfs.c | 13 +++++++++++++
> drivers/gpu/drm/xe/xe_configfs.h | 6 ++++++
> drivers/gpu/drm/xe/xe_lrc.c | 25 +++++++++++++++++++++++++
> 3 files changed, 44 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
> index 45fdb6cf26b5d..d86c75af03278 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.c
> +++ b/drivers/gpu/drm/xe/xe_configfs.c
> @@ -633,6 +633,19 @@ bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev)
> return ret;
> }
>
> +/**
> + * xe_configfs_get_ctx_restore_post_bb - get configfs ctx_restore_post_bb setting
> + * @pdev: pci device
> + *
> + * Return: post_ctx_restore setting in configfs
> + */
> +u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
> + enum xe_engine_class class,
> + const u32 **cs)
> +{
> + return 0;
> +}
> +
> int __init xe_configfs_init(void)
> {
> int ret;
> diff --git a/drivers/gpu/drm/xe/xe_configfs.h b/drivers/gpu/drm/xe/xe_configfs.h
> index 1402e863b71c0..eff2645b5f593 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.h
> +++ b/drivers/gpu/drm/xe/xe_configfs.h
> @@ -8,6 +8,8 @@
> #include <linux/limits.h>
> #include <linux/types.h>
>
> +#include <xe_hw_engine_types.h>
> +
> struct pci_dev;
>
> #if IS_ENABLED(CONFIG_CONFIGFS_FS)
> @@ -17,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_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> + const u32 **cs);
> #else
> static inline int xe_configfs_init(void) { return 0; }
> static inline void xe_configfs_exit(void) { }
> @@ -24,6 +28,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_post_bb(struct pci_dev *pdev, enum xe_engine_class,
> + const u32 **cs) { return 0; }
> #endif
>
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> index 6d52e0eb97f54..f337954066f55 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.c
> +++ b/drivers/gpu/drm/xe/xe_lrc.c
> @@ -16,6 +16,7 @@
> #include "regs/xe_lrc_layout.h"
> #include "xe_bb.h"
> #include "xe_bo.h"
> +#include "xe_configfs.h"
> #include "xe_device.h"
> #include "xe_drm_client.h"
> #include "xe_exec_queue_types.h"
> @@ -1102,6 +1103,29 @@ static ssize_t setup_timestamp_wa(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
> return cmd - batch;
> }
>
> +static ssize_t setup_configfs_post_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_post_bb(to_pci_dev(xe->drm.dev),
> + hwe->class, &user_batch);
> + if (!count)
> + return 0;
> +
> + if (count > max_len)
> + return -ENOSPC;
> +
> + memcpy(cmd, user_batch, count * sizeof(u32));
shouldn't we use copy_from_user here?
> + 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)
> @@ -1203,6 +1227,7 @@ int xe_lrc_setup_wa_bb_with_scratch(struct xe_lrc *lrc, struct xe_hw_engine *hwe
> { .setup = setup_timestamp_wa },
> { .setup = setup_invalidate_state_cache_wa },
> { .setup = setup_utilization_wa },
> + { .setup = setup_configfs_post_ctx_restore_bb },
> };
> struct bo_setup_state state = {
> .lrc = lrc,
>
> --
> 2.50.1
>
next prev parent reply other threads:[~2025-09-16 20:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 19:36 [PATCH v4 0/6] drm/xe: Add user commands to WA BB via configfs Lucas De Marchi
2025-09-11 19:36 ` [PATCH v4 1/6] drm/xe: Update workaround documentation Lucas De Marchi
2025-09-11 19:36 ` [PATCH v4 2/6] drm/xe/configfs: Fix documentation warning Lucas De Marchi
2025-09-11 19:36 ` [PATCH v4 3/6] drm/xe/configfs: Extract function to parse engine Lucas De Marchi
2025-09-11 19:36 ` [PATCH v4 4/6] drm/xe/configfs: Allow to select by class only Lucas De Marchi
2025-09-12 5:18 ` Raag Jadav
2025-09-12 5:30 ` Lucas De Marchi
2025-09-12 5:58 ` Raag Jadav
2025-09-11 19:36 ` [PATCH v4 5/6] drm/xe/lrc: Allow to add user commands on context switch Lucas De Marchi
2025-09-16 20:27 ` Rodrigo Vivi [this message]
2025-09-16 21:07 ` Lucas De Marchi
2025-09-16 21:16 ` Rodrigo Vivi
2025-09-16 21:19 ` Lucas De Marchi
2025-09-11 19:36 ` [PATCH v4 6/6] drm/xe/configfs: Add post context restore bb Lucas De Marchi
2025-09-12 8:05 ` Raag Jadav
2025-09-12 14:07 ` Lucas De Marchi
2025-09-12 16:56 ` Raag Jadav
2025-09-11 20:19 ` ✗ CI.checkpatch: warning for drm/xe: Add user commands to WA BB via configfs Patchwork
2025-09-11 20:20 ` ✓ CI.KUnit: success " Patchwork
2025-09-11 21:06 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-12 3:16 ` ✗ 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=aMnIQQWdJvWEA0pK@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