All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Mikko Perttunen <cyndis@kapsi.fi>,
	Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v4 7/8] i2c: tegra: Always terminate DMA transfer
Date: Sun, 12 Jan 2020 20:14:29 +0300	[thread overview]
Message-ID: <20200112171430.27219-8-digetx@gmail.com> (raw)
In-Reply-To: <20200112171430.27219-1-digetx@gmail.com>

It is possible that I2C could error out in the middle of DMA transfer and
in this case DMA channel needs to be reset, otherwise a follow up transfer
will fail because DMA channel stays blocked.

Tested-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/i2c/busses/i2c-tegra.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 1a390e1bff72..3c7c86d4b0e4 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1220,11 +1220,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
 		time_left = tegra_i2c_wait_completion_timeout(
 				i2c_dev, &i2c_dev->dma_complete, xfer_time);
 
+		dmaengine_terminate_sync(i2c_dev->msg_read ?
+					 i2c_dev->rx_dma_chan :
+					 i2c_dev->tx_dma_chan);
+
 		if (time_left == 0) {
 			dev_err(i2c_dev->dev, "DMA transfer timeout\n");
-			dmaengine_terminate_sync(i2c_dev->msg_read ?
-						 i2c_dev->rx_dma_chan :
-						 i2c_dev->tx_dma_chan);
 			tegra_i2c_init(i2c_dev, true);
 			return -ETIMEDOUT;
 		}
@@ -1237,11 +1238,6 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
 			memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf,
 			       msg->len);
 		}
-
-		if (i2c_dev->msg_err != I2C_ERR_NONE)
-			dmaengine_synchronize(i2c_dev->msg_read ?
-					      i2c_dev->rx_dma_chan :
-					      i2c_dev->tx_dma_chan);
 	}
 
 	time_left = tegra_i2c_wait_completion_timeout(
-- 
2.24.0

  parent reply	other threads:[~2020-01-12 17:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-12 17:14 [PATCH v4 0/8] NVIDIA Tegra I2C driver fixes and improvements Dmitry Osipenko
2020-01-12 17:14 ` [PATCH v4 2/8] i2c: tegra: Properly disable runtime PM on driver's probe error Dmitry Osipenko
2020-01-12 17:14 ` [PATCH v4 3/8] i2c: tegra: Prevent interrupt triggering after transfer timeout Dmitry Osipenko
2020-01-12 17:14 ` [PATCH v4 4/8] i2c: tegra: Support atomic transfers Dmitry Osipenko
2020-01-13 22:03   ` Wolfram Sang
2020-01-13 22:52     ` Dmitry Osipenko
2020-01-14  1:26       ` Dmitry Osipenko
2020-01-14  5:57       ` Wolfram Sang
2020-01-12 17:14 ` [PATCH v4 6/8] i2c: tegra: Use relaxed versions of readl/writel Dmitry Osipenko
2020-01-12 17:14 ` Dmitry Osipenko [this message]
     [not found] ` <20200112171430.27219-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-01-12 17:14   ` [PATCH v4 1/8] i2c: tegra: Fix suspending in active runtime PM state Dmitry Osipenko
2020-01-12 17:14     ` Dmitry Osipenko
2020-01-12 17:14   ` [PATCH v4 5/8] i2c: tegra: Rename I2C_PIO_MODE_MAX_LEN to I2C_PIO_MODE_PREFERRED_LEN Dmitry Osipenko
2020-01-12 17:14     ` Dmitry Osipenko
2020-01-12 17:14   ` [PATCH v4 8/8] i2c: tegra: Check DMA completion status in addition to left time Dmitry Osipenko
2020-01-12 17:14     ` Dmitry Osipenko
2020-01-13 21:53   ` [PATCH v4 0/8] NVIDIA Tegra I2C driver fixes and improvements Wolfram Sang
2020-01-13 21:53     ` Wolfram Sang
2020-01-13 23:01     ` Dmitry Osipenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200112171430.27219-8-digetx@gmail.com \
    --to=digetx@gmail.com \
    --cc=cyndis@kapsi.fi \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.