[PATCH v5 3/3] drm/xe: Add WA BB to capture active context utilization
Tvrtko Ursulin
tursulin at ursulin.net
Tue May 20 09:01:59 UTC 2025
Hi,
One question below in the context of the missing workarounds series I am
working on:
On 09/05/2025 17:12, Umesh Nerlige Ramappa wrote:
8><
> +#define CONTEXT_ACTIVE 1ULL
> +static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
> +{
> + u32 *cmd;
> +
> + cmd = lrc->bb_per_ctx_bo->vmap.vaddr;
> +
> + *cmd++ = MI_STORE_REGISTER_MEM | MI_SRM_USE_GGTT | MI_SRM_ADD_CS_OFFSET;
> + *cmd++ = ENGINE_ID(0).addr;
> + *cmd++ = __xe_lrc_engine_id_ggtt_addr(lrc);
> + *cmd++ = 0;
> +
> + *cmd++ = MI_STORE_DATA_IMM | MI_SDI_GGTT | MI_SDI_NUM_DW(1);
> + *cmd++ = __xe_lrc_ctx_timestamp_ggtt_addr(lrc);
> + *cmd++ = 0;
> + *cmd++ = lower_32_bits(CONTEXT_ACTIVE);
> +
> + if (lrc_to_xe(lrc)->info.has_64bit_timestamp) {
> + *cmd++ = MI_STORE_DATA_IMM | MI_SDI_GGTT | MI_SDI_NUM_DW(1);
> + *cmd++ = __xe_lrc_ctx_timestamp_udw_ggtt_addr(lrc);
> + *cmd++ = 0;
> + *cmd++ = upper_32_bits(CONTEXT_ACTIVE);
> + }
> +
> + *cmd++ = MI_BATCH_BUFFER_END;
Matt Roper raised the suggestion in another series that we should always
use the iosys helpers for writing into mapped BOs. Later I realised this
code uses the same shortcut as I did. I probably even lifted the concept
since I placed my function right next to this one. :)
So question is what is the definitive recommended way to write into
mapped BOs? Is the direct writes shortcut acceptable, or this also needs
changing?
> +
> + xe_lrc_write_ctx_reg(lrc, CTX_BB_PER_CTX_PTR,
> + xe_bo_ggtt_addr(lrc->bb_per_ctx_bo) | 1);
Btw here code uses the iosys helpers. It is a different BO but they are
created/mapped the same AFAICT.
Regards,
Tvrtko
More information about the Intel-xe
mailing list