Lines Matching full:buffer
21 * Command Buffer helper:
25 static inline void OUT(struct etnaviv_cmdbuf *buffer, u32 data) in OUT() argument
27 u32 *vaddr = (u32 *)buffer->vaddr; in OUT()
29 BUG_ON(buffer->user_size >= buffer->size); in OUT()
31 vaddr[buffer->user_size / 4] = data; in OUT()
32 buffer->user_size += 4; in OUT()
35 static inline void CMD_LOAD_STATE(struct etnaviv_cmdbuf *buffer, in CMD_LOAD_STATE() argument
40 buffer->user_size = ALIGN(buffer->user_size, 8); in CMD_LOAD_STATE()
43 OUT(buffer, VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE | in CMD_LOAD_STATE()
46 OUT(buffer, value); in CMD_LOAD_STATE()
49 static inline void CMD_END(struct etnaviv_cmdbuf *buffer) in CMD_END() argument
51 buffer->user_size = ALIGN(buffer->user_size, 8); in CMD_END()
53 OUT(buffer, VIV_FE_END_HEADER_OP_END); in CMD_END()
56 static inline void CMD_WAIT(struct etnaviv_cmdbuf *buffer) in CMD_WAIT() argument
58 buffer->user_size = ALIGN(buffer->user_size, 8); in CMD_WAIT()
60 OUT(buffer, VIV_FE_WAIT_HEADER_OP_WAIT | 200); in CMD_WAIT()
63 static inline void CMD_LINK(struct etnaviv_cmdbuf *buffer, in CMD_LINK() argument
66 buffer->user_size = ALIGN(buffer->user_size, 8); in CMD_LINK()
68 OUT(buffer, VIV_FE_LINK_HEADER_OP_LINK | in CMD_LINK()
70 OUT(buffer, address); in CMD_LINK()
73 static inline void CMD_STALL(struct etnaviv_cmdbuf *buffer, in CMD_STALL() argument
76 buffer->user_size = ALIGN(buffer->user_size, 8); in CMD_STALL()
78 OUT(buffer, VIV_FE_STALL_HEADER_OP_STALL); in CMD_STALL()
79 OUT(buffer, VIV_FE_STALL_TOKEN_FROM(from) | VIV_FE_STALL_TOKEN_TO(to)); in CMD_STALL()
82 static inline void CMD_SEM(struct etnaviv_cmdbuf *buffer, u32 from, u32 to) in CMD_SEM() argument
84 CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN, in CMD_SEM()
90 struct etnaviv_cmdbuf *buffer, u8 pipe) in etnaviv_cmd_select_pipe() argument
107 CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE, flush); in etnaviv_cmd_select_pipe()
108 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_cmd_select_pipe()
109 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_cmd_select_pipe()
111 CMD_LOAD_STATE(buffer, VIVS_GL_PIPE_SELECT, in etnaviv_cmd_select_pipe()
136 static void etnaviv_buffer_replace_wait(struct etnaviv_cmdbuf *buffer, in etnaviv_buffer_replace_wait() argument
139 u32 *lw = buffer->vaddr + wl_offset; in etnaviv_buffer_replace_wait()
148 * Ensure that there is space in the command buffer to contiguously write
149 * 'cmd_dwords' 64-bit words into the buffer, wrapping if necessary.
152 struct etnaviv_cmdbuf *buffer, unsigned int cmd_dwords) in etnaviv_buffer_reserve() argument
154 if (buffer->user_size + cmd_dwords * sizeof(u64) > buffer->size) in etnaviv_buffer_reserve()
155 buffer->user_size = 0; in etnaviv_buffer_reserve()
157 return etnaviv_cmdbuf_get_va(buffer, in etnaviv_buffer_reserve()
159 buffer->user_size; in etnaviv_buffer_reserve()
164 struct etnaviv_cmdbuf *buffer = &gpu->buffer; in etnaviv_buffer_init() local
168 /* initialize buffer */ in etnaviv_buffer_init()
169 buffer->user_size = 0; in etnaviv_buffer_init()
171 CMD_WAIT(buffer); in etnaviv_buffer_init()
172 CMD_LINK(buffer, 2, in etnaviv_buffer_init()
173 etnaviv_cmdbuf_get_va(buffer, &gpu->mmu_context->cmdbuf_mapping) in etnaviv_buffer_init()
174 + buffer->user_size - 4); in etnaviv_buffer_init()
176 return buffer->user_size / 8; in etnaviv_buffer_init()
181 struct etnaviv_cmdbuf *buffer = &gpu->buffer; in etnaviv_buffer_config_mmuv2() local
185 buffer->user_size = 0; in etnaviv_buffer_config_mmuv2()
188 CMD_LOAD_STATE(buffer, VIVS_GL_PIPE_SELECT, in etnaviv_buffer_config_mmuv2()
190 CMD_LOAD_STATE(buffer, VIVS_MMUv2_CONFIGURATION, in etnaviv_buffer_config_mmuv2()
192 CMD_LOAD_STATE(buffer, VIVS_MMUv2_SAFE_ADDRESS, safe_addr); in etnaviv_buffer_config_mmuv2()
193 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_config_mmuv2()
194 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_config_mmuv2()
198 CMD_LOAD_STATE(buffer, VIVS_GL_PIPE_SELECT, in etnaviv_buffer_config_mmuv2()
200 CMD_LOAD_STATE(buffer, VIVS_MMUv2_CONFIGURATION, in etnaviv_buffer_config_mmuv2()
202 CMD_LOAD_STATE(buffer, VIVS_MMUv2_SAFE_ADDRESS, safe_addr); in etnaviv_buffer_config_mmuv2()
203 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_config_mmuv2()
204 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_config_mmuv2()
207 CMD_END(buffer); in etnaviv_buffer_config_mmuv2()
209 buffer->user_size = ALIGN(buffer->user_size, 8); in etnaviv_buffer_config_mmuv2()
211 return buffer->user_size / 8; in etnaviv_buffer_config_mmuv2()
216 struct etnaviv_cmdbuf *buffer = &gpu->buffer; in etnaviv_buffer_config_pta() local
220 buffer->user_size = 0; in etnaviv_buffer_config_pta()
222 CMD_LOAD_STATE(buffer, VIVS_MMUv2_PTA_CONFIG, in etnaviv_buffer_config_pta()
225 CMD_END(buffer); in etnaviv_buffer_config_pta()
227 buffer->user_size = ALIGN(buffer->user_size, 8); in etnaviv_buffer_config_pta()
229 return buffer->user_size / 8; in etnaviv_buffer_config_pta()
234 struct etnaviv_cmdbuf *buffer = &gpu->buffer; in etnaviv_buffer_end() local
235 unsigned int waitlink_offset = buffer->user_size - 16; in etnaviv_buffer_end()
257 link_target = etnaviv_buffer_reserve(gpu, buffer, dwords); in etnaviv_buffer_end()
259 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_end()
260 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_end()
262 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1); in etnaviv_buffer_end()
263 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT); in etnaviv_buffer_end()
264 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT); in etnaviv_buffer_end()
265 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0); in etnaviv_buffer_end()
267 CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE, flush); in etnaviv_buffer_end()
270 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1); in etnaviv_buffer_end()
271 CMD_LOAD_STATE(buffer, VIVS_BLT_SET_COMMAND, 0x1); in etnaviv_buffer_end()
272 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0); in etnaviv_buffer_end()
274 CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE, in etnaviv_buffer_end()
278 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_end()
279 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_end()
281 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1); in etnaviv_buffer_end()
282 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT); in etnaviv_buffer_end()
283 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT); in etnaviv_buffer_end()
284 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0); in etnaviv_buffer_end()
286 CMD_END(buffer); in etnaviv_buffer_end()
288 etnaviv_buffer_replace_wait(buffer, waitlink_offset, in etnaviv_buffer_end()
294 etnaviv_buffer_replace_wait(buffer, waitlink_offset, in etnaviv_buffer_end()
299 /* Append a 'sync point' to the ring buffer. */
302 struct etnaviv_cmdbuf *buffer = &gpu->buffer; in etnaviv_sync_point_queue() local
303 unsigned int waitlink_offset = buffer->user_size - 16; in etnaviv_sync_point_queue()
313 target = etnaviv_buffer_reserve(gpu, buffer, dwords); in etnaviv_sync_point_queue()
316 CMD_LOAD_STATE(buffer, VIVS_GL_EVENT, VIVS_GL_EVENT_EVENT_ID(event) | in etnaviv_sync_point_queue()
320 CMD_END(buffer); in etnaviv_sync_point_queue()
323 CMD_WAIT(buffer); in etnaviv_sync_point_queue()
324 CMD_LINK(buffer, 2, in etnaviv_sync_point_queue()
325 etnaviv_cmdbuf_get_va(buffer, &gpu->mmu_context->cmdbuf_mapping) in etnaviv_sync_point_queue()
326 + buffer->user_size - 4); in etnaviv_sync_point_queue()
330 * WAIT with a link to the address in the ring buffer. in etnaviv_sync_point_queue()
332 etnaviv_buffer_replace_wait(buffer, waitlink_offset, in etnaviv_sync_point_queue()
338 /* Append a command buffer to the ring buffer. */
343 struct etnaviv_cmdbuf *buffer = &gpu->buffer; in etnaviv_buffer_queue() local
344 unsigned int waitlink_offset = buffer->user_size - 16; in etnaviv_buffer_queue()
357 etnaviv_buffer_dump(gpu, buffer, 0, 0x50); in etnaviv_buffer_queue()
364 * If we need maintenance prior to submitting this buffer, we will in etnaviv_buffer_queue()
366 * link to this buffer - a total of four additional words. in etnaviv_buffer_queue()
390 target = etnaviv_buffer_reserve(gpu, buffer, extra_dwords); in etnaviv_buffer_queue()
408 CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_MMU, in etnaviv_buffer_queue()
422 CMD_LOAD_STATE(buffer, in etnaviv_buffer_queue()
430 CMD_LOAD_STATE(buffer, VIVS_MMUv2_CONFIGURATION, in etnaviv_buffer_queue()
432 CMD_SEM(buffer, SYNC_RECIPIENT_FE, in etnaviv_buffer_queue()
434 CMD_STALL(buffer, SYNC_RECIPIENT_FE, in etnaviv_buffer_queue()
442 etnaviv_cmd_select_pipe(gpu, buffer, exec_state); in etnaviv_buffer_queue()
446 /* And the link to the submitted buffer */ in etnaviv_buffer_queue()
449 CMD_LINK(buffer, link_dwords, link_target); in etnaviv_buffer_queue()
457 * Append a LINK to the submitted command buffer to return to in etnaviv_buffer_queue()
458 * the ring buffer. return_target is the ring target address. in etnaviv_buffer_queue()
472 return_target = etnaviv_buffer_reserve(gpu, buffer, return_dwords); in etnaviv_buffer_queue()
477 * the wait command to the ring buffer. in etnaviv_buffer_queue()
480 CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE, in etnaviv_buffer_queue()
483 CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE, in etnaviv_buffer_queue()
487 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1); in etnaviv_buffer_queue()
488 CMD_LOAD_STATE(buffer, VIVS_BLT_SET_COMMAND, 0x1); in etnaviv_buffer_queue()
489 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0); in etnaviv_buffer_queue()
491 CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE, in etnaviv_buffer_queue()
495 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_queue()
496 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); in etnaviv_buffer_queue()
499 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1); in etnaviv_buffer_queue()
500 CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT); in etnaviv_buffer_queue()
501 CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT); in etnaviv_buffer_queue()
502 CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0); in etnaviv_buffer_queue()
505 CMD_LOAD_STATE(buffer, VIVS_GL_EVENT, VIVS_GL_EVENT_EVENT_ID(event) | in etnaviv_buffer_queue()
507 CMD_WAIT(buffer); in etnaviv_buffer_queue()
508 CMD_LINK(buffer, 2, in etnaviv_buffer_queue()
509 etnaviv_cmdbuf_get_va(buffer, &gpu->mmu_context->cmdbuf_mapping) in etnaviv_buffer_queue()
510 + buffer->user_size - 4); in etnaviv_buffer_queue()
522 pr_info("link op: %p\n", buffer->vaddr + waitlink_offset); in etnaviv_buffer_queue()
530 * WAIT with a link to the address in the ring buffer. in etnaviv_buffer_queue()
532 etnaviv_buffer_replace_wait(buffer, waitlink_offset, in etnaviv_buffer_queue()
538 etnaviv_buffer_dump(gpu, buffer, 0, 0x50); in etnaviv_buffer_queue()