mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 23:59:33 -04:00
drm/xe/lrc: Refactor xe_lrc_timestamp to simplify logic
Use a context_active() helper and simplify the timestamp logic. Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> Link: https://patch.msgid.link/20260507162016.3888309-16-umesh.nerlige.ramappa@intel.com
This commit is contained in:
@@ -2585,6 +2585,11 @@ static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool context_active(struct xe_lrc *lrc)
|
||||||
|
{
|
||||||
|
return xe_lrc_ctx_timestamp(lrc) == CONTEXT_ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xe_lrc_timestamp() - Current ctx timestamp
|
* xe_lrc_timestamp() - Current ctx timestamp
|
||||||
* @lrc: Pointer to the lrc.
|
* @lrc: Pointer to the lrc.
|
||||||
@@ -2597,33 +2602,23 @@ 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 xe_lrc_timestamp(struct xe_lrc *lrc)
|
||||||
{
|
{
|
||||||
u64 lrc_ts, reg_ts, new_ts = lrc->ctx_timestamp;
|
u64 reg_ts, new_ts = lrc->ctx_timestamp;
|
||||||
u32 engine_id;
|
|
||||||
|
|
||||||
lrc_ts = xe_lrc_ctx_timestamp(lrc);
|
|
||||||
/* CTX_TIMESTAMP mmio read is invalid on VF, so return the LRC value */
|
/* CTX_TIMESTAMP mmio read is invalid on VF, so return the LRC value */
|
||||||
if (IS_SRIOV_VF(lrc_to_xe(lrc))) {
|
if (IS_SRIOV_VF(lrc_to_xe(lrc)))
|
||||||
new_ts = lrc_ts;
|
return xe_lrc_ctx_timestamp(lrc);
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lrc_ts == CONTEXT_ACTIVE) {
|
if (context_active(lrc) &&
|
||||||
engine_id = xe_lrc_engine_id(lrc);
|
!get_ctx_timestamp(lrc, xe_lrc_engine_id(lrc), ®_ts))
|
||||||
if (!get_ctx_timestamp(lrc, engine_id, ®_ts))
|
new_ts = reg_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
|
* If context swicthed out while we were here, just return the latest
|
||||||
* be a separate if condition.
|
* LRC CTX TIMESTAMP value.
|
||||||
*/
|
*/
|
||||||
if (lrc_ts != CONTEXT_ACTIVE)
|
if (!context_active(lrc))
|
||||||
new_ts = lrc_ts;
|
return xe_lrc_ctx_timestamp(lrc);
|
||||||
|
|
||||||
done:
|
|
||||||
return new_ts;
|
return new_ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user