Sound Open Firmware
Loading...
Searching...
No Matches
dma-trace.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
4 *
5 * Author: Yan Wang <yan.wang@linux.intel.com>
6 */
7
14#ifndef __SOF_TRACE_DMA_TRACE_H__
15#define __SOF_TRACE_DMA_TRACE_H__
16
17#include <sof/lib/dma.h>
18#include <rtos/task.h>
19#include <rtos/sof.h>
20#include <rtos/spinlock.h>
21#include <ipc/trace.h>
22#include <stdint.h>
23
24struct ipc_msg;
25struct sof;
26
32 void *w_ptr;
33 void *r_ptr;
34 void *addr;
35 void *end_addr;
36 uint32_t size;
37 uint32_t avail;
38};
39
47 struct dma_copy dc;
49 struct ipc_msg *msg;
50 uint32_t host_size;
51 struct task dmat_work;
52 uint32_t enabled;
54 uint32_t stream_tag;
56 uint32_t dma_copy_align;
57 uint32_t dropped_entries;
58 struct k_spinlock lock;
59 uint64_t time_delta;
60};
61
69
77
87 struct dma_sg_elem_array *elem_array,
88 uint32_t host_size);
89
97
104
110void dma_trace_flush(void *destination);
111
116void dma_trace_on(void);
117
122void dma_trace_off(void);
123
130void dtrace_event(const char *e, uint32_t size);
131
138void dtrace_event_atomic(const char *e, uint32_t length);
139
146static inline bool dma_trace_initialized(const struct dma_trace_data *d)
147{
148 return d && d->dmatb.addr;
149}
150
156static inline struct dma_trace_data *dma_trace_data_get(void)
157{
158 return sof_get()->dmat;
159}
160
167static inline uint32_t dtrace_calc_buf_margin(struct dma_trace_buf *buffer)
168{
169 return (char *)buffer->end_addr - (char *)buffer->w_ptr;
170}
171
172#endif /* __SOF_TRACE_DMA_TRACE_H__ */
static bool dma_trace_initialized(const struct dma_trace_data *d)
Check whether DMA trace subsystem has been initialized.
Definition dma-trace.h:146
void dma_trace_disable(struct dma_trace_data *d)
Disable DMA trace streaming and cancel pending periodic tasks.
static uint32_t dtrace_calc_buf_margin(struct dma_trace_buf *buffer)
Calculate contiguous bytes remaining until the end of the circular buffer.
Definition dma-trace.h:167
void dtrace_event(const char *e, uint32_t size)
Append a binary trace event to the circular buffer.
void dma_trace_flush(void *destination)
Flush residual trace data from local DSP buffer to destination memory or mailbox.
void dtrace_event_atomic(const char *e, uint32_t length)
Append a binary trace event to the buffer from atomic or interrupt context.
void dma_trace_on(void)
Globally unpause and resume trace event logging.
int dma_trace_init_early(struct sof *sof)
Early initialization of the DMA trace subsystem during bootstrap.
int dma_trace_enable(struct dma_trace_data *d)
Enable DMA trace streaming to the host.
int dma_trace_init_complete(struct dma_trace_data *d)
Complete initialization of DMA trace once host channel is negotiated.
static struct dma_trace_data * dma_trace_data_get(void)
Retrieve global DMA trace data context from system runtime.
Definition dma-trace.h:156
void dma_trace_off(void)
Globally pause trace event logging.
int dma_trace_host_buffer(struct dma_trace_data *d, struct dma_sg_elem_array *elem_array, uint32_t host_size)
Configure the host-side destination scatter-gather buffer for DMA trace.
Sound Open Firmware global runtime context.
struct sof * sof_get(void)
Get the global Sound Open Firmware runtime instance pointer.
RTOS spinlock primitives and initialization.
Host-DSP IPC trace DMA configuration, filtering, and panic descriptors.
Definition dma.h:253
Definition dma.h:161
SG elem array.
Definition dma.h:155
Internal ring buffer descriptor for DSP trace packets.
Definition dma-trace.h:31
void * end_addr
Upper boundary address of the trace buffer.
Definition dma-trace.h:35
void * w_ptr
Buffer write pointer where new trace packets are appended.
Definition dma-trace.h:32
uint32_t avail
Number of readable bytes currently available.
Definition dma-trace.h:37
void * addr
Base address of the circular trace buffer.
Definition dma-trace.h:34
uint32_t size
Total size of the buffer in bytes.
Definition dma-trace.h:36
void * r_ptr
Buffer read pointer tracking data transferred by DMA.
Definition dma-trace.h:33
Main DMA trace context and state machine descriptor.
Definition dma-trace.h:44
struct dma_copy dc
DMA copy engine instance.
Definition dma-trace.h:47
struct ipc_msg * msg
IPC message used to report buffer position.
Definition dma-trace.h:49
uint32_t stream_tag
Assigned host DMA stream tag.
Definition dma-trace.h:54
struct dma_trace_buf dmatb
Internal circular buffer tracking read/write pointers.
Definition dma-trace.h:46
struct dma_sg_config config
Scatter-gather configuration for host DMA.
Definition dma-trace.h:45
uint32_t dropped_entries
Cumulative counter of dropped entries due to buffer overflow.
Definition dma-trace.h:57
uint64_t time_delta
Offset between host wallclock and DSP hardware timer.
Definition dma-trace.h:59
struct task dmat_work
Periodic scheduling task driving DMA transfers.
Definition dma-trace.h:51
uint32_t dma_copy_align
Minimal byte alignment required for DMA transfer chunks.
Definition dma-trace.h:56
struct sof_ipc_dma_trace_posn posn
Position report payload sent to host.
Definition dma-trace.h:48
uint32_t active_stream_tag
Current active stream tag.
Definition dma-trace.h:55
uint32_t host_size
Total size of host-allocated trace buffer.
Definition dma-trace.h:50
uint32_t copy_in_progress
1 if a DMA copy operation is currently underway
Definition dma-trace.h:53
uint32_t enabled
1 if DMA trace streaming is active, 0 otherwise
Definition dma-trace.h:52
struct k_spinlock lock
Spinlock synchronizing buffer writes and DMA triggers.
Definition dma-trace.h:58
Definition msg.h:34
DMA trace circular buffer position report sent to host (SOF_IPC_TRACE_DMA_POSITION).
Definition trace.h:52
General firmware context.
Definition sof.h:50
struct dma_trace_data * dmat
Definition sof.h:64
Core task structure managed by SOF schedulers.
Definition task.h:81
Core task descriptor, task operations, and task execution state machine.