Skip to content

Commit 6f30848

Browse files
ujfalusiplbossart
authored andcommitted
ASoC: SOF: Switch to IPC generic firmware tracing
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 <peter.ujfalusi@linux.intel.com>
1 parent 95e8889 commit 6f30848

8 files changed

Lines changed: 44 additions & 615 deletions

File tree

sound/soc/sof/core.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,11 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
252252
if (sof_debug_check_flag(SOF_DBG_ENABLE_TRACE)) {
253253
sdev->fw_trace_is_supported = true;
254254

255-
/* init DMA trace */
256-
ret = snd_sof_init_trace(sdev);
255+
/* init firmware tracing */
256+
ret = sof_fw_trace_init(sdev);
257257
if (ret < 0) {
258258
/* non fatal */
259-
dev_warn(sdev->dev,
260-
"warning: failed to initialize trace %d\n",
259+
dev_warn(sdev->dev, "failed to initialize firmware tracing %d\n",
261260
ret);
262261
}
263262
} else {
@@ -308,7 +307,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
308307
sof_machine_err:
309308
snd_sof_machine_unregister(sdev, plat_data);
310309
fw_trace_err:
311-
snd_sof_free_trace(sdev);
310+
sof_fw_trace_free(sdev);
312311
fw_run_err:
313312
snd_sof_fw_unload(sdev);
314313
fw_load_err:
@@ -440,7 +439,7 @@ int snd_sof_device_remove(struct device *dev)
440439
snd_sof_machine_unregister(sdev, pdata);
441440

442441
if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) {
443-
snd_sof_free_trace(sdev);
442+
sof_fw_trace_free(sdev);
444443
ret = snd_sof_dsp_power_down_notify(sdev);
445444
if (ret < 0)
446445
dev_warn(dev, "error: %d failed to prepare DSP for device removal",

sound/soc/sof/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,6 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev)
444444
snd_sof_ipc_dump(sdev);
445445
snd_sof_dsp_dbg_dump(sdev, "Firmware exception",
446446
SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
447-
snd_sof_trace_notify_for_error(sdev);
447+
sof_fw_trace_fw_crashed(sdev);
448448
}
449449
EXPORT_SYMBOL(snd_sof_handle_fw_exception);

sound/soc/sof/ipc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
194194
return NULL;
195195
}
196196

197+
if (ops->fw_tracing && (!ops->fw_tracing->init || !ops->fw_tracing->suspend ||
198+
!ops->fw_tracing->resume)) {
199+
dev_err(sdev->dev, "Missing firmware tracing ops\n");
200+
return NULL;
201+
}
202+
197203
ipc->ops = ops;
198204

199205
return ipc;

sound/soc/sof/ipc3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static void ipc3_trace_message(struct snd_sof_dev *sdev, void *msg_buf)
946946

947947
switch (msg_type) {
948948
case SOF_IPC_TRACE_DMA_POSITION:
949-
snd_sof_trace_update_pos(sdev, msg_buf);
949+
ipc3_dtrace_posn_update(sdev, msg_buf);
950950
break;
951951
default:
952952
dev_err(sdev->dev, "unhandled trace message %#x\n", msg_type);

sound/soc/sof/ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void snd_sof_dsp_panic(struct snd_sof_dev *sdev, u32 offset, bool non_recoverabl
177177
snd_sof_dsp_dbg_dump(sdev, "DSP panic!",
178178
SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
179179
sof_set_fw_state(sdev, SOF_FW_CRASHED);
180-
snd_sof_trace_notify_for_error(sdev);
180+
sof_fw_trace_fw_crashed(sdev);
181181
} else {
182182
snd_sof_dsp_dbg_dump(sdev,
183183
"DSP panic (recovery will be attempted)",

sound/soc/sof/pm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
107107
*/
108108
if (!runtime_resume && sof_ops(sdev)->set_power_state &&
109109
old_state == SOF_DSP_PM_D0) {
110-
ret = snd_sof_trace_resume(sdev);
110+
ret = sof_fw_trace_resume(sdev);
111111
if (ret < 0)
112112
/* non fatal */
113113
dev_warn(sdev->dev,
@@ -143,7 +143,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
143143
}
144144

145145
/* resume DMA trace */
146-
ret = snd_sof_trace_resume(sdev);
146+
ret = sof_fw_trace_resume(sdev);
147147
if (ret < 0) {
148148
/* non fatal */
149149
dev_warn(sdev->dev,
@@ -208,7 +208,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
208208

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

220220
/* suspend DMA trace */
221-
snd_sof_trace_suspend(sdev, pm_state);
221+
sof_fw_trace_suspend(sdev, pm_state);
222222

223223
/* Notify clients not managed by pm framework about core suspend */
224224
sof_suspend_clients(sdev, pm_state);

sound/soc/sof/sof-priv.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,27 +660,26 @@ static inline void snd_sof_ipc_process_reply(struct snd_sof_dev *sdev, u32 msg_i
660660
/*
661661
* Trace/debug
662662
*/
663-
int snd_sof_init_trace(struct snd_sof_dev *sdev);
664-
void snd_sof_free_trace(struct snd_sof_dev *sdev);
665663
int snd_sof_dbg_init(struct snd_sof_dev *sdev);
666664
void snd_sof_free_debug(struct snd_sof_dev *sdev);
667665
int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
668666
void *base, size_t size,
669667
const char *name, mode_t mode);
670-
int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
671-
struct sof_ipc_dma_trace_posn *posn);
672-
void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev);
673668
void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level,
674669
u32 panic_code, u32 tracep_code, void *oops,
675670
struct sof_ipc_panic_info *panic_info,
676671
void *stack, size_t stack_words);
677-
void snd_sof_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state);
678-
int snd_sof_trace_resume(struct snd_sof_dev *sdev);
679672
void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev);
680673
int snd_sof_dbg_memory_info_init(struct snd_sof_dev *sdev);
681674
int snd_sof_debugfs_add_region_item_iomem(struct snd_sof_dev *sdev,
682675
enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
683676
const char *name, enum sof_debugfs_access_type access_type);
677+
/* Firmware tracing */
678+
int sof_fw_trace_init(struct snd_sof_dev *sdev);
679+
void sof_fw_trace_free(struct snd_sof_dev *sdev);
680+
void sof_fw_trace_fw_crashed(struct snd_sof_dev *sdev);
681+
void sof_fw_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state);
682+
int sof_fw_trace_resume(struct snd_sof_dev *sdev);
684683

685684
/*
686685
* DSP Architectures.

0 commit comments

Comments
 (0)