Skip to content

Commit

Permalink
ASoC: SOF: Switch to IPC generic firmware tracing
Browse files Browse the repository at this point in the history
Introduce new, generic API for firmware tracing with sof_fw_trace_ prefix
and switch to use it.
At the same time the old IPC3 code can be dropped from trace.c, which is
now a generic wrapper for the firmware tracing ops.

Signed-off-by: Peter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Reviewed-by: Bard Liao <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
ujfalusi authored and broonie committed May 19, 2022
1 parent 671e0b9 commit 1dedbe4
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 615 deletions.
11 changes: 5 additions & 6 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
if (sof_debug_check_flag(SOF_DBG_ENABLE_TRACE)) {
sdev->fw_trace_is_supported = true;

/* init DMA trace */
ret = snd_sof_init_trace(sdev);
/* init firmware tracing */
ret = sof_fw_trace_init(sdev);
if (ret < 0) {
/* non fatal */
dev_warn(sdev->dev,
"warning: failed to initialize trace %d\n",
dev_warn(sdev->dev, "failed to initialize firmware tracing %d\n",
ret);
}
} else {
Expand Down Expand Up @@ -308,7 +307,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
sof_machine_err:
snd_sof_machine_unregister(sdev, plat_data);
fw_trace_err:
snd_sof_free_trace(sdev);
sof_fw_trace_free(sdev);
fw_run_err:
snd_sof_fw_unload(sdev);
fw_load_err:
Expand Down Expand Up @@ -447,7 +446,7 @@ int snd_sof_device_remove(struct device *dev)
snd_sof_machine_unregister(sdev, pdata);

if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) {
snd_sof_free_trace(sdev);
sof_fw_trace_free(sdev);
ret = snd_sof_dsp_power_down_notify(sdev);
if (ret < 0)
dev_warn(dev, "error: %d failed to prepare DSP for device removal",
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,6 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev)
snd_sof_ipc_dump(sdev);
snd_sof_dsp_dbg_dump(sdev, "Firmware exception",
SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
snd_sof_trace_notify_for_error(sdev);
sof_fw_trace_fw_crashed(sdev);
}
EXPORT_SYMBOL(snd_sof_handle_fw_exception);
6 changes: 6 additions & 0 deletions sound/soc/sof/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
return NULL;
}

if (ops->fw_tracing && (!ops->fw_tracing->init || !ops->fw_tracing->suspend ||
!ops->fw_tracing->resume)) {
dev_err(sdev->dev, "Missing firmware tracing ops\n");
return NULL;
}

return ipc;
}
EXPORT_SYMBOL(snd_sof_ipc_init);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ static void ipc3_trace_message(struct snd_sof_dev *sdev, void *msg_buf)

switch (msg_type) {
case SOF_IPC_TRACE_DMA_POSITION:
snd_sof_trace_update_pos(sdev, msg_buf);
ipc3_dtrace_posn_update(sdev, msg_buf);
break;
default:
dev_err(sdev->dev, "unhandled trace message %#x\n", msg_type);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void snd_sof_dsp_panic(struct snd_sof_dev *sdev, u32 offset, bool non_recoverabl
snd_sof_dsp_dbg_dump(sdev, "DSP panic!",
SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
sof_set_fw_state(sdev, SOF_FW_CRASHED);
snd_sof_trace_notify_for_error(sdev);
sof_fw_trace_fw_crashed(sdev);
} else {
snd_sof_dsp_dbg_dump(sdev,
"DSP panic (recovery will be attempted)",
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/sof/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
*/
if (!runtime_resume && sof_ops(sdev)->set_power_state &&
old_state == SOF_DSP_PM_D0) {
ret = snd_sof_trace_resume(sdev);
ret = sof_fw_trace_resume(sdev);
if (ret < 0)
/* non fatal */
dev_warn(sdev->dev,
Expand Down Expand Up @@ -143,7 +143,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
}

/* resume DMA trace */
ret = snd_sof_trace_resume(sdev);
ret = sof_fw_trace_resume(sdev);
if (ret < 0) {
/* non fatal */
dev_warn(sdev->dev,
Expand Down Expand Up @@ -208,7 +208,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)

/* Skip to platform-specific suspend if DSP is entering D0 */
if (target_state == SOF_DSP_PM_D0) {
snd_sof_trace_suspend(sdev, pm_state);
sof_fw_trace_suspend(sdev, pm_state);
/* Notify clients not managed by pm framework about core suspend */
sof_suspend_clients(sdev, pm_state);
goto suspend;
Expand All @@ -218,7 +218,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
tplg_ops->tear_down_all_pipelines(sdev, false);

/* suspend DMA trace */
snd_sof_trace_suspend(sdev, pm_state);
sof_fw_trace_suspend(sdev, pm_state);

/* Notify clients not managed by pm framework about core suspend */
sof_suspend_clients(sdev, pm_state);
Expand Down
13 changes: 6 additions & 7 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,27 +660,26 @@ static inline void snd_sof_ipc_process_reply(struct snd_sof_dev *sdev, u32 msg_i
/*
* Trace/debug
*/
int snd_sof_init_trace(struct snd_sof_dev *sdev);
void snd_sof_free_trace(struct snd_sof_dev *sdev);
int snd_sof_dbg_init(struct snd_sof_dev *sdev);
void snd_sof_free_debug(struct snd_sof_dev *sdev);
int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
void *base, size_t size,
const char *name, mode_t mode);
int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
struct sof_ipc_dma_trace_posn *posn);
void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev);
void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level,
u32 panic_code, u32 tracep_code, void *oops,
struct sof_ipc_panic_info *panic_info,
void *stack, size_t stack_words);
void snd_sof_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state);
int snd_sof_trace_resume(struct snd_sof_dev *sdev);
void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev);
int snd_sof_dbg_memory_info_init(struct snd_sof_dev *sdev);
int snd_sof_debugfs_add_region_item_iomem(struct snd_sof_dev *sdev,
enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
const char *name, enum sof_debugfs_access_type access_type);
/* Firmware tracing */
int sof_fw_trace_init(struct snd_sof_dev *sdev);
void sof_fw_trace_free(struct snd_sof_dev *sdev);
void sof_fw_trace_fw_crashed(struct snd_sof_dev *sdev);
void sof_fw_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state);
int sof_fw_trace_resume(struct snd_sof_dev *sdev);

/*
* DSP Architectures.
Expand Down
Loading

0 comments on commit 1dedbe4

Please sign in to comment.