diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 87e9c86ca4f885..caf1cff3ea39ac 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -35,7 +35,7 @@ int snd_soc_ret(const struct device *dev, int ret, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - dev_err(dev, "ASoC error (%d): %pV", ret, &vaf); + dev_err_ratelimited(dev, "ASoC error (%d): %pV", ret, &vaf); va_end(args); } diff --git a/sound/soc/sof/ipc3-pcm.c b/sound/soc/sof/ipc3-pcm.c index b95e888c0adb84..4e6fe714a246eb 100644 --- a/sound/soc/sof/ipc3-pcm.c +++ b/sound/soc/sof/ipc3-pcm.c @@ -119,9 +119,9 @@ static int sof_ipc3_pcm_hw_params(struct snd_soc_component *component, ret = sof_ipc_tx_message(sdev->ipc, &pcm, sizeof(pcm), &ipc_params_reply, sizeof(ipc_params_reply)); if (ret < 0) { - spcm_err(spcm, substream->stream, - "STREAM_PCM_PARAMS ipc failed for stream_tag %d\n", - pcm.params.stream_tag); + spcm_err_ratelimited(spcm, substream->stream, + "STREAM_PCM_PARAMS ipc failed for stream_tag %d\n", + pcm.params.stream_tag); return ret; } diff --git a/sound/soc/sof/ipc3.c b/sound/soc/sof/ipc3.c index 85bb22bbe18d08..235ebac1731b7f 100644 --- a/sound/soc/sof/ipc3.c +++ b/sound/soc/sof/ipc3.c @@ -298,17 +298,17 @@ static int ipc3_wait_tx_done(struct snd_sof_ipc *ipc, void *reply_data) msecs_to_jiffies(sdev->ipc_timeout)); if (ret == 0) { - dev_err(sdev->dev, - "ipc tx timed out for %#x (msg/reply size: %d/%zu)\n", - hdr->cmd, hdr->size, msg->reply_size); + dev_err_ratelimited(sdev->dev, + "ipc tx timed out for %#x (msg/reply size: %d/%zu)\n", + hdr->cmd, hdr->size, msg->reply_size); snd_sof_handle_fw_exception(ipc->sdev, "IPC timeout"); ret = -ETIMEDOUT; } else { ret = msg->reply_error; if (ret < 0) { - dev_err(sdev->dev, - "ipc tx error for %#x (msg/reply size: %d/%zu): %d\n", - hdr->cmd, hdr->size, msg->reply_size, ret); + dev_err_ratelimited(sdev->dev, + "ipc tx error for %#x (msg/reply size: %d/%zu): %d\n", + hdr->cmd, hdr->size, msg->reply_size, ret); } else { if (sof_debug_check_flag(SOF_DBG_PRINT_IPC_SUCCESS_LOGS)) ipc3_log_header(sdev->dev, "ipc tx succeeded", hdr->cmd); @@ -371,8 +371,9 @@ static int sof_ipc3_tx_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_ /* ensure the DSP is in D0 before sending a new IPC */ ret = snd_sof_dsp_set_power_state(sdev, &target_state); if (ret < 0) { - dev_err(sdev->dev, "%s: resuming DSP failed: %d\n", - __func__, ret); + dev_err_ratelimited(sdev->dev, + "%s: resuming DSP failed: %d\n", + __func__, ret); return ret; } } diff --git a/sound/soc/sof/ipc4.c b/sound/soc/sof/ipc4.c index bf3a122ee651e8..a07b9d874257a0 100644 --- a/sound/soc/sof/ipc4.c +++ b/sound/soc/sof/ipc4.c @@ -412,15 +412,15 @@ static int ipc4_wait_tx_done(struct snd_sof_ipc *ipc, void *reply_data) ret = wait_event_timeout(msg->waitq, msg->ipc_complete, msecs_to_jiffies(sdev->ipc_timeout)); if (ret == 0) { - dev_err(sdev->dev, "ipc timed out for %#x|%#x\n", - ipc4_msg->primary, ipc4_msg->extension); + dev_err_ratelimited(sdev->dev, "ipc timed out for %#x|%#x\n", + ipc4_msg->primary, ipc4_msg->extension); snd_sof_handle_fw_exception(ipc->sdev, "IPC timeout"); return -ETIMEDOUT; } if (msg->reply_error) { - dev_err(sdev->dev, "ipc error for msg %#x|%#x\n", - ipc4_msg->primary, ipc4_msg->extension); + dev_err_ratelimited(sdev->dev, "ipc error for msg %#x|%#x\n", + ipc4_msg->primary, ipc4_msg->extension); ret = msg->reply_error; } else { if (reply_data) { diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 0161c0ae8bbdb4..ac411ecec0bc35 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -90,7 +90,7 @@ sof_pcm_setup_connected_widgets(struct snd_sof_dev *sdev, struct snd_soc_pcm_run ret = sof_widget_list_prepare(sdev, spcm, params, platform_params, dir); if (ret < 0) { - spcm_err(spcm, dir, "widget list prepare failed\n"); + spcm_err_ratelimited(spcm, dir, "widget list prepare failed\n"); spcm->stream[dir].list = NULL; snd_soc_dapm_dai_free_widgets(&list); return ret; @@ -162,7 +162,8 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, platform_params = &spcm->platform_params[substream->stream]; ret = snd_sof_pcm_platform_hw_params(sdev, substream, params, platform_params); if (ret < 0) { - spcm_err(spcm, substream->stream, "platform hw params failed\n"); + spcm_err_ratelimited(spcm, substream->stream, + "platform hw params failed\n"); return ret; } @@ -179,8 +180,9 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, host_widget = snd_sof_find_swidget_by_comp_id(sdev, host_comp_id); if (!host_widget) { - spcm_err(spcm, substream->stream, - "failed to find host widget with comp_id %d\n", host_comp_id); + spcm_err_ratelimited(spcm, substream->stream, + "failed to find host widget with comp_id %d\n", + host_comp_id); return -EINVAL; } @@ -226,8 +228,8 @@ static int sof_pcm_stream_free(struct snd_sof_dev *sdev, ret = pcm_ops->hw_free(sdev->component, substream, spcm, substream->stream); if (ret < 0) { - spcm_err(spcm, substream->stream, - "pcm_ops->hw_free failed %d\n", ret); + spcm_err_ratelimited(spcm, substream->stream, + "pcm_ops->hw_free failed %d\n", ret); err = ret; } } @@ -239,8 +241,8 @@ static int sof_pcm_stream_free(struct snd_sof_dev *sdev, /* reset the DMA */ ret = snd_sof_pcm_platform_hw_free(sdev, substream); if (ret < 0) { - spcm_err(spcm, substream->stream, - "platform hw free failed %d\n", ret); + spcm_err_ratelimited(spcm, substream->stream, + "platform hw free failed %d\n", ret); if (!err) err = ret; } @@ -249,8 +251,8 @@ static int sof_pcm_stream_free(struct snd_sof_dev *sdev, if (free_widget_list) { ret = sof_widget_list_free(sdev, spcm, dir); if (ret < 0) { - spcm_err(spcm, substream->stream, - "sof_widget_list_free failed %d\n", ret); + spcm_err_ratelimited(spcm, substream->stream, + "sof_widget_list_free failed %d\n", ret); if (!err) err = ret; } @@ -351,8 +353,8 @@ static int sof_pcm_prepare(struct snd_soc_component *component, ret = sof_pcm_hw_params(component, substream, &spcm->params[substream->stream]); if (ret < 0) { - spcm_err(spcm, substream->stream, - "failed to set hw_params after resume\n"); + spcm_err_ratelimited(spcm, substream->stream, + "failed to set hw_params after resume\n"); return ret; } @@ -361,8 +363,9 @@ static int sof_pcm_prepare(struct snd_soc_component *component, platform_params = &spcm->platform_params[substream->stream]; ret = sof_widget_list_setup(sdev, spcm, params, platform_params, dir); if (ret < 0) { - dev_err(sdev->dev, "failed widget list set up for pcm %d dir %u\n", - le32_to_cpu(spcm->pcm.pcm_id), dir); + dev_err_ratelimited(sdev->dev, + "failed widget list set up for pcm %d dir %u\n", + le32_to_cpu(spcm->pcm.pcm_id), dir); spcm->stream[dir].list = NULL; snd_soc_dapm_dai_free_widgets(&list); return ret; diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 10b41ab18b7990..feb1311bdd869a 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -668,6 +668,12 @@ struct snd_sof_widget *snd_sof_find_swidget_by_comp_id(struct snd_sof_dev *sdev, (__spcm)->pcm.pcm_name, __dir, \ ##__VA_ARGS__) +#define spcm_err_ratelimited(__spcm, __dir, __fmt, ...) \ + dev_err_ratelimited((__spcm)->scomp->dev, "%s: pcm%u (%s), dir %d: " __fmt, \ + __func__, le32_to_cpu((__spcm)->pcm.pcm_id), \ + (__spcm)->pcm.pcm_name, __dir, \ + ##__VA_ARGS__) + #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS) void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream); void snd_sof_compr_init_elapsed_work(struct work_struct *work);