[v2] i2c: cadence: try reset when master receive arbitration lost
diff mbox series

Message ID 20190219012447.5900-1-sxauwsk@163.com
State Under Review
Headers show
Series
  • [v2] i2c: cadence: try reset when master receive arbitration lost
Related show

Commit Message

Shikai Wang Feb. 19, 2019, 1:24 a.m. UTC
When the adapter receive arbitration lost error interrupts,
cdns_i2c_master_xfer return to the caller directly instead of resetting
the adapter which resulted in the adapter being out of control.

So when driver detect err_status such as arbitration lost,
then try to repair and fix it.

Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Signed-off-by: Shikai Wang <sxauwsk@163.com>
---
 drivers/i2c/busses/i2c-cadence.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Wolfram Sang Feb. 23, 2019, 9:48 a.m. UTC | #1
On Tue, Feb 19, 2019 at 09:24:47AM +0800, Shikai Wang wrote:
> When the adapter receive arbitration lost error interrupts,
> cdns_i2c_master_xfer return to the caller directly instead of resetting
> the adapter which resulted in the adapter being out of control.
> 
> So when driver detect err_status such as arbitration lost,
> then try to repair and fix it.

Just checking because resetting looks like a big hammer to me: there is
no way to gracefully recover form 'arbitration lost' interrupt?
Wolfram Sang March 9, 2019, 9:44 a.m. UTC | #2
On Sat, Feb 23, 2019 at 10:48:43AM +0100, Wolfram Sang wrote:
> On Tue, Feb 19, 2019 at 09:24:47AM +0800, Shikai Wang wrote:
> > When the adapter receive arbitration lost error interrupts,
> > cdns_i2c_master_xfer return to the caller directly instead of resetting
> > the adapter which resulted in the adapter being out of control.
> > 
> > So when driver detect err_status such as arbitration lost,
> > then try to repair and fix it.
> 
> Just checking because resetting looks like a big hammer to me: there is
> no way to gracefully recover form 'arbitration lost' interrupt?

I am still wondering about this but since it is acked by the maintainer:

Applied to for-current, thanks!
Wolfram Sang March 9, 2019, 9:49 a.m. UTC | #3
On Sat, Mar 09, 2019 at 10:44:52AM +0100, Wolfram Sang wrote:
> On Sat, Feb 23, 2019 at 10:48:43AM +0100, Wolfram Sang wrote:
> > On Tue, Feb 19, 2019 at 09:24:47AM +0800, Shikai Wang wrote:
> > > When the adapter receive arbitration lost error interrupts,
> > > cdns_i2c_master_xfer return to the caller directly instead of resetting
> > > the adapter which resulted in the adapter being out of control.
> > > 
> > > So when driver detect err_status such as arbitration lost,
> > > then try to repair and fix it.
> > 
> > Just checking because resetting looks like a big hammer to me: there is
> > no way to gracefully recover form 'arbitration lost' interrupt?
> 
> I am still wondering about this but since it is acked by the maintainer:
> 
> Applied to for-current, thanks!

Oops, I was mixing this up with

[PATCHv4] i2c: cadence: Fix the driver in interrupt flurry case

This one doesn't have an ack from Michal. Dropping it again.

Patch
diff mbox series

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index b13605718291..595b0d56ff1a 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -548,10 +548,6 @@  static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,
 	cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK,
 			  CDNS_I2C_IDR_OFFSET);
 
-	/* If it is bus arbitration error, try again */
-	if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
-		return -EAGAIN;
-
 	return 0;
 }
 
@@ -624,6 +620,12 @@  static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 		if (id->err_status) {
 			cdns_i2c_master_reset(adap);
 
+			/* If it is bus arbitration error, try again */
+			if (id->err_status & CDNS_I2C_IXR_ARB_LOST) {
+				ret = -EAGAIN;
+				goto out;
+			}
+
 			if (id->err_status & CDNS_I2C_IXR_NACK) {
 				ret = -ENXIO;
 				goto out;