Lines Matching +full:static +full:- +full:trace +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only OR MIT
19 static void
26 tracebuf_ctrl->tracebuf_size_in_dwords = ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS; in tracebuf_ctrl_init()
27 tracebuf_ctrl->tracebuf_flags = 0; in tracebuf_ctrl_init()
29 if (fw_trace->group_mask) in tracebuf_ctrl_init()
30 tracebuf_ctrl->log_type = fw_trace->group_mask | ROGUE_FWIF_LOG_TYPE_TRACE; in tracebuf_ctrl_init()
32 tracebuf_ctrl->log_type = ROGUE_FWIF_LOG_TYPE_NONE; in tracebuf_ctrl_init()
34 for (thread_nr = 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); thread_nr++) { in tracebuf_ctrl_init()
36 &tracebuf_ctrl->tracebuf[thread_nr]; in tracebuf_ctrl_init()
37 struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr]; in tracebuf_ctrl_init()
39 pvr_fw_object_get_fw_addr(trace_buffer->buf_obj, in tracebuf_ctrl_init()
40 &tracebuf_space->trace_buffer_fw_addr); in tracebuf_ctrl_init()
42 tracebuf_space->trace_buffer = trace_buffer->buf; in tracebuf_ctrl_init()
43 tracebuf_space->trace_pointer = 0; in tracebuf_ctrl_init()
49 struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; in pvr_fw_trace_init()
54 for (thread_nr = 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); thread_nr++) { in pvr_fw_trace_init()
55 struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr]; in pvr_fw_trace_init()
57 trace_buffer->buf = in pvr_fw_trace_init()
60 sizeof(*trace_buffer->buf), in pvr_fw_trace_init()
63 NULL, NULL, &trace_buffer->buf_obj); in pvr_fw_trace_init()
64 if (IS_ERR(trace_buffer->buf)) { in pvr_fw_trace_init()
65 drm_err(drm_dev, "Unable to allocate trace buffer\n"); in pvr_fw_trace_init()
66 err = PTR_ERR(trace_buffer->buf); in pvr_fw_trace_init()
67 trace_buffer->buf = NULL; in pvr_fw_trace_init()
73 fw_trace->group_mask = 0; in pvr_fw_trace_init()
75 fw_trace->tracebuf_ctrl = in pvr_fw_trace_init()
77 sizeof(*fw_trace->tracebuf_ctrl), in pvr_fw_trace_init()
81 &fw_trace->tracebuf_ctrl_obj); in pvr_fw_trace_init()
82 if (IS_ERR(fw_trace->tracebuf_ctrl)) { in pvr_fw_trace_init()
83 drm_err(drm_dev, "Unable to allocate trace buffer control structure\n"); in pvr_fw_trace_init()
84 err = PTR_ERR(fw_trace->tracebuf_ctrl); in pvr_fw_trace_init()
88 BUILD_BUG_ON(ARRAY_SIZE(fw_trace->tracebuf_ctrl->tracebuf) != in pvr_fw_trace_init()
89 ARRAY_SIZE(fw_trace->buffers)); in pvr_fw_trace_init()
91 for (thread_nr = 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); thread_nr++) { in pvr_fw_trace_init()
93 &fw_trace->tracebuf_ctrl->tracebuf[thread_nr]; in pvr_fw_trace_init()
94 struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr]; in pvr_fw_trace_init()
96 trace_buffer->tracebuf_space = tracebuf_space; in pvr_fw_trace_init()
102 for (thread_nr = 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); thread_nr++) { in pvr_fw_trace_init()
103 struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr]; in pvr_fw_trace_init()
105 if (trace_buffer->buf) in pvr_fw_trace_init()
106 pvr_fw_object_unmap_and_destroy(trace_buffer->buf_obj); in pvr_fw_trace_init()
114 struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; in pvr_fw_trace_fini()
117 for (thread_nr = 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); thread_nr++) { in pvr_fw_trace_fini()
118 struct pvr_fw_trace_buffer *trace_buffer = &fw_trace->buffers[thread_nr]; in pvr_fw_trace_fini()
120 pvr_fw_object_unmap_and_destroy(trace_buffer->buf_obj); in pvr_fw_trace_fini()
122 pvr_fw_object_unmap_and_destroy(fw_trace->tracebuf_ctrl_obj); in pvr_fw_trace_fini()
128 * update_logtype() - Send KCCB command to trigger FW to update logtype
135 * * -%EIO if the device is lost.
137 static int
140 struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; in update_logtype()
146 fw_trace->tracebuf_ctrl->log_type = ROGUE_FWIF_LOG_TYPE_TRACE | group_mask; in update_logtype()
148 fw_trace->tracebuf_ctrl->log_type = ROGUE_FWIF_LOG_TYPE_NONE; in update_logtype()
150 fw_trace->group_mask = group_mask; in update_logtype()
152 down_read(&pvr_dev->reset_sem); in update_logtype()
154 err = -EIO; in update_logtype()
166 up_read(&pvr_dev->reset_sem); in update_logtype()
172 /** @buffer: Pointer to copy of trace data. */
175 /** @start_offset: Starting offset in trace data, as reported by FW. */
178 /** @idx: Current index into trace data. */
181 /** @assert_buf: Trace assert buffer, as reported by FW. */
185 static u32 find_sfid(u32 id) in find_sfid() argument
190 if (stid_fmts[i].id == id) in find_sfid()
197 static u32 read_fw_trace(struct pvr_fw_trace_seq_data *trace_seq_data, u32 offset) in read_fw_trace()
201 idx = trace_seq_data->idx + offset; in read_fw_trace()
205 idx = (idx + trace_seq_data->start_offset) % ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS; in read_fw_trace()
206 return trace_seq_data->buffer[idx]; in read_fw_trace()
210 * fw_trace_get_next() - Advance trace index to next entry
211 * @trace_seq_data: Trace sequence data.
214 * * %true if trace index is now pointing to a valid entry, or
215 * * %false if trace index is pointing to an invalid entry, or has hit the end
216 * of the trace.
218 static bool fw_trace_get_next(struct pvr_fw_trace_seq_data *trace_seq_data) in fw_trace_get_next()
220 u32 id, sf_id; in fw_trace_get_next() local
222 while (trace_seq_data->idx < ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS) { in fw_trace_get_next()
223 id = read_fw_trace(trace_seq_data, 0); in fw_trace_get_next()
224 trace_seq_data->idx++; in fw_trace_get_next()
225 if (!ROGUE_FW_LOG_VALIDID(id)) in fw_trace_get_next()
227 if (id == ROGUE_FW_SF_MAIN_ASSERT_FAILED) { in fw_trace_get_next()
228 /* Assertion failure marks the end of the trace. */ in fw_trace_get_next()
232 sf_id = find_sfid(id); in fw_trace_get_next()
237 * Could not match with an ID in the SF table, trace is in fw_trace_get_next()
244 trace_seq_data->idx += 2 + ROGUE_FW_SF_PARAMNUM(id); in fw_trace_get_next()
246 /* Ensure index is now pointing to a valid trace entry. */ in fw_trace_get_next()
247 id = read_fw_trace(trace_seq_data, 0); in fw_trace_get_next()
248 if (!ROGUE_FW_LOG_VALIDID(id)) in fw_trace_get_next()
254 /* Hit end of trace data. */ in fw_trace_get_next()
259 * fw_trace_get_first() - Find first valid entry in trace
260 * @trace_seq_data: Trace sequence data.
264 * If the trace has no valid entries, this function will exit with the trace
265 * index pointing to the end of the trace. trace_seq_show() will return an error
268 static void fw_trace_get_first(struct pvr_fw_trace_seq_data *trace_seq_data) in fw_trace_get_first()
270 trace_seq_data->idx = 0; in fw_trace_get_first()
272 while (trace_seq_data->idx < ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS) { in fw_trace_get_first()
273 u32 id = read_fw_trace(trace_seq_data, 0); in fw_trace_get_first() local
275 if (ROGUE_FW_LOG_VALIDID(id)) { in fw_trace_get_first()
276 u32 sf_id = find_sfid(id); in fw_trace_get_first()
281 trace_seq_data->idx++; in fw_trace_get_first()
285 static void *fw_trace_seq_start(struct seq_file *s, loff_t *pos) in fw_trace_seq_start()
287 struct pvr_fw_trace_seq_data *trace_seq_data = s->private; in fw_trace_seq_start()
290 /* Reset trace index, then advance to *pos. */ in fw_trace_seq_start()
298 return (trace_seq_data->idx < ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS) ? pos : NULL; in fw_trace_seq_start()
301 static void *fw_trace_seq_next(struct seq_file *s, void *v, loff_t *pos) in fw_trace_seq_next()
303 struct pvr_fw_trace_seq_data *trace_seq_data = s->private; in fw_trace_seq_next()
309 return (trace_seq_data->idx < ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS) ? pos : NULL; in fw_trace_seq_next()
312 static void fw_trace_seq_stop(struct seq_file *s, void *v) in fw_trace_seq_stop()
316 static int fw_trace_seq_show(struct seq_file *s, void *v) in fw_trace_seq_show()
318 struct pvr_fw_trace_seq_data *trace_seq_data = s->private; in fw_trace_seq_show()
320 u32 id; in fw_trace_seq_show() local
323 if (trace_seq_data->idx >= ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS) in fw_trace_seq_show()
324 return -EINVAL; in fw_trace_seq_show()
326 id = read_fw_trace(trace_seq_data, 0); in fw_trace_seq_show()
328 if (!ROGUE_FW_LOG_VALIDID(id)) in fw_trace_seq_show()
329 return -EINVAL; in fw_trace_seq_show()
331 sf_id = find_sfid(id); in fw_trace_seq_show()
334 return -EINVAL; in fw_trace_seq_show()
342 if (id == ROGUE_FW_SF_MAIN_ASSERT_FAILED) { in fw_trace_seq_show()
344 trace_seq_data->assert_buf.info, in fw_trace_seq_show()
345 trace_seq_data->assert_buf.path, in fw_trace_seq_show()
346 trace_seq_data->assert_buf.line_num); in fw_trace_seq_show()
374 static const struct seq_operations pvr_fw_trace_seq_ops = {
381 static int fw_trace_open(struct inode *inode, struct file *file) in fw_trace_open()
383 struct pvr_fw_trace_buffer *trace_buffer = inode->i_private; in fw_trace_open()
385 trace_buffer->tracebuf_space; in fw_trace_open()
391 return -ENOMEM; in fw_trace_open()
393 trace_seq_data->buffer = kcalloc(ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS, in fw_trace_open()
394 sizeof(*trace_seq_data->buffer), GFP_KERNEL); in fw_trace_open()
395 if (!trace_seq_data->buffer) { in fw_trace_open()
396 err = -ENOMEM; in fw_trace_open()
401 * Take a local copy of the trace buffer, as firmware may still be in fw_trace_open()
404 memcpy(trace_seq_data->buffer, trace_buffer->buf, in fw_trace_open()
406 trace_seq_data->start_offset = READ_ONCE(tracebuf_space->trace_pointer); in fw_trace_open()
407 trace_seq_data->assert_buf = tracebuf_space->assert_buf; in fw_trace_open()
414 ((struct seq_file *)file->private_data)->private = trace_seq_data; in fw_trace_open()
419 kfree(trace_seq_data->buffer); in fw_trace_open()
427 static int fw_trace_release(struct inode *inode, struct file *file) in fw_trace_release()
430 ((struct seq_file *)file->private_data)->private; in fw_trace_release()
433 kfree(trace_seq_data->buffer); in fw_trace_release()
439 static const struct file_operations pvr_fw_trace_fops = {
457 struct pvr_fw_trace *fw_trace = &pvr_dev->fw_dev.fw_trace; in pvr_fw_trace_debugfs_init()
460 static_assert(ARRAY_SIZE(fw_trace->buffers) <= 10, in pvr_fw_trace_debugfs_init()
461 "The filename buffer is only large enough for a single-digit thread count"); in pvr_fw_trace_debugfs_init()
463 for (thread_nr = 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); ++thread_nr) { in pvr_fw_trace_debugfs_init()
468 &fw_trace->buffers[thread_nr], in pvr_fw_trace_debugfs_init()