Commit f4ea22f7 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

ASoC: SOF: ipc4: Add support for mtrace log extraction

One of the debugging/logging features for an IPC4 based firmware is the use
of the debug window to deliver log messages to host via the shared SRAM.

The initial implementation of the mtrace supports only TGL/MTL style of
logging, but can be extended to support other types, like APL, SKL, CNL,
etc.

The window is split into 16 'slots' where the first slot contains the
descriptors for the remaining 15 slots.

Each DSP core logs to a separate slot and the slot allocation is not fixed,
we can not assume that the first slot is always used by core0 for example.

The firmware sends LOG_BUFFER_STATUS message when new log batch is
available from one of the cores (after it updated the write_ptr in the
given slot).
Host should update the read_ptr in the same slot when it has taken out log
data.

The patch also updates the sof_ipc4_fw_data struct with parameters needed
for the mtrace to be enabled and used safely.
Co-developed-by: default avatarRander Wang <rander.wang@intel.com>
Signed-off-by: default avatarRander Wang <rander.wang@intel.com>
Co-developed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220909114332.31393-6-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a5d0147a
...@@ -9,7 +9,8 @@ snd-sof-objs += ipc3.o ipc3-loader.o ipc3-topology.o ipc3-control.o ipc3-pcm.o\ ...@@ -9,7 +9,8 @@ snd-sof-objs += ipc3.o ipc3-loader.o ipc3-topology.o ipc3-control.o ipc3-pcm.o\
ipc3-dtrace.o ipc3-dtrace.o
endif endif
ifneq ($(CONFIG_SND_SOC_SOF_INTEL_IPC4),) ifneq ($(CONFIG_SND_SOC_SOF_INTEL_IPC4),)
snd-sof-objs += ipc4.o ipc4-loader.o ipc4-topology.o ipc4-control.o ipc4-pcm.o snd-sof-objs += ipc4.o ipc4-loader.o ipc4-topology.o ipc4-control.o ipc4-pcm.o\
ipc4-mtrace.o
endif endif
# SOF client support # SOF client support
......
...@@ -157,6 +157,7 @@ static int sof_ipc4_validate_firmware(struct snd_sof_dev *sdev) ...@@ -157,6 +157,7 @@ static int sof_ipc4_validate_firmware(struct snd_sof_dev *sdev)
static int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev) static int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev)
{ {
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
const struct sof_ipc_ops *iops = sdev->ipc->ops; const struct sof_ipc_ops *iops = sdev->ipc->ops;
struct sof_ipc4_fw_version *fw_ver; struct sof_ipc4_fw_version *fw_ver;
struct sof_ipc4_tuple *tuple; struct sof_ipc4_tuple *tuple;
...@@ -200,6 +201,7 @@ static int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev) ...@@ -200,6 +201,7 @@ static int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev)
break; break;
case SOF_IPC4_FW_CFG_TRACE_LOG_BYTES: case SOF_IPC4_FW_CFG_TRACE_LOG_BYTES:
dev_vdbg(sdev->dev, "Trace log size: %u\n", *tuple->value); dev_vdbg(sdev->dev, "Trace log size: %u\n", *tuple->value);
ipc4_data->mtrace_log_bytes = *tuple->value;
break; break;
default: default:
break; break;
......
This diff is collapsed.
...@@ -17,18 +17,29 @@ ...@@ -17,18 +17,29 @@
#define SOF_IPC4_OUTBOX_WINDOW_IDX 1 #define SOF_IPC4_OUTBOX_WINDOW_IDX 1
#define SOF_IPC4_DEBUG_WINDOW_IDX 2 #define SOF_IPC4_DEBUG_WINDOW_IDX 2
enum sof_ipc4_mtrace_type {
SOF_IPC4_MTRACE_NOT_AVAILABLE = 0,
SOF_IPC4_MTRACE_INTEL_CAVS_1_5,
SOF_IPC4_MTRACE_INTEL_CAVS_1_8,
SOF_IPC4_MTRACE_INTEL_CAVS_2,
};
/** /**
* struct sof_ipc4_fw_data - IPC4-specific data * struct sof_ipc4_fw_data - IPC4-specific data
* @manifest_fw_hdr_offset: FW header offset in the manifest * @manifest_fw_hdr_offset: FW header offset in the manifest
* @num_fw_modules : Number of modules in base FW * @num_fw_modules : Number of modules in base FW
* @fw_modules: Array of base FW modules * @fw_modules: Array of base FW modules
* @nhlt: NHLT table either from the BIOS or the topology manifest * @nhlt: NHLT table either from the BIOS or the topology manifest
* @mtrace_type: mtrace type supported on the booted platform
* @mtrace_log_bytes: log bytes as reported by the firmware via fw_config reply
*/ */
struct sof_ipc4_fw_data { struct sof_ipc4_fw_data {
u32 manifest_fw_hdr_offset; u32 manifest_fw_hdr_offset;
int num_fw_modules; int num_fw_modules;
void *fw_modules; void *fw_modules;
void *nhlt; void *nhlt;
enum sof_ipc4_mtrace_type mtrace_type;
u32 mtrace_log_bytes;
}; };
/** /**
...@@ -49,7 +60,8 @@ extern const struct sof_ipc_fw_loader_ops ipc4_loader_ops; ...@@ -49,7 +60,8 @@ extern const struct sof_ipc_fw_loader_ops ipc4_loader_ops;
extern const struct sof_ipc_tplg_ops ipc4_tplg_ops; extern const struct sof_ipc_tplg_ops ipc4_tplg_ops;
extern const struct sof_ipc_tplg_control_ops tplg_ipc4_control_ops; extern const struct sof_ipc_tplg_control_ops tplg_ipc4_control_ops;
extern const struct sof_ipc_pcm_ops ipc4_pcm_ops; extern const struct sof_ipc_pcm_ops ipc4_pcm_ops;
extern const struct sof_ipc_fw_tracing_ops ipc4_mtrace_ops;
int sof_ipc4_set_pipeline_state(struct snd_sof_dev *sdev, u32 id, u32 state); int sof_ipc4_set_pipeline_state(struct snd_sof_dev *sdev, u32 id, u32 state);
int sof_ipc4_mtrace_update_pos(struct snd_sof_dev *sdev, int core);
#endif #endif
...@@ -589,6 +589,9 @@ static void sof_ipc4_rx_msg(struct snd_sof_dev *sdev) ...@@ -589,6 +589,9 @@ static void sof_ipc4_rx_msg(struct snd_sof_dev *sdev)
case SOF_IPC4_NOTIFY_RESOURCE_EVENT: case SOF_IPC4_NOTIFY_RESOURCE_EVENT:
data_size = sizeof(struct sof_ipc4_notify_resource_data); data_size = sizeof(struct sof_ipc4_notify_resource_data);
break; break;
case SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS:
sof_ipc4_mtrace_update_pos(sdev, SOF_IPC4_LOG_CORE_GET(ipc4_msg->primary));
break;
default: default:
dev_dbg(sdev->dev, "Unhandled DSP message: %#x|%#x\n", dev_dbg(sdev->dev, "Unhandled DSP message: %#x|%#x\n",
ipc4_msg->primary, ipc4_msg->extension); ipc4_msg->primary, ipc4_msg->extension);
...@@ -662,4 +665,5 @@ const struct sof_ipc_ops ipc4_ops = { ...@@ -662,4 +665,5 @@ const struct sof_ipc_ops ipc4_ops = {
.fw_loader = &ipc4_loader_ops, .fw_loader = &ipc4_loader_ops,
.tplg = &ipc4_tplg_ops, .tplg = &ipc4_tplg_ops,
.pcm = &ipc4_pcm_ops, .pcm = &ipc4_pcm_ops,
.fw_tracing = &ipc4_mtrace_ops,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment