Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1490083 > unrolled thread

[PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP condition

Started byMasahiro Yamada <yamada.masahiro@socionext.com>
First post2016-09-23 15:40 +0200
Last post2016-09-24 11:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP condition Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-09-23 15:40 +0200
    Re: [PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP  condition Wolfram Sang <wsa@the-dreams.de> - 2016-09-24 11:30 +0200

#1490083 — [PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP condition

FromMasahiro Yamada <yamada.masahiro@socionext.com>
Date2016-09-23 15:40 +0200
Subject[PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP condition
Message-ID<skyRQ-4e3-11@gated-at.bofh.it>
Currently, the status register FI2C_SR is checked immediately after
a STOP condition is issued in case of the deferred STOP condition.
It takes typically 5-10 usec until the corresponding bits in the
register are set, so the error check for "stop condition was not
completed" is very likely to be false positive.

Add wait code to relax the status register check.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v2:
  - use readl_poll_timeout()

 drivers/i2c/busses/i2c-uniphier-f.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c
index 829df91..db9105e 100644
--- a/drivers/i2c/busses/i2c-uniphier-f.c
+++ b/drivers/i2c/busses/i2c-uniphier-f.c
@@ -14,6 +14,7 @@
 
 #include <linux/clk.h>
 #include <linux/i2c.h>
+#include <linux/iopoll.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -348,14 +349,19 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap,
 	dev_dbg(&adap->dev, "complete\n");
 
 	if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) {
-		u32 status = readl(priv->membase + UNIPHIER_FI2C_SR);
-
-		if (!(status & UNIPHIER_FI2C_SR_STS) ||
-		    status & UNIPHIER_FI2C_SR_BB) {
+		u32 status;
+		int ret;
+
+		ret = readl_poll_timeout(priv->membase + UNIPHIER_FI2C_SR,
+					 status,
+					 (status & UNIPHIER_FI2C_SR_STS) &&
+					 !(status & UNIPHIER_FI2C_SR_BB),
+					 1, 20);
+		if (ret) {
 			dev_err(&adap->dev,
 				"stop condition was not completed.\n");
 			uniphier_fi2c_recover(priv);
-			return -EBUSY;
+			return ret;
 		}
 	}
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1490616 — Re: [PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP condition

FromWolfram Sang <wsa@the-dreams.de>
Date2016-09-24 11:30 +0200
SubjectRe: [PATCH v2] i2c: uniphier-f: fix misdetection of incomplete STOP condition
Message-ID<skRrr-7FA-9@gated-at.bofh.it>
In reply to#1490083

[Multipart message — attachments visible in raw view] — view raw

On Fri, Sep 23, 2016 at 10:34:41PM +0900, Masahiro Yamada wrote:
> Currently, the status register FI2C_SR is checked immediately after
> a STOP condition is issued in case of the deferred STOP condition.
> It takes typically 5-10 usec until the corresponding bits in the
> register are set, so the error check for "stop condition was not
> completed" is very likely to be false positive.
> 
> Add wait code to relax the status register check.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Applied to for-next, thanks!

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web