From: Srinivas Kandagatla Date: Wed, 26 Oct 2022 11:02:06 +0000 (+0100) Subject: soundwire: qcom: check for outanding writes before doing a read X-Git-Tag: v6.0.9~172 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e06803e9ffd36ae3628f16dfc29f51317ab1a4f;p=thirdparty%2Fkernel%2Fstable.git soundwire: qcom: check for outanding writes before doing a read [ Upstream commit 49a467310dc4fae591a3547860ee04d8730780f4 ] Reading will increase the fifo count, so check for outstanding cmd wrt. write fifo depth to avoid overflow as read will also increase write fifo cnt. Fixes: a661308c34de ("soundwire: qcom: wait for fifo space to be available before read/write") Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20221026110210.6575-3-srinivas.kandagatla@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 87ccaebc8453a..6e5990611d834 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -380,6 +380,12 @@ static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *swrm, val = swrm_get_packed_reg_val(&swrm->rcmd_id, len, dev_addr, reg_addr); + /* + * Check for outstanding cmd wrt. write fifo depth to avoid + * overflow as read will also increase write fifo cnt. + */ + swrm_wait_for_wr_fifo_avail(swrm); + /* wait for FIFO RD to complete to avoid overflow */ usleep_range(100, 105); swrm->reg_write(swrm, SWRM_CMD_FIFO_RD_CMD, val);