Commit dba4d442 authored by Matthew Auld's avatar Matthew Auld
Browse files

drm/i915/ttm: remove calc_ctrl_surf_instr_size



We only ever need to emit one ccs block copy command.

Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: default avatarRamalingam <C&lt;ramalingam.c@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220805132240.442747-1-matthew.auld@intel.com
parent 3d037d99
Loading
Loading
Loading
Loading
+3 −32
Original line number Diff line number Diff line
@@ -511,44 +511,16 @@ static inline u32 *i915_flush_dw(u32 *cmd, u32 flags)
	return cmd;
}

static u32 calc_ctrl_surf_instr_size(struct drm_i915_private *i915, int size)
{
	u32 num_cmds, num_blks, total_size;

	if (!GET_CCS_BYTES(i915, size))
		return 0;

	/*
	 * XY_CTRL_SURF_COPY_BLT transfers CCS in 256 byte
	 * blocks. one XY_CTRL_SURF_COPY_BLT command can
	 * transfer upto 1024 blocks.
	 */
	num_blks = DIV_ROUND_UP(GET_CCS_BYTES(i915, size),
				NUM_CCS_BYTES_PER_BLOCK);
	num_cmds = DIV_ROUND_UP(num_blks, NUM_CCS_BLKS_PER_XFER);
	total_size = XY_CTRL_SURF_INSTR_SIZE * num_cmds;

	/*
	 * Adding a flush before and after XY_CTRL_SURF_COPY_BLT
	 */
	total_size += 2 * MI_FLUSH_DW_SIZE;

	return total_size;
}

static int emit_copy_ccs(struct i915_request *rq,
			 u32 dst_offset, u8 dst_access,
			 u32 src_offset, u8 src_access, int size)
{
	struct drm_i915_private *i915 = rq->engine->i915;
	int mocs = rq->engine->gt->mocs.uc_index << 1;
	u32 num_ccs_blks, ccs_ring_size;
	u32 num_ccs_blks;
	u32 *cs;

	ccs_ring_size = calc_ctrl_surf_instr_size(i915, size);
	WARN_ON(!ccs_ring_size);

	cs = intel_ring_begin(rq, round_up(ccs_ring_size, 2));
	cs = intel_ring_begin(rq, 12);
	if (IS_ERR(cs))
		return PTR_ERR(cs);

@@ -583,7 +555,6 @@ static int emit_copy_ccs(struct i915_request *rq,
		FIELD_PREP(XY_CTRL_SURF_MOCS_MASK, mocs);

	cs = i915_flush_dw(cs, MI_FLUSH_DW_LLC | MI_FLUSH_DW_CCS);
	if (ccs_ring_size & 1)
	*cs++ = MI_NOOP;

	intel_ring_advance(rq, cs);