From: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
To: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <matthew.brost@intel.com>,
<stuart.summers@intel.com>
Subject: Re: [PATCH v3 03/11] drm/xe/lrc: Refactor xe_lrc_timestamp to simplify logic
Date: Tue, 5 May 2026 20:13:41 -0700 [thread overview]
Message-ID: <afqx5UtkmPbR0HPU@nvishwa1-desk> (raw)
In-Reply-To: <20260505234408.3552147-16-umesh.nerlige.ramappa@intel.com>
On Tue, May 05, 2026 at 04:44:12PM -0700, Umesh Nerlige Ramappa wrote:
>Use a context_active() helper and simplify the timestamp logic.
>
>Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>---
> drivers/gpu/drm/xe/xe_lrc.c | 35 +++++++++++++----------------------
> 1 file changed, 13 insertions(+), 22 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
>index 66682a678cc2..3b6990d68a5a 100644
>--- a/drivers/gpu/drm/xe/xe_lrc.c
>+++ b/drivers/gpu/drm/xe/xe_lrc.c
>@@ -2585,6 +2585,11 @@ static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts)
> return 0;
> }
>
>+static bool context_active(struct xe_lrc *lrc)
>+{
>+ return xe_lrc_ctx_timestamp(lrc) == CONTEXT_ACTIVE;
>+}
>+
> /**
> * xe_lrc_timestamp() - Current ctx timestamp
> * @lrc: Pointer to the lrc.
>@@ -2597,33 +2602,19 @@ static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts)
> */
> u64 xe_lrc_timestamp(struct xe_lrc *lrc)
> {
>- u64 lrc_ts, reg_ts, new_ts = lrc->ctx_timestamp;
>- u32 engine_id;
>+ u64 reg_ts, new_ts = lrc->ctx_timestamp;
>
>- lrc_ts = xe_lrc_ctx_timestamp(lrc);
> /* CTX_TIMESTAMP mmio read is invalid on VF, so return the LRC value */
>- if (IS_SRIOV_VF(lrc_to_xe(lrc))) {
>- new_ts = lrc_ts;
>- goto done;
>- }
>+ if (IS_SRIOV_VF(lrc_to_xe(lrc)))
>+ return xe_lrc_ctx_timestamp(lrc);
>
>- if (lrc_ts == CONTEXT_ACTIVE) {
>- engine_id = xe_lrc_engine_id(lrc);
>- if (!get_ctx_timestamp(lrc, engine_id, ®_ts))
>- new_ts = reg_ts;
>+ if (context_active(lrc) &&
>+ !get_ctx_timestamp(lrc, xe_lrc_engine_id(lrc), ®_ts))
>+ new_ts = reg_ts;
>
>- /* read lrc again to ensure context is still active */
>- lrc_ts = xe_lrc_ctx_timestamp(lrc);
>- }
>-
>- /*
>- * If context switched out, just use the lrc_ts. Note that this needs to
>- * be a separate if condition.
>- */
>- if (lrc_ts != CONTEXT_ACTIVE)
>- new_ts = lrc_ts;
>+ if (!context_active(lrc))
>+ return xe_lrc_ctx_timestamp(lrc);
NIT....may be it is good to keep a comment here like the one removed above?
Either way, lgtm.
Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
>
>-done:
> return new_ts;
> }
>
>--
>2.51.0
>
next prev parent reply other threads:[~2026-05-06 3:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 23:44 [PATCH v3 00/11] Support run ticks for multi-queue use case Umesh Nerlige Ramappa
2026-05-05 23:44 ` [PATCH v3 01/11] drm/xe/lrc: Use 64 bit ctx timestamp in the LRC snapshot Umesh Nerlige Ramappa
2026-05-05 23:44 ` [PATCH v3 02/11] drm/xe: Add timestamp_ms to " Umesh Nerlige Ramappa
2026-05-06 3:10 ` Niranjana Vishwanathapura
2026-05-05 23:44 ` [PATCH v3 03/11] drm/xe/lrc: Refactor xe_lrc_timestamp to simplify logic Umesh Nerlige Ramappa
2026-05-06 3:13 ` Niranjana Vishwanathapura [this message]
2026-05-05 23:44 ` [PATCH v3 04/11] drm/xe/multi_queue: Refactor check for multi queue support for engine class Umesh Nerlige Ramappa
2026-05-06 3:16 ` Niranjana Vishwanathapura
2026-05-05 23:44 ` [PATCH v3 05/11] drm/xe/multi_queue: Store primary LRC and position info in LRC Umesh Nerlige Ramappa
2026-05-06 3:47 ` Niranjana Vishwanathapura
2026-05-05 23:44 ` [PATCH v3 06/11] drm/xe/multi_queue: Add helpers to access CS QUEUE TIMESTAMP from lrc Umesh Nerlige Ramappa
2026-05-06 3:25 ` Niranjana Vishwanathapura
2026-05-06 5:07 ` Niranjana Vishwanathapura
2026-05-05 23:44 ` [PATCH v3 07/11] drm/xe/lrc: Refactor out engine id to hwe conversion Umesh Nerlige Ramappa
2026-05-05 23:44 ` [PATCH v3 08/11] drm/xe/multi_queue: Capture queue run times for active queues Umesh Nerlige Ramappa
2026-05-06 3:30 ` Niranjana Vishwanathapura
2026-05-05 23:44 ` [PATCH v3 09/11] drm/xe/multi_queue: Add trace event for the multi queue timestamp Umesh Nerlige Ramappa
2026-05-06 5:03 ` Niranjana Vishwanathapura
2026-05-06 20:25 ` Umesh Nerlige Ramappa
2026-05-05 23:44 ` [PATCH v3 10/11] drm/xe/multi_queue: Use QUEUE_TIMESTAMP as job timestamp for multi-queue Umesh Nerlige Ramappa
2026-05-05 23:44 ` [PATCH v3 11/11] drm/xe/multi_queue: Whitelist QUEUE_TIMESTAMP register Umesh Nerlige Ramappa
2026-05-06 3:31 ` Niranjana Vishwanathapura
2026-05-05 23:51 ` ✗ CI.checkpatch: warning for Support run ticks for multi-queue use case (rev3) Patchwork
2026-05-05 23:53 ` ✓ CI.KUnit: success " 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=afqx5UtkmPbR0HPU@nvishwa1-desk \
--to=niranjana.vishwanathapura@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=stuart.summers@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