aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Glauber <jglauber@cavium.com>2016-12-09 04:31:56 -0500
committerWolfram Sang <wsa@the-dreams.de>2016-12-11 16:59:10 -0500
commit38190dfb7056678e388f85cb9c79f8e479a4b263 (patch)
treee2e9fa9ed49f6d91bc2459bf50c4e91639e047b7
parentccee1a4cdcd02e748d39d2b121f7f82041893121 (diff)
i2c: octeon: thunderx: Remove double-check after interrupt
Commit 1bb1ff3e7c74 ("i2c: octeon: Improve performance if interrupt is early") added a double-check around the wait_event_timeout() condition. The performance problem that this commit tried to work-around could not be reproduced. It also makes the wait condition more complicated then it should be. Therefore remove the double-check. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-octeon-core.c43
1 files changed, 2 insertions, 41 deletions
diff --git a/drivers/i2c/busses/i2c-octeon-core.c b/drivers/i2c/busses/i2c-octeon-core.c
index 0b020703017d..1d8775799056 100644
--- a/drivers/i2c/busses/i2c-octeon-core.c
+++ b/drivers/i2c/busses/i2c-octeon-core.c
@@ -36,24 +36,6 @@ static bool octeon_i2c_test_iflg(struct octeon_i2c *i2c)
36 return (octeon_i2c_ctl_read(i2c) & TWSI_CTL_IFLG); 36 return (octeon_i2c_ctl_read(i2c) & TWSI_CTL_IFLG);
37} 37}
38 38
39static bool octeon_i2c_test_ready(struct octeon_i2c *i2c, bool *first)
40{
41 if (octeon_i2c_test_iflg(i2c))
42 return true;
43
44 if (*first) {
45 *first = false;
46 return false;
47 }
48
49 /*
50 * IRQ has signaled an event but IFLG hasn't changed.
51 * Sleep and retry once.
52 */
53 usleep_range(I2C_OCTEON_EVENT_WAIT, 2 * I2C_OCTEON_EVENT_WAIT);
54 return octeon_i2c_test_iflg(i2c);
55}
56
57/** 39/**
58 * octeon_i2c_wait - wait for the IFLG to be set 40 * octeon_i2c_wait - wait for the IFLG to be set
59 * @i2c: The struct octeon_i2c 41 * @i2c: The struct octeon_i2c
@@ -63,7 +45,6 @@ static bool octeon_i2c_test_ready(struct octeon_i2c *i2c, bool *first)
63static int octeon_i2c_wait(struct octeon_i2c *i2c) 45static int octeon_i2c_wait(struct octeon_i2c *i2c)
64{ 46{
65 long time_left; 47 long time_left;
66 bool first = true;
67 48
68 /* 49 /*
69 * Some chip revisions don't assert the irq in the interrupt 50 * Some chip revisions don't assert the irq in the interrupt
@@ -80,7 +61,7 @@ static int octeon_i2c_wait(struct octeon_i2c *i2c)
80 } 61 }
81 62
82 i2c->int_enable(i2c); 63 i2c->int_enable(i2c);
83 time_left = wait_event_timeout(i2c->queue, octeon_i2c_test_ready(i2c, &first), 64 time_left = wait_event_timeout(i2c->queue, octeon_i2c_test_iflg(i2c),
84 i2c->adap.timeout); 65 i2c->adap.timeout);
85 i2c->int_disable(i2c); 66 i2c->int_disable(i2c);
86 67
@@ -102,25 +83,6 @@ static bool octeon_i2c_hlc_test_valid(struct octeon_i2c *i2c)
102 return (__raw_readq(i2c->twsi_base + SW_TWSI(i2c)) & SW_TWSI_V) == 0; 83 return (__raw_readq(i2c->twsi_base + SW_TWSI(i2c)) & SW_TWSI_V) == 0;
103} 84}
104 85
105static bool octeon_i2c_hlc_test_ready(struct octeon_i2c *i2c, bool *first)
106{
107 /* check if valid bit is cleared */
108 if (octeon_i2c_hlc_test_valid(i2c))
109 return true;
110
111 if (*first) {
112 *first = false;
113 return false;
114 }
115
116 /*
117 * IRQ has signaled an event but valid bit isn't cleared.
118 * Sleep and retry once.
119 */
120 usleep_range(I2C_OCTEON_EVENT_WAIT, 2 * I2C_OCTEON_EVENT_WAIT);
121 return octeon_i2c_hlc_test_valid(i2c);
122}
123
124static void octeon_i2c_hlc_int_clear(struct octeon_i2c *i2c) 86static void octeon_i2c_hlc_int_clear(struct octeon_i2c *i2c)
125{ 87{
126 /* clear ST/TS events, listen for neither */ 88 /* clear ST/TS events, listen for neither */
@@ -176,7 +138,6 @@ static void octeon_i2c_hlc_disable(struct octeon_i2c *i2c)
176 */ 138 */
177static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c) 139static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
178{ 140{
179 bool first = true;
180 int time_left; 141 int time_left;
181 142
182 /* 143 /*
@@ -195,7 +156,7 @@ static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
195 156
196 i2c->hlc_int_enable(i2c); 157 i2c->hlc_int_enable(i2c);
197 time_left = wait_event_timeout(i2c->queue, 158 time_left = wait_event_timeout(i2c->queue,
198 octeon_i2c_hlc_test_ready(i2c, &first), 159 octeon_i2c_hlc_test_valid(i2c),
199 i2c->adap.timeout); 160 i2c->adap.timeout);
200 i2c->hlc_int_disable(i2c); 161 i2c->hlc_int_disable(i2c);
201 if (!time_left) 162 if (!time_left)