From: Lucas De Marchi <lucas.demarchi@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
Stuart Summers <stuart.summers@intel.com>,
Matt Roper <matthew.d.roper@intel.com>,
Riana Tauro <riana.tauro@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>
Subject: [PATCH 2/5] drm/xe/lrc: Extract post context restore function
Date: Fri, 23 May 2025 11:54:36 -0700 [thread overview]
Message-ID: <20250523-wa-bb-cmds-v1-2-40b337f71bcd@intel.com> (raw)
In-Reply-To: <20250523-wa-bb-cmds-v1-0-40b337f71bcd@intel.com>
The post context restore is a mechanism in HW that may be used for
things other than the utilization setup. Create a new function called
setup_post_context_restore_bb() that wraps any function writing useful
commands in the buffer.
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
drivers/gpu/drm/xe/xe_lrc.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
index 61a2e87990a9d..4562049a23fb1 100644
--- a/drivers/gpu/drm/xe/xe_lrc.c
+++ b/drivers/gpu/drm/xe/xe_lrc.c
@@ -917,9 +917,10 @@ static void xe_lrc_finish(struct xe_lrc *lrc)
}
/*
- * xe_lrc_setup_utilization() - Setup wa bb to assist in calculating active
- * context run ticks.
+ * wa_bb_write_utilization_state() - Write commands to wa bb to assist
+ * in calculating active context run ticks.
* @lrc: Pointer to the lrc.
+ * @cmd0: Pointer to the batch buffer location.
*
* Context Timestamp (CTX_TIMESTAMP) in the LRC accumulates the run ticks of the
* context, but only gets updated when the context switches out. In order to
@@ -944,11 +945,9 @@ static void xe_lrc_finish(struct xe_lrc *lrc)
* store it in the PPHSWP.
*/
#define CONTEXT_ACTIVE 1ULL
-static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
+static size_t wa_bb_write_utilization_state(struct xe_lrc *lrc, u32 *cmd0)
{
- u32 *cmd;
-
- cmd = lrc->bb_per_ctx_bo->vmap.vaddr;
+ u32 *cmd = cmd0;
*cmd++ = MI_STORE_REGISTER_MEM | MI_SRM_USE_GGTT | MI_SRM_ADD_CS_OFFSET;
*cmd++ = ENGINE_ID(0).addr;
@@ -967,11 +966,21 @@ static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
*cmd++ = upper_32_bits(CONTEXT_ACTIVE);
}
+ return cmd - cmd0;
+}
+
+static void setup_wa_bb(struct xe_lrc *lrc)
+{
+ u32 *cmd, *cmd0;
+
+ cmd0 = lrc->bb_per_ctx_bo->vmap.vaddr;
+ cmd = cmd0;
+
+ cmd += wa_bb_write_utilization_state(lrc, cmd);
*cmd++ = MI_BATCH_BUFFER_END;
xe_lrc_write_ctx_reg(lrc, CTX_BB_PER_CTX_PTR,
xe_bo_ggtt_addr(lrc->bb_per_ctx_bo) | 1);
-
}
#define PVC_CTX_ASID (0x2e + 1)
@@ -1128,7 +1137,7 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
map = __xe_lrc_start_seqno_map(lrc);
xe_map_write32(lrc_to_xe(lrc), &map, lrc->fence_ctx.next_seqno - 1);
- xe_lrc_setup_utilization(lrc);
+ setup_wa_bb(lrc);
return 0;
--
2.49.0
next prev parent reply other threads:[~2025-05-23 18:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 18:54 [PATCH 0/5] drm/xe: Add user commands to WA BB via configfs Lucas De Marchi
2025-05-23 18:54 ` [PATCH 1/5] FOR-CI: Add-configfs-to-load-with-fewer-engines Lucas De Marchi
2025-05-23 18:54 ` Lucas De Marchi [this message]
2025-05-23 19:32 ` [PATCH 2/5] drm/xe/lrc: Extract post context restore function Umesh Nerlige Ramappa
2025-05-25 3:30 ` Lucas De Marchi
2025-05-23 18:54 ` [PATCH 3/5] drm/xe/lrc: Sanity check bb space Lucas De Marchi
2025-05-23 18:54 ` [PATCH 4/5] drm/xe/lrc: Allow to add user commands on context switch Lucas De Marchi
2025-05-23 18:54 ` [PATCH 5/5] drm/xe/configfs: Add interface to wa_bb commands Lucas De Marchi
2025-05-23 19:00 ` ✓ CI.Patch_applied: success for drm/xe: Add user commands to WA BB via configfs Patchwork
2025-05-23 19:00 ` ✓ CI.checkpatch: " Patchwork
2025-05-23 19:02 ` ✓ CI.KUnit: " Patchwork
2025-05-23 19:12 ` ✓ CI.Build: " Patchwork
2025-05-23 19:15 ` ✓ CI.Hooks: " Patchwork
2025-05-23 19:16 ` ✓ CI.checksparse: " Patchwork
2025-05-23 19:41 ` ✓ Xe.CI.BAT: " Patchwork
2025-05-24 12:40 ` ✗ 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=20250523-wa-bb-cmds-v1-2-40b337f71bcd@intel.com \
--to=lucas.demarchi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.d.roper@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@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