|
11 | 11 |
|
12 | 12 | #include <linux/device.h> |
13 | 13 | #include <linux/firmware.h> |
| 14 | +#include <linux/kfifo.h> |
14 | 15 | #include <sound/hda_codec.h> |
15 | 16 | #include <sound/hda_register.h> |
16 | 17 | #include <sound/soc-component.h> |
@@ -42,6 +43,10 @@ struct avs_dsp_ops { |
42 | 43 | int (* const load_basefw)(struct avs_dev *, struct firmware *); |
43 | 44 | int (* const load_lib)(struct avs_dev *, struct firmware *, u32); |
44 | 45 | int (* const transfer_mods)(struct avs_dev *, bool, struct avs_module_entry *, u32); |
| 46 | + int (* const enable_logs)(struct avs_dev *, enum avs_log_enable, u32, u32, unsigned long, |
| 47 | + u32 *); |
| 48 | + int (* const log_buffer_offset)(struct avs_dev *, u32); |
| 49 | + int (* const log_buffer_status)(struct avs_dev *, union avs_notify_msg *); |
45 | 50 | int (* const coredump)(struct avs_dev *, union avs_notify_msg *); |
46 | 51 | }; |
47 | 52 |
|
@@ -75,6 +80,16 @@ struct avs_fw_entry { |
75 | 80 | struct list_head node; |
76 | 81 | }; |
77 | 82 |
|
| 83 | +struct avs_debug { |
| 84 | + struct kfifo trace_fifo; |
| 85 | + spinlock_t fifo_lock; /* serialize I/O for trace_fifo */ |
| 86 | + spinlock_t trace_lock; /* serialize debug window I/O between each LOG_BUFFER_STATUS */ |
| 87 | + wait_queue_head_t trace_waitq; |
| 88 | + u32 aging_timer_period; |
| 89 | + u32 fifo_full_timer_period; |
| 90 | + u32 logged_resources; /* context dependent: core or library */ |
| 91 | +}; |
| 92 | + |
78 | 93 | /* |
79 | 94 | * struct avs_dev - Intel HD-Audio driver data |
80 | 95 | * |
@@ -115,6 +130,8 @@ struct avs_dev { |
115 | 130 | struct list_head path_list; |
116 | 131 | spinlock_t path_list_lock; |
117 | 132 | struct mutex path_mutex; |
| 133 | + |
| 134 | + struct avs_debug dbg; |
118 | 135 | }; |
119 | 136 |
|
120 | 137 | /* from hda_bus to avs_dev */ |
@@ -279,4 +296,19 @@ int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned l |
279 | 296 | unsigned long *tdms); |
280 | 297 | int avs_hda_platform_register(struct avs_dev *adev, const char *name); |
281 | 298 |
|
| 299 | +/* Firmware tracing helpers */ |
| 300 | + |
| 301 | +unsigned int __kfifo_fromio_locked(struct kfifo *fifo, const void __iomem *src, unsigned int len, |
| 302 | + spinlock_t *lock); |
| 303 | + |
| 304 | +#define avs_log_buffer_size(adev) \ |
| 305 | + ((adev)->fw_cfg.trace_log_bytes / (adev)->hw_cfg.dsp_cores) |
| 306 | + |
| 307 | +#define avs_log_buffer_addr(adev, core) \ |
| 308 | +({ \ |
| 309 | + s32 __offset = avs_dsp_op(adev, log_buffer_offset, core); \ |
| 310 | + (__offset < 0) ? NULL : \ |
| 311 | + (avs_sram_addr(adev, AVS_DEBUG_WINDOW) + __offset); \ |
| 312 | +}) |
| 313 | + |
282 | 314 | #endif /* __SOUND_SOC_INTEL_AVS_H */ |
0 commit comments