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"
19 int gen8_emit_flush_rcs(struct i915_request *rq, u32 mode);
20 int gen11_emit_flush_rcs(struct i915_request *rq, u32 mode);
21 int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode);
23 int gen8_emit_flush_xcs(struct i915_request *rq, u32 mode);
24 int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode);
26 int gen8_emit_init_breadcrumb(struct i915_request *rq);
28 int gen8_emit_bb_start_noarb(struct i915_request *rq,
30 const unsigned int flags);
31 int gen8_emit_bb_start(struct i915_request *rq,
33 const unsigned int flags);
35 int gen125_emit_bb_start_noarb(struct i915_request *rq,
37 const unsigned int flags);
38 int gen125_emit_bb_start(struct i915_request *rq,
40 const unsigned int flags);
42 u32 *gen8_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs);
43 u32 *gen12_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs);
45 u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
46 u32 *gen11_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
47 u32 *gen12_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
49 u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg);
52 __gen8_emit_pipe_control(u32 *batch, u32 flags0, u32 flags1, u32 offset)
54 memset(batch, 0, 6 * sizeof(u32));
56 batch[0] = GFX_OP_PIPE_CONTROL(6) | flags0;
63 static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset)
65 return __gen8_emit_pipe_control(batch, 0, flags, offset);
68 static inline u32 *gen12_emit_pipe_control(u32 *batch, u32 flags0, u32 flags1, u32 offset)
70 return __gen8_emit_pipe_control(batch, flags0, flags1, offset);
74 __gen8_emit_write_rcs(u32 *cs, u32 value, u32 offset, u32 flags0, u32 flags1)
76 *cs++ = GFX_OP_PIPE_CONTROL(6) | flags0;
77 *cs++ = flags1 | PIPE_CONTROL_QW_WRITE;
81 *cs++ = 0; /* We're thrashing one extra dword. */
87 gen8_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
89 /* We're using qword write, offset should be aligned to 8 bytes. */
90 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
92 return __gen8_emit_write_rcs(cs,
96 flags | PIPE_CONTROL_GLOBAL_GTT_IVB);
100 gen12_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags0, u32 flags1)
102 /* We're using qword write, offset should be aligned to 8 bytes. */
103 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
105 return __gen8_emit_write_rcs(cs,
109 flags1 | PIPE_CONTROL_GLOBAL_GTT_IVB);
113 __gen8_emit_flush_dw(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
115 *cs++ = (MI_FLUSH_DW + 1) | flags;
124 gen8_emit_ggtt_write(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
126 /* w/a: bit 5 needs to be zero for MI_FLUSH_DW address. */
127 GEM_BUG_ON(gtt_offset & (1 << 5));
128 /* Offset should be aligned to 8 bytes for both (QW/DW) write types */
129 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
131 return __gen8_emit_flush_dw(cs,
133 gtt_offset | MI_FLUSH_DW_USE_GTT,
134 flags | MI_FLUSH_DW_OP_STOREDW);
137 #endif /* __GEN8_ENGINE_CS_H__ */