Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1386532 > unrolled thread
| Started by | Jan Glauber <jglauber@cavium.com> |
|---|---|
| First post | 2016-04-25 16:40 +0200 |
| Last post | 2016-04-27 19:00 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v7 09/15] i2c: octeon: Add workaround for broken irqs on CN3860 Jan Glauber <jglauber@cavium.com> - 2016-04-25 16:40 +0200
Re: [PATCH v7 09/15] i2c: octeon: Add workaround for broken irqs on CN3860 Wolfram Sang <wsa@the-dreams.de> - 2016-04-26 23:20 +0200
Re: [PATCH v7 09/15] i2c: octeon: Add workaround for broken irqs on CN3860 Jan Glauber <jan.glauber@caviumnetworks.com> - 2016-04-27 11:40 +0200
[PATCH] i2c: octeon: Add workaround for broken irqs on CN3860 Jan Glauber <jglauber@cavium.com> - 2016-04-27 11:50 +0200
Re: [PATCH] i2c: octeon: Add workaround for broken irqs on CN3860 Wolfram Sang <wsa@the-dreams.de> - 2016-04-27 19:00 +0200
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-04-25 16:40 +0200 |
| Subject | [PATCH v7 09/15] i2c: octeon: Add workaround for broken irqs on CN3860 |
| Message-ID | <rrPQ7-7se-39@gated-at.bofh.it> |
From: David Daney <david.daney@cavium.com>
CN3860 does not interrupt the CPU when the i2c status changes. If
we get a timeout, and see the status has in fact changed, we know we
have this problem, and drop back to polling.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
drivers/i2c/busses/i2c-octeon.c | 53 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index 3144fe9..009cc33 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -121,6 +121,8 @@ struct octeon_i2c {
void __iomem *twsi_base;
struct device *dev;
bool hlc_enabled;
+ bool broken_irq_mode;
+ bool broken_irq_check;
void (*int_enable)(struct octeon_i2c *);
void (*int_disable)(struct octeon_i2c *);
void (*hlc_int_enable)(struct octeon_i2c *);
@@ -376,10 +378,32 @@ static int octeon_i2c_wait(struct octeon_i2c *i2c)
long time_left;
bool first = 1;
+ /*
+ * Some chip revisions don't assert the irq in the interrupt
+ * controller. So we must poll for the IFLG change.
+ */
+ if (i2c->broken_irq_mode) {
+ u64 end = get_jiffies_64() + i2c->adap.timeout;
+
+ while (!octeon_i2c_test_iflg(i2c) &&
+ time_before64(get_jiffies_64(), end))
+ udelay(50);
+
+ return octeon_i2c_test_iflg(i2c) ? 0 : -ETIMEDOUT;
+ }
+
i2c->int_enable(i2c);
time_left = wait_event_timeout(i2c->queue, octeon_i2c_test_ready(i2c, &first),
i2c->adap.timeout);
i2c->int_disable(i2c);
+
+ if (i2c->broken_irq_check && !time_left &&
+ octeon_i2c_test_iflg(i2c)) {
+ dev_err(i2c->dev, "broken irq connection detected, switching to polling mode.\n");
+ i2c->broken_irq_mode = true;
+ return 0;
+ }
+
if (!time_left)
return -ETIMEDOUT;
@@ -493,15 +517,37 @@ static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
bool first = 1;
int time_left;
+ /*
+ * Some cn38xx boards don't assert the irq in the interrupt
+ * controller. So we must poll for the valid bit change.
+ */
+ if (i2c->broken_irq_mode) {
+ u64 end = get_jiffies_64() + i2c->adap.timeout;
+
+ while (!octeon_i2c_hlc_test_valid(i2c) &&
+ time_before64(get_jiffies_64(), end))
+ udelay(50);
+
+ return octeon_i2c_hlc_test_valid(i2c) ? 0 : -ETIMEDOUT;
+ }
+
i2c->hlc_int_enable(i2c);
time_left = wait_event_timeout(i2c->queue,
octeon_i2c_hlc_test_ready(i2c, &first),
i2c->adap.timeout);
i2c->hlc_int_disable(i2c);
- if (!time_left) {
+ if (!time_left)
octeon_i2c_hlc_int_clear(i2c);
- return -ETIMEDOUT;
+
+ if (i2c->broken_irq_check && !time_left &&
+ octeon_i2c_hlc_test_valid(i2c)) {
+ dev_err(i2c->dev, "broken irq connection detected, switching to polling mode.\n");
+ i2c->broken_irq_mode = true;
+ return 0;
}
+
+ if (!time_left)
+ return -ETIMEDOUT;
return 0;
}
@@ -1136,6 +1182,9 @@ static int octeon_i2c_probe(struct platform_device *pdev)
goto out;
}
+ if (OCTEON_IS_MODEL(OCTEON_CN38XX))
+ i2c->broken_irq_check = true;
+
result = octeon_i2c_init_lowlevel(i2c);
if (result) {
dev_err(i2c->dev, "init low level failed\n");
--
1.9.1
[toc] | [next] | [standalone]
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-04-26 23:20 +0200 |
| Subject | Re: [PATCH v7 09/15] i2c: octeon: Add workaround for broken irqs on CN3860 |
| Message-ID | <rsiyJ-6iy-7@gated-at.bofh.it> |
| In reply to | #1386532 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Apr 25, 2016 at 04:33:38PM +0200, Jan Glauber wrote:
> From: David Daney <david.daney@cavium.com>
>
> CN3860 does not interrupt the CPU when the i2c status changes. If
> we get a timeout, and see the status has in fact changed, we know we
> have this problem, and drop back to polling.
>
> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> Signed-off-by: Jan Glauber <jglauber@cavium.com>
My code checkers say something:
CHECKPATCH
CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt
#37: FILE: drivers/i2c/busses/i2c-octeon.c:390:
+ udelay(50);
CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt
#70: FILE: drivers/i2c/busses/i2c-octeon.c:529:
+ udelay(50);
Dunno if you want to change that? Seems reasonable to me. Also:
SMATCH
drivers/i2c/busses/i2c-octeon.c:544 octeon_i2c_hlc_wait() warn: inconsistent indenting
This is true as well.
[toc] | [prev] | [next] | [standalone]
| From | Jan Glauber <jan.glauber@caviumnetworks.com> |
|---|---|
| Date | 2016-04-27 11:40 +0200 |
| Subject | Re: [PATCH v7 09/15] i2c: octeon: Add workaround for broken irqs on CN3860 |
| Message-ID | <rsu6T-7lj-35@gated-at.bofh.it> |
| In reply to | #1388103 |
On Tue, Apr 26, 2016 at 11:17:59PM +0200, Wolfram Sang wrote: > On Mon, Apr 25, 2016 at 04:33:38PM +0200, Jan Glauber wrote: > > From: David Daney <david.daney@cavium.com> > > > > CN3860 does not interrupt the CPU when the i2c status changes. If > > we get a timeout, and see the status has in fact changed, we know we > > have this problem, and drop back to polling. > > > > Signed-off-by: David Daney <ddaney@caviumnetworks.com> > > Signed-off-by: Jan Glauber <jglauber@cavium.com> > > My code checkers say something: > > CHECKPATCH > CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt > #37: FILE: drivers/i2c/busses/i2c-octeon.c:390: > + udelay(50); > > CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt > #70: FILE: drivers/i2c/busses/i2c-octeon.c:529: > + udelay(50); > > Dunno if you want to change that? Seems reasonable to me. Also: Yes, makes sense. > SMATCH > drivers/i2c/busses/i2c-octeon.c:544 octeon_i2c_hlc_wait() warn: inconsistent indenting > > This is true as well. > OK, I'll reply with an updated patch.
[toc] | [prev] | [next] | [standalone]
| From | Jan Glauber <jglauber@cavium.com> |
|---|---|
| Date | 2016-04-27 11:50 +0200 |
| Subject | [PATCH] i2c: octeon: Add workaround for broken irqs on CN3860 |
| Message-ID | <rsugy-7q8-9@gated-at.bofh.it> |
| In reply to | #1388103 |
From: David Daney <david.daney@cavium.com>
CN3860 does not interrupt the CPU when the i2c status changes. If
we get a timeout, and see the status has in fact changed, we know we
have this problem, and drop back to polling.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
drivers/i2c/busses/i2c-octeon.c | 53 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index 3144fe9..5b32a02 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -121,6 +121,8 @@ struct octeon_i2c {
void __iomem *twsi_base;
struct device *dev;
bool hlc_enabled;
+ bool broken_irq_mode;
+ bool broken_irq_check;
void (*int_enable)(struct octeon_i2c *);
void (*int_disable)(struct octeon_i2c *);
void (*hlc_int_enable)(struct octeon_i2c *);
@@ -376,10 +378,32 @@ static int octeon_i2c_wait(struct octeon_i2c *i2c)
long time_left;
bool first = 1;
+ /*
+ * Some chip revisions don't assert the irq in the interrupt
+ * controller. So we must poll for the IFLG change.
+ */
+ if (i2c->broken_irq_mode) {
+ u64 end = get_jiffies_64() + i2c->adap.timeout;
+
+ while (!octeon_i2c_test_iflg(i2c) &&
+ time_before64(get_jiffies_64(), end))
+ usleep_range(I2C_OCTEON_EVENT_WAIT / 2, I2C_OCTEON_EVENT_WAIT);
+
+ return octeon_i2c_test_iflg(i2c) ? 0 : -ETIMEDOUT;
+ }
+
i2c->int_enable(i2c);
time_left = wait_event_timeout(i2c->queue, octeon_i2c_test_ready(i2c, &first),
i2c->adap.timeout);
i2c->int_disable(i2c);
+
+ if (i2c->broken_irq_check && !time_left &&
+ octeon_i2c_test_iflg(i2c)) {
+ dev_err(i2c->dev, "broken irq connection detected, switching to polling mode.\n");
+ i2c->broken_irq_mode = true;
+ return 0;
+ }
+
if (!time_left)
return -ETIMEDOUT;
@@ -493,15 +517,37 @@ static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
bool first = 1;
int time_left;
+ /*
+ * Some cn38xx boards don't assert the irq in the interrupt
+ * controller. So we must poll for the valid bit change.
+ */
+ if (i2c->broken_irq_mode) {
+ u64 end = get_jiffies_64() + i2c->adap.timeout;
+
+ while (!octeon_i2c_hlc_test_valid(i2c) &&
+ time_before64(get_jiffies_64(), end))
+ usleep_range(I2C_OCTEON_EVENT_WAIT / 2, I2C_OCTEON_EVENT_WAIT);
+
+ return octeon_i2c_hlc_test_valid(i2c) ? 0 : -ETIMEDOUT;
+ }
+
i2c->hlc_int_enable(i2c);
time_left = wait_event_timeout(i2c->queue,
octeon_i2c_hlc_test_ready(i2c, &first),
i2c->adap.timeout);
i2c->hlc_int_disable(i2c);
- if (!time_left) {
+ if (!time_left)
octeon_i2c_hlc_int_clear(i2c);
- return -ETIMEDOUT;
+
+ if (i2c->broken_irq_check && !time_left &&
+ octeon_i2c_hlc_test_valid(i2c)) {
+ dev_err(i2c->dev, "broken irq connection detected, switching to polling mode.\n");
+ i2c->broken_irq_mode = true;
+ return 0;
}
+
+ if (!time_left)
+ return -ETIMEDOUT;
return 0;
}
@@ -1136,6 +1182,9 @@ static int octeon_i2c_probe(struct platform_device *pdev)
goto out;
}
+ if (OCTEON_IS_MODEL(OCTEON_CN38XX))
+ i2c->broken_irq_check = true;
+
result = octeon_i2c_init_lowlevel(i2c);
if (result) {
dev_err(i2c->dev, "init low level failed\n");
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-04-27 19:00 +0200 |
| Subject | Re: [PATCH] i2c: octeon: Add workaround for broken irqs on CN3860 |
| Message-ID | <rsAYG-4mv-13@gated-at.bofh.it> |
| In reply to | #1388848 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Apr 27, 2016 at 11:44:39AM +0200, Jan Glauber wrote: > From: David Daney <david.daney@cavium.com> > > CN3860 does not interrupt the CPU when the i2c status changes. If > we get a timeout, and see the status has in fact changed, we know we > have this problem, and drop back to polling. > > Signed-off-by: David Daney <ddaney@caviumnetworks.com> > Signed-off-by: Jan Glauber <jglauber@cavium.com> Applied to for-next, thanks!
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web