From 5936ba71aab27bee3505f70c0a79f6d4a0253295 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Tue, 13 Oct 2020 17:32:14 +0530 Subject: [PATCH] soc: swr-mstr: Resolve swr overflow, underflow errors for wsa SWR overflow, underflow interrupts are seen sometimes on bootup. Check whether devnum is 0 during fifo read and write. Also assign read and write fifo depth before master init to resolve errors. Change-Id: Id7b687985e320396d2f9dab69db56cc7f5426b04 Signed-off-by: Vatsal Bucha --- soc/swr-mstr-ctrl.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index 6e9b7c1eec01..51448f3cbf3c 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -887,6 +887,11 @@ static int swrm_cmd_fifo_rd_cmd(struct swr_mstr_ctrl *swrm, int *cmd_data, u32 val; u32 retry_attempt = 0; + if (!dev_addr) { + dev_err(swrm->dev, "%s: invalid slave dev num\n", __func__); + return -EINVAL; + } + mutex_lock(&swrm->iolock); val = swrm_get_packed_reg_val(&swrm->rcmd_id, len, dev_addr, reg_addr); if (swrm->read) { @@ -942,6 +947,11 @@ static int swrm_cmd_fifo_wr_cmd(struct swr_mstr_ctrl *swrm, u8 cmd_data, u32 val; int ret = 0; + if (!dev_addr) { + dev_err(swrm->dev, "%s: invalid slave dev num\n", __func__); + return -EINVAL; + } + mutex_lock(&swrm->iolock); if (!cmd_id) val = swrm_get_packed_reg_val(&swrm->wcmd_id, cmd_data, @@ -2883,6 +2893,10 @@ static int swrm_probe(struct platform_device *pdev) mutex_lock(&swrm->mlock); swrm_clk_request(swrm, true); swrm->version = swr_master_read(swrm, SWRM_COMP_HW_VERSION); + swrm->rd_fifo_depth = ((swr_master_read(swrm, SWRM_COMP_PARAMS) + & SWRM_COMP_PARAMS_RD_FIFO_DEPTH) >> 15); + swrm->wr_fifo_depth = ((swr_master_read(swrm, SWRM_COMP_PARAMS) + & SWRM_COMP_PARAMS_WR_FIFO_DEPTH) >> 10); ret = swrm_master_init(swrm); if (ret < 0) { dev_err(&pdev->dev, @@ -2899,11 +2913,6 @@ static int swrm_probe(struct platform_device *pdev) if (pdev->dev.of_node) of_register_swr_devices(&swrm->master); - swrm->rd_fifo_depth = ((swr_master_read(swrm, SWRM_COMP_PARAMS) - & SWRM_COMP_PARAMS_RD_FIFO_DEPTH) >> 15); - swrm->wr_fifo_depth = ((swr_master_read(swrm, SWRM_COMP_PARAMS) - & SWRM_COMP_PARAMS_WR_FIFO_DEPTH) >> 10); - #ifdef CONFIG_DEBUG_FS swrm->debugfs_swrm_dent = debugfs_create_dir(dev_name(&pdev->dev), 0); if (!IS_ERR(swrm->debugfs_swrm_dent)) {