[Intel-xe] [PATCH 1/3] drm/xe: Prepare to emit non-register state while recording default LRC

Balasubramani Vivekanandan balasubramani.vivekanandan at intel.com
Wed Oct 25 13:48:53 UTC 2023


On 17.10.2023 16:18, Matt Roper wrote:
> On some platforms we need to emit some non-register state while
> recording an engine class' default LRC.  Add the infrastructure to
> support this; actual per-platform tables will be added in future
> patches.
> 
> Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_gt.c  | 10 ++++++++-
>  drivers/gpu/drm/xe/xe_lrc.c | 44 +++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_lrc.h |  3 +++
>  3 files changed, 56 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index 74e1f47bd401..8618275b1877 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c
> @@ -136,7 +136,13 @@ static int emit_wa_job(struct xe_gt *gt, struct xe_exec_queue *q)
>  	long timeout;
>  	int count = 0;
>  
> -	bb = xe_bb_new(gt, SZ_4K, false);	/* Just pick a large BB size */
> +	if (q->hwe->class == XE_ENGINE_CLASS_RENDER)
> +		/* Big enough to emit all of the context's 3DSTATE */
> +		bb = xe_bb_new(gt, xe_lrc_size(gt_to_xe(gt), q->hwe->class), false);
> +	else
> +		/* Just pick a large BB size */
> +		bb = xe_bb_new(gt, SZ_4K, false);
> +
>  	if (IS_ERR(bb))
>  		return PTR_ERR(bb);
>  
> @@ -173,6 +179,8 @@ static int emit_wa_job(struct xe_gt *gt, struct xe_exec_queue *q)
>  		}
>  	}
>  
> +	xe_lrc_emit_hwe_state_instructions(q, bb);
> +
>  	job = xe_bb_create_job(q, bb);
>  	if (IS_ERR(job)) {
>  		xe_bb_free(bb, NULL);
> diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> index 332fc0602074..1f7b1ea00d4d 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.c
> +++ b/drivers/gpu/drm/xe/xe_lrc.c
> @@ -12,6 +12,7 @@
>  #include "regs/xe_gt_regs.h"
>  #include "regs/xe_lrc_layout.h"
>  #include "regs/xe_regs.h"
> +#include "xe_bb.h"
>  #include "xe_bo.h"
>  #include "xe_device.h"
>  #include "xe_drm_client.h"
> @@ -1108,3 +1109,46 @@ void xe_lrc_dump_default(struct drm_printer *p,
>  		remaining_dw -= num_dw;
>  	}
>  }
> +
> +struct instr_state {
> +	u32 instr;
> +	u16 num_dw;
> +};
> +
> +void xe_lrc_emit_hwe_state_instructions(struct xe_exec_queue *q, struct xe_bb *bb)
> +{
> +	struct xe_gt *gt = q->hwe->gt;
> +	struct xe_device *xe = gt_to_xe(gt);
> +	const struct instr_state *state_table;
> +	int state_table_size;
> +
> +	/*
> +	 * At the moment we only need to emit non-register state for the RCS
> +	 * engine.
> +	 */
> +	if (q->hwe->class != XE_ENGINE_CLASS_RENDER)
> +		return;
> +
> +	switch(GRAPHICS_VERx100(xe)) {
> +	default:
> +		xe_gt_dbg(gt, "No non-register state to emit on graphics ver %d.%02d\n",
> +			  GRAPHICS_VER(xe), GRAPHICS_VERx100(xe) % 100);
> +		return;
> +	}
> +
> +	for (int i = 0; i < state_table_size; i++) {
> +		u32 instr = state_table[i].instr;
> +		u16 num_dw = state_table[i].num_dw;
> +		bool is_single_dw = ((instr & GFXPIPE_PIPELINE) == PIPELINE_SINGLE_DW);
> +
> +		xe_gt_assert(gt, (instr & XE_INSTR_CMD_TYPE) == XE_INSTR_GFXPIPE);
> +		xe_gt_assert(gt, is_single_dw ^ (num_dw > 1));
I think it may help to add an another assert statement to check if
num_dw == 0.

Rest looks good.

Reviewed-by: Balasubramani Vivekanandan <balasubramani.vivekanandan at intel.com>

Regards,
Bala
> +
> +		bb->cs[bb->len] = instr;
> +		if (!is_single_dw)
> +			bb->cs[bb->len] |= (num_dw - 2);
> +
> +		bb->len += num_dw;
> +	}
> +}
> +
> diff --git a/drivers/gpu/drm/xe/xe_lrc.h b/drivers/gpu/drm/xe/xe_lrc.h
> index a7056eda5e0c..28b1d3f404d4 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.h
> +++ b/drivers/gpu/drm/xe/xe_lrc.h
> @@ -8,6 +8,7 @@
>  #include "xe_lrc_types.h"
>  
>  struct drm_printer;
> +struct xe_bb;
>  struct xe_device;
>  struct xe_exec_queue;
>  enum xe_engine_class;
> @@ -52,4 +53,6 @@ void xe_lrc_dump_default(struct drm_printer *p,
>  			 struct xe_gt *gt,
>  			 enum xe_engine_class);
>  
> +void xe_lrc_emit_hwe_state_instructions(struct xe_exec_queue *q, struct xe_bb *bb);
> +
>  #endif
> -- 
> 2.41.0
> 


More information about the Intel-xe mailing list