Commit 4995ffce authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

ASoC: SOF: Rename snd_sof_get_status() and add kernel log level parameter

The snd_sof_get_status() is not the best name for a function which in fact
is tasked to print out DSP oops and stack. Rename it to
sof_print_oops_and_stack().

At the same time add a new parameter to specify the desired kernel log
level to be used for the prints.

When updating the users of the function, pass KERN_ERR for now to make sure
that there is no functional change happens.
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 avatarChao Song <chao.song@intel.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20211223113628.18582-18-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent b9f0bfd1
......@@ -68,23 +68,33 @@ static const struct sof_panic_msg panic_msg[] = {
{SOF_IPC_PANIC_ASSERT, "assertion failed"},
};
/*
/**
* sof_print_oops_and_stack - Handle the printing of DSP oops and stack trace
* @sdev: Pointer to the device's sdev
* @level: prink log level to use for the printing
* @panic_code: the panic code
* @tracep_code: tracepoint code
* @oops: Pointer to DSP specific oops data
* @panic_info: Pointer to the received panic information message
* @stack: Pointer to the call stack data
* @stack_words: Number of words in the stack data
*
* helper to be called from .dbg_dump callbacks. No error code is
* provided, it's left as an exercise for the caller of .dbg_dump
* (typically IPC or loader)
*/
void snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
u32 tracep_code, void *oops,
struct sof_ipc_panic_info *panic_info,
void *stack, size_t stack_words)
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)
{
u32 code;
int i;
/* is firmware dead ? */
if ((panic_code & SOF_IPC_PANIC_MAGIC_MASK) != SOF_IPC_PANIC_MAGIC) {
dev_err(sdev->dev, "unexpected fault %#010x trace %#010x\n",
panic_code, tracep_code);
dev_printk(level, sdev->dev, "unexpected fault %#010x trace %#010x\n",
panic_code, tracep_code);
return; /* no fault ? */
}
......@@ -92,24 +102,25 @@ void snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
for (i = 0; i < ARRAY_SIZE(panic_msg); i++) {
if (panic_msg[i].id == code) {
dev_err(sdev->dev, "reason: %s (%#x)\n", panic_msg[i].msg,
code & SOF_IPC_PANIC_CODE_MASK);
dev_err(sdev->dev, "trace point: %#010x\n", tracep_code);
dev_printk(level, sdev->dev, "reason: %s (%#x)\n",
panic_msg[i].msg, code & SOF_IPC_PANIC_CODE_MASK);
dev_printk(level, sdev->dev, "trace point: %#010x\n", tracep_code);
goto out;
}
}
/* unknown error */
dev_err(sdev->dev, "unknown panic code: %#x\n", code & SOF_IPC_PANIC_CODE_MASK);
dev_err(sdev->dev, "trace point: %#010x\n", tracep_code);
dev_printk(level, sdev->dev, "unknown panic code: %#x\n",
code & SOF_IPC_PANIC_CODE_MASK);
dev_printk(level, sdev->dev, "trace point: %#010x\n", tracep_code);
out:
dev_err(sdev->dev, "panic at %s:%d\n", panic_info->filename,
panic_info->linenum);
sof_oops(sdev, KERN_ERR, oops);
sof_stack(sdev, KERN_ERR, oops, stack, stack_words);
dev_printk(level, sdev->dev, "panic at %s:%d\n", panic_info->filename,
panic_info->linenum);
sof_oops(sdev, level, oops);
sof_stack(sdev, level, oops, stack, stack_words);
}
EXPORT_SYMBOL(snd_sof_get_status);
EXPORT_SYMBOL(sof_print_oops_and_stack);
/*
* FW Boot State Transition Diagram
......
......@@ -69,8 +69,8 @@ void imx8_dump(struct snd_sof_dev *sdev, u32 flags)
IMX8_STACK_DUMP_SIZE);
/* Print the information to the console */
snd_sof_get_status(sdev, status, status, &xoops, &panic_info, stack,
IMX8_STACK_DUMP_SIZE);
sof_print_oops_and_stack(sdev, KERN_ERR, status, status, &xoops,
&panic_info, stack, IMX8_STACK_DUMP_SIZE);
}
EXPORT_SYMBOL(imx8_dump);
......
......@@ -70,8 +70,8 @@ void atom_dump(struct snd_sof_dev *sdev, u32 flags)
panic = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IPCX);
atom_get_registers(sdev, &xoops, &panic_info, stack,
STACK_DUMP_SIZE);
snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, stack,
STACK_DUMP_SIZE);
sof_print_oops_and_stack(sdev, KERN_ERR, status, panic, &xoops,
&panic_info, stack, STACK_DUMP_SIZE);
/* provide some context for firmware debug */
imrx = snd_sof_dsp_read64(sdev, DSP_BAR, SHIM_IMRX);
......
......@@ -258,8 +258,8 @@ static void bdw_dump(struct snd_sof_dev *sdev, u32 flags)
panic = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCX);
bdw_get_registers(sdev, &xoops, &panic_info, stack,
BDW_STACK_DUMP_SIZE);
snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, stack,
BDW_STACK_DUMP_SIZE);
sof_print_oops_and_stack(sdev, KERN_ERR, status, panic, &xoops,
&panic_info, stack, BDW_STACK_DUMP_SIZE);
/* provide some context for firmware debug */
imrx = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IMRX);
......
......@@ -554,8 +554,8 @@ void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags)
hda_dsp_get_registers(sdev, &xoops, &panic_info, stack,
HDA_DSP_STACK_DUMP_SIZE);
snd_sof_get_status(sdev, status, panic, &xoops, &panic_info,
stack, HDA_DSP_STACK_DUMP_SIZE);
sof_print_oops_and_stack(sdev, KERN_ERR, status, panic, &xoops,
&panic_info, stack, HDA_DSP_STACK_DUMP_SIZE);
} else {
hda_dsp_dump_ext_rom_status(sdev, flags);
}
......
......@@ -559,10 +559,10 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
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 snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
u32 tracep_code, void *oops,
struct sof_ipc_panic_info *panic_info,
void *stack, size_t stack_words);
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);
int snd_sof_init_trace_ipc(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);
......
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