diff mbox series

[v7,17/34] i2c: tegra: Remove outdated barrier()

Message ID 20200908224006.25636-18-digetx@gmail.com
State Superseded
Headers show
Series Improvements for Tegra I2C driver | expand

Commit Message

Dmitry Osipenko Sept. 8, 2020, 10:39 p.m. UTC
The barrier() was intended to reduce possibility of racing with the
interrupt handler, but driver's code evolved significantly and today's
driver enables interrupt only when it waits for completion notification.
Hence barrier() has no good use anymore, let's remove it.

Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/i2c/busses/i2c-tegra.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Thierry Reding Sept. 17, 2020, 12:39 p.m. UTC | #1
On Wed, Sep 09, 2020 at 01:39:49AM +0300, Dmitry Osipenko wrote:
> The barrier() was intended to reduce possibility of racing with the

> interrupt handler, but driver's code evolved significantly and today's

> driver enables interrupt only when it waits for completion notification.

> Hence barrier() has no good use anymore, let's remove it.

> 

> Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

> ---

>  drivers/i2c/busses/i2c-tegra.c | 13 +++++--------

>  1 file changed, 5 insertions(+), 8 deletions(-)


Acked-by: Thierry Reding <treding@nvidia.com>
Thierry Reding Sept. 21, 2020, 10:19 a.m. UTC | #2
On Wed, 09 Sep 2020 01:39:49 +0300, Dmitry Osipenko wrote:
> The barrier() was intended to reduce possibility of racing with the

> interrupt handler, but driver's code evolved significantly and today's

> driver enables interrupt only when it waits for completion notification.

> Hence barrier() has no good use anymore, let's remove it.

> 

> Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

> Acked-by: Thierry Reding <treding@nvidia.com>

> ---

>  drivers/i2c/busses/i2c-tegra.c | 13 +++++--------

>  1 file changed, 5 insertions(+), 8 deletions(-)


Tested-by: Thierry Reding <treding@nvidia.com>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 71e82a68c942..ab83d1de6c94 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -795,18 +795,17 @@  static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev)
 			words_to_transfer = tx_fifo_avail;
 
 		/*
-		 * Update state before writing to FIFO.  If this casues us
-		 * to finish writing all bytes (AKA buf_remaining goes to 0) we
-		 * have a potential for an interrupt (PACKET_XFER_COMPLETE is
-		 * not maskable).  We need to make sure that the isr sees
-		 * buf_remaining as 0 and doesn't call us back re-entrantly.
+		 * Update state before writing to FIFO.  Note that this may
+		 * cause us to finish writing all bytes (AKA buf_remaining
+		 * goes to 0), hence we have a potential for an interrupt
+		 * (PACKET_XFER_COMPLETE is not maskable), but GIC interrupt
+		 * is disabled at this point.
 		 */
 		buf_remaining -= words_to_transfer * BYTES_PER_FIFO_WORD;
 		tx_fifo_avail -= words_to_transfer;
 		i2c_dev->msg_buf_remaining = buf_remaining;
 		i2c_dev->msg_buf = buf +
 			words_to_transfer * BYTES_PER_FIFO_WORD;
-		barrier();
 
 		i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
 
@@ -827,10 +826,8 @@  static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev)
 		memcpy(&val, buf, buf_remaining);
 		val = le32_to_cpu(val);
 
-		/* Again update before writing to FIFO to make sure isr sees. */
 		i2c_dev->msg_buf_remaining = 0;
 		i2c_dev->msg_buf = NULL;
-		barrier();
 
 		i2c_writel(i2c_dev, val, I2C_TX_FIFO);
 	}