diff mbox series

[2/2] i2c: cadence: Clear HOLD bit at correct time in Rx path

Message ID 1593784572-21910-1-git-send-email-raviteja.narayanam@xilinx.com (mailing list archive)
State Mainlined
Commit 12d4d9ec5eeecd712c73772e422b6d082e66b046
Headers show
Series i2c: cadence: HOLD bit manipulation | expand

Commit Message

Raviteja Narayanam July 3, 2020, 1:56 p.m. UTC
There are few issues on Zynq SOC observed in the stress tests causing
timeout errors. Even though all the data is received, timeout error
is thrown. This is due to an IP bug in which the COMP bit in ISR is
not set at end of transfer and completion interrupt is not generated.

This bug is seen on Zynq platforms when the following condition occurs:
Master read & HOLD bit set & Transfer size register reaches '0'.

One workaround is to clear the HOLD bit before the transfer size
register reaches '0'. The current implementation checks for this at
the start of the loop and also only for less than FIFO DEPTH case
(ignoring the equal to case).

So clear the HOLD bit when the data yet to receive is less than or
equal to the FIFO DEPTH. This avoids the IP bug condition.

Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
---
 drivers/i2c/busses/i2c-cadence.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Wolfram Sang July 22, 2020, 10:29 a.m. UTC | #1
On Fri, Jul 03, 2020 at 07:26:12PM +0530, Raviteja Narayanam wrote:
> There are few issues on Zynq SOC observed in the stress tests causing
> timeout errors. Even though all the data is received, timeout error
> is thrown. This is due to an IP bug in which the COMP bit in ISR is
> not set at end of transfer and completion interrupt is not generated.
> 
> This bug is seen on Zynq platforms when the following condition occurs:
> Master read & HOLD bit set & Transfer size register reaches '0'.
> 
> One workaround is to clear the HOLD bit before the transfer size
> register reaches '0'. The current implementation checks for this at
> the start of the loop and also only for less than FIFO DEPTH case
> (ignoring the equal to case).
> 
> So clear the HOLD bit when the data yet to receive is less than or
> equal to the FIFO DEPTH. This avoids the IP bug condition.
> 
> Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xilinx.com>

Applied to for-current, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index e069602..e4b7f2a 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -421,20 +421,21 @@  static irqreturn_t cdns_i2c_master_isr(void *ptr)
 		/* Read data if receive data valid is set */
 		while (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) &
 		       CDNS_I2C_SR_RXDV) {
-			/*
-			 * Clear hold bit that was set for FIFO control if
-			 * RX data left is less than FIFO depth, unless
-			 * repeated start is selected.
-			 */
-			if ((id->recv_count < CDNS_I2C_FIFO_DEPTH) &&
-			    !id->bus_hold_flag)
-				cdns_i2c_clear_bus_hold(id);
-
 			if (id->recv_count > 0) {
 				*(id->p_recv_buf)++ =
 					cdns_i2c_readreg(CDNS_I2C_DATA_OFFSET);
 				id->recv_count--;
 				id->curr_recv_count--;
+
+				/*
+				 * Clear hold bit that was set for FIFO control
+				 * if RX data left is less than or equal to
+				 * FIFO DEPTH unless repeated start is selected
+				 */
+				if (id->recv_count <= CDNS_I2C_FIFO_DEPTH &&
+				    !id->bus_hold_flag)
+					cdns_i2c_clear_bus_hold(id);
+
 			} else {
 				dev_err(id->adap.dev.parent,
 					"xfer_size reg rollover. xfer aborted!\n");