Skip to content

Commit 98832db

Browse files
committed
ASoC: SOF: ipc4-mtrace: resync host_read_ptr on debugfs open
IPC4 mtrace aging timer sends NOTIFY_LOG_BUFFER_STATUS IPC every 256ms but only when dsp_write_ptr has changed since last tick. If IPC is sent while no reader is active, the wake_up() is lost and core_data->dsp_write_ptr becomes stale. Open() finds host_read_ptr == dsp_write_ptr (both reflecting stale cached value) and blocks in sof_wait_mtrace_avail() waiting for IPC that will never come since DSP has gone idle. This causes empty trace output on platforms with low post-boot DSP activity. Fix this by re-reading dsp_write_ptr directly from SRAM in open() so reader see current write position without relying on IPC cache. host_read_ptr is intentionally left unchanged to preserve any data written between sessions Signed-off-by: Mateusz Junkier <mateusz.junkier@intel.com>
1 parent 667770d commit 98832db

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

sound/soc/sof/ipc4-mtrace.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ static int sof_ipc4_mtrace_dfs_open(struct inode *inode, struct file *file)
109109
return -ENOMEM;
110110
}
111111

112+
/*
113+
* Re-sync dsp_write_ptr from SRAM on open to avoid blocking
114+
* when the aging timer IPC was missed while no reader was active.
115+
*/
116+
if (core_data->slot_offset != SOF_IPC4_INVALID_SLOT_OFFSET) {
117+
struct snd_sof_dev *sdev = core_data->sdev;
118+
u32 write_ptr;
119+
120+
sof_mailbox_read(sdev, core_data->slot_offset + sizeof(u32),
121+
&write_ptr, sizeof(write_ptr));
122+
write_ptr -= write_ptr % 4;
123+
core_data->dsp_write_ptr = write_ptr;
124+
}
125+
112126
ret = simple_open(inode, file);
113127
if (ret) {
114128
kfree(core_data->log_buffer);

0 commit comments

Comments
 (0)