Skip to contentSkip to conversation

i2c: cadence: try reset when master receive error interrupts

PATCH In review sxauwsk 2 participants 6 messages Jan 29, 2019 – Feb 18, 2019

Subsystems (2)
lore
Share & tools
lore

sxauwsk

author
#0 lore raw

PATCH 1/1 i2c: cadence: try reset when master receive error interrupts

When the adapter receive error interrupts, such as NACK, arbitration lost, cdns_i2c_master_xfer return to the caller directly instead of resuming the adapter which resulted in the adapter being out of control.

So when driver detect err_status then try to repair and fix it.

---
 drivers/i2c/busses/i2c-cadence.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-cadence.c +7 -5
index b13605718291..e10048d7524a 100644
@@ -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;
 }
 
@@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 			id->bus_hold_flag = 0;
 
 		ret = cdns_i2c_process_msg(id, msgs, adap);
-		if (ret)
+		if (!ret)
 			goto out;
 
 		/* Report the other error interrupts to application */
 		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;
Signature · 1 line
2.19.2
#1 lore raw

Hi Sxauwsk,

Quoted 28 lines · sxauwsk

When the adapter receive error interrupts, such as NACK, arbitration lost, cdns_i2c_master_xfer return to the caller directly instead of resuming the adapter which resulted in the adapter being out of control.

So when driver detect err_status then try to repair and fix it.

---
 drivers/i2c/busses/i2c-cadence.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-cadence.c +0 -4
index b13605718291..e10048d7524a 100644
@@ -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;
 }
 

drivers/i2c/busses/i2c-cadence.c static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 618

Quoted 7 lines
drivers/i2c/busses/i2c-cadence.c +1 -1
@@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                        id->bus_hold_flag = 0;
 
                ret = cdns_i2c_process_msg(id, msgs, adap);
-               if (ret)
+               if (!ret)
                        goto out;
 

In case the Arbitration error happend the cdns_i2c_process_msg would return 0 and we will miss the check below.

Am I missing something ?

Quoted 17 lines
drivers/i2c/busses/i2c-cadence.c +6 -1
                /* Report the other error interrupts to application */
                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;
--

2.19.2

#2 lore raw

PATCH 1/1 i2c: cadence: try reset when master receive error interrupts

Quoted 41 lines

Hi Sxauwsk,

Quoted 28 lines · sxauwsk

When the adapter receive error interrupts, such as NACK, arbitration lost, cdns_i2c_master_xfer return to the caller directly instead of resuming the adapter which resulted in the adapter being out of control.

So when driver detect err_status then try to repair and fix it.

---
  drivers/i2c/busses/i2c-cadence.c | 12 +++++++-----

  1 file changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-cadence.c +0 -4
index b13605718291..e10048d7524a 100644
@@ -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;
   }
 

drivers/i2c/busses/i2c-cadence.c static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 618

Quoted 7 lines
drivers/i2c/busses/i2c-cadence.c +1 -1
@@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                          id->bus_hold_flag = 0;
 
                  ret = cdns_i2c_process_msg(id, msgs, adap);
-               if (ret)
+               if (!ret)
                          goto out;
 

In case  the Arbitration error happend  the cdns_i2c_process_msg would return 0 and we will miss the check  below.

Quoted 19 lines

Am I missing something ?

Quoted 17 lines
drivers/i2c/busses/i2c-cadence.c +6 -1
                  /* Report the other error interrupts to application */
                  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;
--

2.19.2

In cdns_i2c_process_msg process, when detect arbitration lost error return -EAGAIN to  cdns_i2c_master_xfer,  not return 0 that mean cdns_i2c_process_msg  just go out ignore error check and  problem occur, So we should do something when arbitration error detect.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw

Hi ,

Quoted 62 lines · On Sat, Feb 16, 2019 at 1:21 PM [email protected] <[email protected]> wrote:
Quoted 42 lines

Hi Sxauwsk,

Quoted 28 lines · sxauwsk

When the adapter receive error interrupts, such as NACK, arbitration lost, cdns_i2c_master_xfer return to the caller directly instead of resuming the adapter which resulted in the adapter being out of control.

So when driver detect err_status then try to repair and fix it.

---
 drivers/i2c/busses/i2c-cadence.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-cadence.c +0 -4
index b13605718291..e10048d7524a 100644
@@ -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;
 }
 

drivers/i2c/busses/i2c-cadence.c static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 618

Quoted 7 lines
drivers/i2c/busses/i2c-cadence.c +1 -1
@@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                        id->bus_hold_flag = 0;
 
                ret = cdns_i2c_process_msg(id, msgs, adap);
-               if (ret)
+               if (!ret)
                        goto out;
 

In case the Arbitration error happend the cdns_i2c_process_msg would return 0 and we will miss the check below.

Quoted 19 lines

Am I missing something ?

Quoted 17 lines
drivers/i2c/busses/i2c-cadence.c +6 -1
                /* Report the other error interrupts to application */
                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;
--

2.19.2

Quoted 2 lines

In cdns_i2c_process_msg process, when detect arbitration lost error return -EAGAIN to cdns_i2c_master_xfer, not return 0 that mean cdns_i2c_process_msg just go out ignore error check and problem occur, So we should do something when arbitration error detect.

Arbitration lost is fine how about other errors like NACK.

#4 lore raw

Hi , Shubhrajyoti

Quoted 64 lines

Hi ,

Quoted 62 lines · On Sat, Feb 16, 2019 at 1:21 PM [email protected] <[email protected]> wrote:
Quoted 61 lines

Hi Sxauwsk,

Quoted 28 lines · sxauwsk

When the adapter receive error interrupts, such as NACK, arbitration lost, cdns_i2c_master_xfer return to the caller directly instead of resuming the adapter which resulted in the adapter being out of control.

So when driver detect err_status then try to repair and fix it.

---
  drivers/i2c/busses/i2c-cadence.c | 12 +++++++-----

  1 file changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-cadence.c +0 -4
index b13605718291..e10048d7524a 100644
@@ -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;
   }
 

drivers/i2c/busses/i2c-cadence.c static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 618

Quoted 7 lines
drivers/i2c/busses/i2c-cadence.c +1 -1
@@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                          id->bus_hold_flag = 0;
 
                  ret = cdns_i2c_process_msg(id, msgs, adap);
-               if (ret)
+               if (!ret)
                          goto out;
 

In case  the Arbitration error happend  the cdns_i2c_process_msg would return 0 and we will miss the check  below.

Am I missing something ?

Quoted 17 lines
drivers/i2c/busses/i2c-cadence.c +6 -1
                  /* Report the other error interrupts to application */
                  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;
--

2.19.2

Quoted 9 lines
Quoted 2 lines

In cdns_i2c_process_msg process, when detect arbitration lost error return -EAGAIN to  cdns_i2c_master_xfer,  not return 0 that mean cdns_i2c_process_msg  just go out ignore error check and  problem occur, So we should do something when arbitration error detect.

Arbitration lost is fine how about other errors like NACK.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

                ret = cdns_i2c_process_msg(id, msgs, adap);
-               if (ret)
+               if (!ret)
                        goto out;

Yes, you're right,  This place I should't make any change,  perfect solution!

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

-       /* If it is bus arbitration error, try again */
-       if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
-               return -EAGAIN;
-
        return 0;
 }

                /* Report the other error interrupts to application */ if (id->err_status) { cdns_i2c_master_reset(adap);

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

+                       /* If it is bus arbitration error, try again */
+                       if (id->err_status & CDNS_I2C_IXR_ARB_LOST) {
+                               ret = -EAGAIN;
+                               goto out;
+                       }
+

Maybe Just remove Arbitration lost Detect part from  cdns_i2c_process_msg function,  then add to cdns_i2c_master_xfer,  Do you think?

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw
Quoted 92 lines · On Mon, Feb 18, 2019 at 12:48 PM [email protected] <[email protected]> wrote:

Hi , Shubhrajyoti

Quoted 64 lines

Hi ,

Quoted 62 lines · On Sat, Feb 16, 2019 at 1:21 PM [email protected] <[email protected]> wrote:
Quoted 61 lines

Hi Sxauwsk,

Quoted 28 lines · sxauwsk

When the adapter receive error interrupts, such as NACK, arbitration lost, cdns_i2c_master_xfer return to the caller directly instead of resuming the adapter which resulted in the adapter being out of control.

So when driver detect err_status then try to repair and fix it.

---
 drivers/i2c/busses/i2c-cadence.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-cadence.c +0 -4
index b13605718291..e10048d7524a 100644
@@ -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;
 }
 

drivers/i2c/busses/i2c-cadence.c static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 618

Quoted 7 lines
drivers/i2c/busses/i2c-cadence.c +1 -1
@@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                        id->bus_hold_flag = 0;
 
                ret = cdns_i2c_process_msg(id, msgs, adap);
-               if (ret)
+               if (!ret)
                        goto out;
 

In case the Arbitration error happend the cdns_i2c_process_msg would return 0 and we will miss the check below.

Am I missing something ?

Quoted 17 lines
drivers/i2c/busses/i2c-cadence.c +6 -1
                /* Report the other error interrupts to application */
                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;
--

2.19.2

Quoted 9 lines
Quoted 2 lines

In cdns_i2c_process_msg process, when detect arbitration lost error return -EAGAIN to cdns_i2c_master_xfer, not return 0 that mean cdns_i2c_process_msg just go out ignore error check and problem occur, So we should do something when arbitration error detect.

Arbitration lost is fine how about other errors like NACK.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
                ret = cdns_i2c_process_msg(id, msgs, adap);
drivers/i2c/busses/i2c-cadence.c +1 -1
-               if (ret)
+               if (!ret)
                        goto out;

Yes, you're right, This place I should't make any change, perfect solution!

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/i2c/busses/i2c-cadence.c +0 -4
-       /* If it is bus arbitration error, try again */
-       if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
-               return -EAGAIN;
-
        return 0;
 }
 
 
                /* Report the other error interrupts to application */
                if (id->err_status) {
                        cdns_i2c_master_reset(adap);
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/i2c/busses/i2c-cadence.c static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 628

Quoted 6 lines
drivers/i2c/busses/i2c-cadence.c +6 -0
+                       /* If it is bus arbitration error, try again */
+                       if (id->err_status & CDNS_I2C_IXR_ARB_LOST) {
+                               ret = -EAGAIN;
+                               goto out;
+                       }
+

Maybe Just remove Arbitration lost Detect part from cdns_i2c_process_msg function, then add to cdns_i2c_master_xfer, Do you think?

I agree.

Quoted 4 lines