From 04e2774ee8d8f9b5fad0858f620ffedc38fa6541 Mon Sep 17 00:00:00 2001 From: Mukesh Kumar Savaliya Date: Fri, 2 Oct 2020 02:00:14 +0530 Subject: [PATCH 1/2] i3c: i3c-master-qcom-geni: Save master device info to debug list This change stores each probed master device to the global device list. This will help to debug and know the master device information easily. Change-Id: I1987aa54f1b24280a3b6a2436bbe1e5deccb8b6e Signed-off-by: Mukesh Kumar Savaliya --- drivers/i3c/master/i3c-master-qcom-geni.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master/i3c-master-qcom-geni.c b/drivers/i3c/master/i3c-master-qcom-geni.c index 8bc2bb6ec334..800c1ad73a10 100644 --- a/drivers/i3c/master/i3c-master-qcom-geni.c +++ b/drivers/i3c/master/i3c-master-qcom-geni.c @@ -208,6 +208,8 @@ enum geni_i3c_err_code { #define IBI_SW_RESET_MIN_SLEEP 1000 #define IBI_SW_RESET_MAX_SLEEP 2000 +#define MAX_I3C_SE 2 + enum i3c_trans_dir { WRITE_TRANSACTION = 0, READ_TRANSACTION = 1 @@ -328,6 +330,9 @@ struct geni_i3c_clk_fld { static void geni_i3c_enable_ibi_ctrl(struct geni_i3c_dev *gi3c, bool enable); static void geni_i3c_enable_ibi_irq(struct geni_i3c_dev *gi3c, bool enable); +static struct geni_i3c_dev *i3c_geni_dev[MAX_I3C_SE]; +static int i3c_nos; + static struct geni_i3c_dev* to_geni_i3c_master(struct i3c_master_controller *master) { @@ -1996,6 +2001,9 @@ static int geni_i3c_probe(struct platform_device *pdev) if (!gi3c->ipcl) dev_info(&pdev->dev, "Error creating IPC Log\n"); + if (i3c_nos < MAX_I3C_SE) + i3c_geni_dev[i3c_nos++] = gi3c; + ret = i3c_geni_rsrcs_init(gi3c, pdev); if (ret) { GENI_SE_ERR(gi3c->ipcl, false, gi3c->se.dev, @@ -2117,7 +2125,7 @@ static int geni_i3c_probe(struct platform_device *pdev) static int geni_i3c_remove(struct platform_device *pdev) { struct geni_i3c_dev *gi3c = platform_get_drvdata(pdev); - int ret = 0; + int ret = 0, i; //Disable hot-join, until next probe happens geni_i3c_enable_hotjoin_irq(gi3c, false); @@ -2143,6 +2151,11 @@ static int geni_i3c_remove(struct platform_device *pdev) /* TBD : If we need debug for previous session, Don't delete logs */ if (gi3c->ipcl) ipc_log_context_destroy(gi3c->ipcl); + + for (i = 0; i < i3c_nos; i++) + i3c_geni_dev[i] = NULL; + i3c_nos = 0; + return ret; } From d9fc9718f5db6efaeccb29693e169f13796f23f0 Mon Sep 17 00:00:00 2001 From: Mukesh Kumar Savaliya Date: Fri, 9 Oct 2020 00:12:11 +0530 Subject: [PATCH 2/2] i3c: i3c-master-qcom-geni: Handle timeout for DMA FSM reset This change adds timeout handling scenario for the DMA TX/TX reset sequence and adds the proper error logs. If return value from API wait_for_completion_timeout() is not taken cared, may mislead the debug. Also Fix the issue of not initializing the completion variable during command execution time. Change-Id: I01442e611ea531bbd6124c0b5f4b6c8da9c79281 Signed-off-by: Mukesh Kumar Savaliya --- drivers/i3c/master/i3c-master-qcom-geni.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/i3c-master-qcom-geni.c b/drivers/i3c/master/i3c-master-qcom-geni.c index 800c1ad73a10..12b864485060 100644 --- a/drivers/i3c/master/i3c-master-qcom-geni.c +++ b/drivers/i3c/master/i3c-master-qcom-geni.c @@ -761,6 +761,7 @@ static int _i3c_geni_execute_command enum i3c_trans_dir rnw = gi3c->cur_rnw; u32 len = gi3c->cur_len; + reinit_completion(&gi3c->done); geni_se_select_mode(gi3c->se.base, xfer->mode); gi3c->err = 0; @@ -810,8 +811,8 @@ static int _i3c_geni_execute_command writel_relaxed(1, gi3c->se.base + SE_GENI_TX_WATERMARK_REG); } - time_remaining = wait_for_completion_timeout(&gi3c->done, - XFER_TIMEOUT); + + time_remaining = wait_for_completion_timeout(&gi3c->done, XFER_TIMEOUT); if (!time_remaining) { unsigned long flags; @@ -854,7 +855,11 @@ static int _i3c_geni_execute_command else writel_relaxed(1, gi3c->se.base + SE_DMA_TX_FSM_RST); + time_remaining = wait_for_completion_timeout(&gi3c->done, XFER_TIMEOUT); + if (!time_remaining) + GENI_SE_ERR(gi3c->ipcl, true, gi3c->se.dev, + "Timeout:FSM Reset, rnw:%d\n", rnw); } geni_se_rx_dma_unprep(gi3c->se.i3c_rsc.wrapper_dev, rx_dma, len);