summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2019-04-01 16:40:57 +0800
committerShengjiu Wang <shengjiu.wang@nxp.com>2019-04-12 17:35:10 +0800
commitcaabdfa176453cc7c8d6521f7865a670a7265a18 (patch)
treea5d388639a22eae950a0bc588ced519da478386f /sound
parent58ffdf239288cfa6904640fc8432c182cf56589b (diff)
MLK-21307: ASoC: fsl_rpmsg_i2s: optimize the message sent to m4
M4 complain that there are two much period done message sent to m4, that M4 don't have enough time to handle these messages. The solution for this issue is to reduce the number of period done message. We allocate a specific memory for period done message, every time there is period done coming, it will be writed to this memory, not write it directly to the work queue, that queue will not be overflow, and the old period done message will be overwrited. In the rpmsg_i2s_work, we first check if there is period done message, then send it first, after that, send the command in queue. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/fsl/fsl_rpmsg_i2s.c10
-rw-r--r--sound/soc/fsl/fsl_rpmsg_i2s.h2
-rw-r--r--sound/soc/fsl/imx-pcm-rpmsg.c13
3 files changed, 15 insertions, 10 deletions
diff --git a/sound/soc/fsl/fsl_rpmsg_i2s.c b/sound/soc/fsl/fsl_rpmsg_i2s.c
index 1aa46e4968d9..f43890a364cd 100644
--- a/sound/soc/fsl/fsl_rpmsg_i2s.c
+++ b/sound/soc/fsl/fsl_rpmsg_i2s.c
@@ -148,6 +148,16 @@ static void rpmsg_i2s_work(struct work_struct *work)
work_of_rpmsg = container_of(work, struct work_of_rpmsg, work);
i2s_info = work_of_rpmsg->i2s_info;
+ if (i2s_info->period_done_msg_enabled[0]) {
+ i2s_send_message(&i2s_info->period_done_msg[0], i2s_info);
+ i2s_info->period_done_msg_enabled[0] = false;
+ }
+
+ if (i2s_info->period_done_msg_enabled[1]) {
+ i2s_send_message(&i2s_info->period_done_msg[1], i2s_info);
+ i2s_info->period_done_msg_enabled[1] = false;
+ }
+
i2s_send_message(&work_of_rpmsg->msg, i2s_info);
i2s_info->work_read_index++;
diff --git a/sound/soc/fsl/fsl_rpmsg_i2s.h b/sound/soc/fsl/fsl_rpmsg_i2s.h
index 14922f1a7690..cd0badb562f2 100644
--- a/sound/soc/fsl/fsl_rpmsg_i2s.h
+++ b/sound/soc/fsl/fsl_rpmsg_i2s.h
@@ -394,6 +394,8 @@ struct i2s_info {
struct i2s_rpmsg_r recv_msg;
struct i2s_rpmsg rpmsg[I2S_CMD_MAX_NUM];
+ struct i2s_rpmsg period_done_msg[2];
+ bool period_done_msg_enabled[2];
struct workqueue_struct *rpmsg_wq;
struct work_of_rpmsg work_list[WORK_MAX_NUM];
diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
index 1cbdf4215c11..2a89f9371edb 100644
--- a/sound/soc/fsl/imx-pcm-rpmsg.c
+++ b/sound/soc/fsl/imx-pcm-rpmsg.c
@@ -577,7 +577,6 @@ int imx_rpmsg_pcm_ack(struct snd_pcm_substream *substream)
struct fsl_rpmsg_i2s *rpmsg_i2s = dev_get_drvdata(cpu_dai->dev);
struct i2s_info *i2s_info = &rpmsg_i2s->i2s_info;
struct i2s_rpmsg *rpmsg;
- int index = i2s_info->work_write_index;
int buffer_tail = 0;
if (!rpmsg_i2s->force_lpa)
@@ -601,15 +600,9 @@ int imx_rpmsg_pcm_ack(struct snd_pcm_substream *substream)
if (buffer_tail != rpmsg->send_msg.param.buffer_tail) {
rpmsg->send_msg.param.buffer_tail = buffer_tail;
- if (i2s_info->work_write_index != i2s_info->work_read_index) {
- memcpy(&i2s_info->work_list[index].msg, rpmsg,
- sizeof(struct i2s_rpmsg_s));
- queue_work(i2s_info->rpmsg_wq,
- &i2s_info->work_list[index].work);
- i2s_info->work_write_index++;
- i2s_info->work_write_index %= WORK_MAX_NUM;
- } else
- i2s_info->msg_drop_count[substream->stream]++;
+ memcpy(&i2s_info->period_done_msg[substream->stream], rpmsg,
+ sizeof(struct i2s_rpmsg_s));
+ i2s_info->period_done_msg_enabled[substream->stream] = true;
}
return 0;