linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] i2c: cadence: Clear HOLD bit at correct time in Rx path
@ 2020-07-03 13:56 Raviteja Narayanam
  2020-07-22 10:29 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Raviteja Narayanam @ 2020-07-03 13:56 UTC (permalink / raw)
  To: linux-i2c
  Cc: michal.simek, linux-arm-kernel, linux-kernel, git, Raviteja Narayanam

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(-)

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");
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] i2c: cadence: Clear HOLD bit at correct time in Rx path
  2020-07-03 13:56 [PATCH 2/2] i2c: cadence: Clear HOLD bit at correct time in Rx path Raviteja Narayanam
@ 2020-07-22 10:29 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2020-07-22 10:29 UTC (permalink / raw)
  To: Raviteja Narayanam
  Cc: linux-i2c, michal.simek, linux-arm-kernel, linux-kernel, git

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

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!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-22 10:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 13:56 [PATCH 2/2] i2c: cadence: Clear HOLD bit at correct time in Rx path Raviteja Narayanam
2020-07-22 10:29 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).