Skip to content

Commit d01c763

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: ipc3: Dump IPC message payload
Dump the IPC message payload if BIT(11) of sof_debug is set and the message contains more data than just a header. The header size differs between TX and RX and in case of set_get_data, the header is always the reply header for the message regardless if it is TX or RX. The use of printk(KERN_DEBUG "..."); is on purpose to keep the dmesg output tidy. Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20230616100039.378150-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d498a3b commit d01c763

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

sound/soc/sof/ipc3.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ static inline void ipc3_log_header(struct device *dev, u8 *text, u32 cmd)
223223
}
224224
#endif
225225

226+
static void sof_ipc3_dump_payload(struct snd_sof_dev *sdev,
227+
void *ipc_data, size_t size)
228+
{
229+
printk(KERN_DEBUG "Size of payload following the header: %zu\n", size);
230+
print_hex_dump_debug("Message payload: ", DUMP_PREFIX_OFFSET,
231+
16, 4, ipc_data, size, false);
232+
}
233+
226234
static int sof_ipc3_get_reply(struct snd_sof_dev *sdev)
227235
{
228236
struct snd_sof_ipc_msg *msg = sdev->msg;
@@ -374,6 +382,29 @@ static int sof_ipc3_tx_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_
374382

375383
ret = ipc3_tx_msg_unlocked(ipc, msg_data, msg_bytes, reply_data, reply_bytes);
376384

385+
if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
386+
size_t payload_bytes, header_bytes;
387+
char *payload = NULL;
388+
389+
/* payload is indicated by non zero msg/reply_bytes */
390+
if (msg_bytes > sizeof(struct sof_ipc_cmd_hdr)) {
391+
payload = msg_data;
392+
393+
header_bytes = sizeof(struct sof_ipc_cmd_hdr);
394+
payload_bytes = msg_bytes - header_bytes;
395+
} else if (reply_bytes > sizeof(struct sof_ipc_reply)) {
396+
payload = reply_data;
397+
398+
header_bytes = sizeof(struct sof_ipc_reply);
399+
payload_bytes = reply_bytes - header_bytes;
400+
}
401+
402+
if (payload) {
403+
payload += header_bytes;
404+
sof_ipc3_dump_payload(sdev, payload, payload_bytes);
405+
}
406+
}
407+
377408
mutex_unlock(&ipc->tx_mutex);
378409

379410
return ret;
@@ -472,6 +503,14 @@ static int sof_ipc3_set_get_data(struct snd_sof_dev *sdev, void *data, size_t da
472503
offset += payload_size;
473504
}
474505

506+
if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
507+
size_t header_bytes = sizeof(struct sof_ipc_reply);
508+
char *payload = (char *)cdata;
509+
510+
payload += header_bytes;
511+
sof_ipc3_dump_payload(sdev, payload, data_bytes - header_bytes);
512+
}
513+
475514
mutex_unlock(&sdev->ipc->tx_mutex);
476515

477516
kfree(cdata_chunk);

0 commit comments

Comments
 (0)