From: Shengjiu Wang Date: Tue, 16 Apr 2019 07:17:06 +0000 (+0800) Subject: MLK-21461: ASoC: fsl_rpmsg_i2s: clear buffer pointer in i2s_send_message X-Git-Tag: rel_imx_4.19.35_1.1.0~774 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=edbbcdc07bf154df7fde5b989623bf13e3962c11;p=linux.git MLK-21461: ASoC: fsl_rpmsg_i2s: clear buffer pointer in i2s_send_message Reset the buffer pointer to be zero in i2s_send_message, actully we have set the buffer pointer to be zero in imx_rpmsg_terminate_all. But if there is timer task (I2S_TX_POINTER) queued in queue, after it is executed the buffer pointer will be changed, this is timing issue that the task in the queue is delayed. so need to reset it with TERMINATE command. Signed-off-by: Shengjiu Wang (cherry picked from commit 0a07dd454cbf85744677812e53fc5e86a48706bf) --- diff --git a/sound/soc/fsl/fsl_rpmsg_i2s.c b/sound/soc/fsl/fsl_rpmsg_i2s.c index 5a82340c2d6d..5db47a3a3e6d 100644 --- a/sound/soc/fsl/fsl_rpmsg_i2s.c +++ b/sound/soc/fsl/fsl_rpmsg_i2s.c @@ -70,6 +70,25 @@ static int i2s_send_message(struct i2s_rpmsg *msg, sizeof(struct i2s_rpmsg_r)); memcpy(&info->rpmsg[msg->recv_msg.header.cmd].recv_msg, &msg->recv_msg, sizeof(struct i2s_rpmsg_r)); + + /* + * Reset the buffer pointer to be zero, actully we have + * set the buffer pointer to be zero in imx_rpmsg_terminate_all + * But if there is timer task queued in queue, after it is + * executed the buffer pointer will be changed, so need to + * reset it again with TERMINATE command. + */ + + switch (msg->send_msg.header.cmd) { + case I2S_TX_TERMINATE: + info->rpmsg[I2S_TX_POINTER].recv_msg.param.buffer_offset = 0; + break; + case I2S_RX_TERMINATE: + info->rpmsg[I2S_RX_POINTER].recv_msg.param.buffer_offset = 0; + break; + default: + break; + } } dev_dbg(&info->rpdev->dev, "cmd:%d, resp %d\n",