1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2014 Intel Corporation
6 #ifndef __GEN8_ENGINE_CS_H__
7 #define __GEN8_ENGINE_CS_H__
9 #include <linux/string.h>
10 #include <linux/types.h>
12 #include "i915_gem.h" /* GEM_BUG_ON */
13 #include "intel_gt_regs.h"
14 #include "intel_gpu_commands.h"
16 struct intel_engine_cs;
20 int gen8_emit_flush_rcs(struct i915_request *rq, u32 mode);
21 int gen11_emit_flush_rcs(struct i915_request *rq, u32 mode);
22 int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode);
24 int gen8_emit_flush_xcs(struct i915_request *rq, u32 mode);
25 int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode);
27 int gen8_emit_init_breadcrumb(struct i915_request *rq);
29 int gen8_emit_bb_start_noarb(struct i915_request *rq,
31 const unsigned int flags);
32 int gen8_emit_bb_start(struct i915_request *rq,
34 const unsigned int flags);
36 int xehp_emit_bb_start_noarb(struct i915_request *rq,
38 const unsigned int flags);
39 int xehp_emit_bb_start(struct i915_request *rq,
41 const unsigned int flags);
43 u32 *gen8_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs);
44 u32 *gen12_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs);
46 u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
47 u32 *gen11_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
48 u32 *gen12_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
50 u32 *gen12_emit_aux_table_inv(struct intel_engine_cs *engine, u32 *cs);
53 __gen8_emit_pipe_control(u32 *batch, u32 bit_group_0,
54 u32 bit_group_1, u32 offset)
56 memset(batch, 0, 6 * sizeof(u32));
58 batch[0] = GFX_OP_PIPE_CONTROL(6) | bit_group_0;
59 batch[1] = bit_group_1;
65 static inline u32 *gen8_emit_pipe_control(u32 *batch,
66 u32 bit_group_1, u32 offset)
68 return __gen8_emit_pipe_control(batch, 0, bit_group_1, offset);
71 static inline u32 *gen12_emit_pipe_control(u32 *batch, u32 bit_group_0,
72 u32 bit_group_1, u32 offset)
74 return __gen8_emit_pipe_control(batch, bit_group_0,
79 __gen8_emit_write_rcs(u32 *cs, u32 value, u32 offset, u32 flags0, u32 flags1)
81 *cs++ = GFX_OP_PIPE_CONTROL(6) | flags0;
82 *cs++ = flags1 | PIPE_CONTROL_QW_WRITE;
86 *cs++ = 0; /* We're thrashing one extra dword. */
92 gen8_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
94 /* We're using qword write, offset should be aligned to 8 bytes. */
95 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
97 return __gen8_emit_write_rcs(cs,
101 flags | PIPE_CONTROL_GLOBAL_GTT_IVB);
105 gen12_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags0, u32 flags1)
107 /* We're using qword write, offset should be aligned to 8 bytes. */
108 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
110 return __gen8_emit_write_rcs(cs,
114 flags1 | PIPE_CONTROL_GLOBAL_GTT_IVB);
118 __gen8_emit_flush_dw(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
120 *cs++ = (MI_FLUSH_DW + 1) | flags;
129 gen8_emit_ggtt_write(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
131 /* w/a: bit 5 needs to be zero for MI_FLUSH_DW address. */
132 GEM_BUG_ON(gtt_offset & (1 << 5));
133 /* Offset should be aligned to 8 bytes for both (QW/DW) write types */
134 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
136 return __gen8_emit_flush_dw(cs,
138 gtt_offset | MI_FLUSH_DW_USE_GTT,
139 flags | MI_FLUSH_DW_OP_STOREDW);
142 #endif /* __GEN8_ENGINE_CS_H__ */