Commit f0e7e9ed authored by Dmitry Baryshkov's avatar Dmitry Baryshkov

drm/msm/dsi: fix error checks and return values for DSI xmit functions

As noticed by Dan ([1] an the followup thread) there are multiple issues
with the return values for MSM DSI command transmission callback. In
the error case it can easily return a positive value when it should
have returned a proper error code.

This commits attempts to fix these issues both in TX and in RX paths.

[1]: https://lore.kernel.org/linux-arm-msm/20211001123617.GH2283@kili/

Fixes: a689554b ("drm/msm: Initial add DSI connector support")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
Tested-by: default avatarMarijn Suijten <marijn.suijten@somainline.org>
Patchwork: https://patchwork.freedesktop.org/patch/480501/
Link: https://lore.kernel.org/r/20220401231104.967193-1-dmitry.baryshkov@linaro.orgSigned-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
parent 2788b4ef
...@@ -1440,10 +1440,10 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, ...@@ -1440,10 +1440,10 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host,
dsi_get_bpp(msm_host->format) / 8; dsi_get_bpp(msm_host->format) / 8;
len = dsi_cmd_dma_add(msm_host, msg); len = dsi_cmd_dma_add(msm_host, msg);
if (!len) { if (len < 0) {
pr_err("%s: failed to add cmd type = 0x%x\n", pr_err("%s: failed to add cmd type = 0x%x\n",
__func__, msg->type); __func__, msg->type);
return -EINVAL; return len;
} }
/* for video mode, do not send cmds more than /* for video mode, do not send cmds more than
...@@ -1462,10 +1462,14 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, ...@@ -1462,10 +1462,14 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host,
} }
ret = dsi_cmd_dma_tx(msm_host, len); ret = dsi_cmd_dma_tx(msm_host, len);
if (ret < len) { if (ret < 0) {
pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, len=%d\n", pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, len=%d, ret=%d\n",
__func__, msg->type, (*(u8 *)(msg->tx_buf)), len); __func__, msg->type, (*(u8 *)(msg->tx_buf)), len, ret);
return -ECOMM; return ret;
} else if (ret < len) {
pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, ret=%d len=%d\n",
__func__, msg->type, (*(u8 *)(msg->tx_buf)), ret, len);
return -EIO;
} }
return len; return len;
...@@ -2333,9 +2337,12 @@ int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host, ...@@ -2333,9 +2337,12 @@ int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
} }
ret = dsi_cmds2buf_tx(msm_host, msg); ret = dsi_cmds2buf_tx(msm_host, msg);
if (ret < msg->tx_len) { if (ret < 0) {
pr_err("%s: Read cmd Tx failed, %d\n", __func__, ret); pr_err("%s: Read cmd Tx failed, %d\n", __func__, ret);
return ret; return ret;
} else if (ret < msg->tx_len) {
pr_err("%s: Read cmd Tx failed, too short: %d\n", __func__, ret);
return -ECOMM;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment