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>
(cherry picked from commit caabdfa176)
This commit is contained in:
@ -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++;
|
||||
|
||||
@ -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];
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user