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 */
14 #include "intel_gpu_commands.h"
18 int gen8_emit_flush_rcs(struct i915_request *rq, u32 mode);
19 int gen11_emit_flush_rcs(struct i915_request *rq, u32 mode);
20 int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode);
22 int gen8_emit_flush_xcs(struct i915_request *rq, u32 mode);
23 int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode);
25 int gen8_emit_init_breadcrumb(struct i915_request *rq);
27 int gen8_emit_bb_start_noarb(struct i915_request *rq,
29 const unsigned int flags);
30 int gen8_emit_bb_start(struct i915_request *rq,
32 const unsigned int flags);
34 u32 *gen8_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs);
35 u32 *gen12_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs);
37 u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
38 u32 *gen11_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
39 u32 *gen12_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
42 __gen8_emit_pipe_control(u32 *batch, u32 flags0, u32 flags1, u32 offset)
44 memset(batch, 0, 6 * sizeof(u32));
46 batch[0] = GFX_OP_PIPE_CONTROL(6) | flags0;
53 static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset)
55 return __gen8_emit_pipe_control(batch, 0, flags, offset);
58 static inline u32 *gen12_emit_pipe_control(u32 *batch, u32 flags0, u32 flags1, u32 offset)
60 return __gen8_emit_pipe_control(batch, flags0, flags1, offset);
64 __gen8_emit_write_rcs(u32 *cs, u32 value, u32 offset, u32 flags0, u32 flags1)
66 *cs++ = GFX_OP_PIPE_CONTROL(6) | flags0;
67 *cs++ = flags1 | PIPE_CONTROL_QW_WRITE;
71 *cs++ = 0; /* We're thrashing one extra dword. */
77 gen8_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
79 /* We're using qword write, offset should be aligned to 8 bytes. */
80 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
82 return __gen8_emit_write_rcs(cs,
86 flags | PIPE_CONTROL_GLOBAL_GTT_IVB);
90 gen12_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags0, u32 flags1)
92 /* We're using qword write, offset should be aligned to 8 bytes. */
93 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
95 return __gen8_emit_write_rcs(cs,
99 flags1 | PIPE_CONTROL_GLOBAL_GTT_IVB);
103 __gen8_emit_flush_dw(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
105 *cs++ = (MI_FLUSH_DW + 1) | flags;
114 gen8_emit_ggtt_write(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
116 /* w/a: bit 5 needs to be zero for MI_FLUSH_DW address. */
117 GEM_BUG_ON(gtt_offset & (1 << 5));
118 /* Offset should be aligned to 8 bytes for both (QW/DW) write types */
119 GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
121 return __gen8_emit_flush_dw(cs,
123 gtt_offset | MI_FLUSH_DW_USE_GTT,
124 flags | MI_FLUSH_DW_OP_STOREDW);
127 #endif /* __GEN8_ENGINE_CS_H__ */