diff options
author | Alexey Starikovskiy <astarikovskiy@suse.de> | 2008-11-11 17:40:19 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-11-11 18:34:41 -0500 |
commit | a2f93aeadf97e870ff385030633a73e21146815d (patch) | |
tree | 6d61eac20c4f6daf54bc9ce9ff331e8d3555fff7 /drivers/acpi/ec.c | |
parent | dd15f8c42af09031e27da5b4d697ce925511f2e1 (diff) |
ACPI: EC: restart failed command
Restart current transaction if we recieved unexpected GPEs instead
of needed ones.
http://bugzilla.kernel.org/show_bug.cgi?id=11896
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r-- | drivers/acpi/ec.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index cebd65d2e2a9..34c67ca3bebe 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -100,6 +100,8 @@ struct transaction { | |||
100 | u8 *rdata; | 100 | u8 *rdata; |
101 | unsigned short irq_count; | 101 | unsigned short irq_count; |
102 | u8 command; | 102 | u8 command; |
103 | u8 wi; | ||
104 | u8 ri; | ||
103 | u8 wlen; | 105 | u8 wlen; |
104 | u8 rlen; | 106 | u8 rlen; |
105 | bool done; | 107 | bool done; |
@@ -185,26 +187,34 @@ static int ec_transaction_done(struct acpi_ec *ec) | |||
185 | return ret; | 187 | return ret; |
186 | } | 188 | } |
187 | 189 | ||
190 | static void start_transaction(struct acpi_ec *ec) | ||
191 | { | ||
192 | ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0; | ||
193 | ec->curr->done = false; | ||
194 | acpi_ec_write_cmd(ec, ec->curr->command); | ||
195 | } | ||
196 | |||
188 | static void gpe_transaction(struct acpi_ec *ec, u8 status) | 197 | static void gpe_transaction(struct acpi_ec *ec, u8 status) |
189 | { | 198 | { |
190 | unsigned long flags; | 199 | unsigned long flags; |
191 | spin_lock_irqsave(&ec->curr_lock, flags); | 200 | spin_lock_irqsave(&ec->curr_lock, flags); |
192 | if (!ec->curr) | 201 | if (!ec->curr) |
193 | goto unlock; | 202 | goto unlock; |
194 | if (ec->curr->wlen > 0) { | 203 | if (ec->curr->wlen > ec->curr->wi) { |
195 | if ((status & ACPI_EC_FLAG_IBF) == 0) { | 204 | if ((status & ACPI_EC_FLAG_IBF) == 0) |
196 | acpi_ec_write_data(ec, *(ec->curr->wdata++)); | 205 | acpi_ec_write_data(ec, |
197 | --ec->curr->wlen; | 206 | ec->curr->wdata[ec->curr->wi++]); |
198 | } else | 207 | else |
199 | goto err; | 208 | goto err; |
200 | } else if (ec->curr->rlen > 0) { | 209 | } else if (ec->curr->rlen > ec->curr->ri) { |
201 | if ((status & ACPI_EC_FLAG_OBF) == 1) { | 210 | if ((status & ACPI_EC_FLAG_OBF) == 1) { |
202 | *(ec->curr->rdata++) = acpi_ec_read_data(ec); | 211 | ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec); |
203 | if (--ec->curr->rlen == 0) | 212 | if (ec->curr->rlen == ec->curr->ri) |
204 | ec->curr->done = true; | 213 | ec->curr->done = true; |
205 | } else | 214 | } else |
206 | goto err; | 215 | goto err; |
207 | } else if (ec->curr->wlen == 0 && (status & ACPI_EC_FLAG_IBF) == 0) | 216 | } else if (ec->curr->wlen == ec->curr->wi && |
217 | (status & ACPI_EC_FLAG_IBF) == 0) | ||
208 | ec->curr->done = true; | 218 | ec->curr->done = true; |
209 | goto unlock; | 219 | goto unlock; |
210 | err: | 220 | err: |
@@ -219,6 +229,15 @@ static int acpi_ec_wait(struct acpi_ec *ec) | |||
219 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), | 229 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), |
220 | msecs_to_jiffies(ACPI_EC_DELAY))) | 230 | msecs_to_jiffies(ACPI_EC_DELAY))) |
221 | return 0; | 231 | return 0; |
232 | /* try restart command if we get any false interrupts */ | ||
233 | if (ec->curr->irq_count && | ||
234 | (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { | ||
235 | pr_debug(PREFIX "controller reset, restart transaction\n"); | ||
236 | start_transaction(ec); | ||
237 | if (wait_event_timeout(ec->wait, ec_transaction_done(ec), | ||
238 | msecs_to_jiffies(ACPI_EC_DELAY))) | ||
239 | return 0; | ||
240 | } | ||
222 | /* missing GPEs, switch back to poll mode */ | 241 | /* missing GPEs, switch back to poll mode */ |
223 | if (printk_ratelimit()) | 242 | if (printk_ratelimit()) |
224 | pr_info(PREFIX "missing confirmations, " | 243 | pr_info(PREFIX "missing confirmations, " |
@@ -268,10 +287,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
268 | /* start transaction */ | 287 | /* start transaction */ |
269 | spin_lock_irqsave(&ec->curr_lock, tmp); | 288 | spin_lock_irqsave(&ec->curr_lock, tmp); |
270 | /* following two actions should be kept atomic */ | 289 | /* following two actions should be kept atomic */ |
271 | t->irq_count = 0; | ||
272 | t->done = false; | ||
273 | ec->curr = t; | 290 | ec->curr = t; |
274 | acpi_ec_write_cmd(ec, ec->curr->command); | 291 | start_transaction(ec); |
275 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) | 292 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) |
276 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); | 293 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
277 | spin_unlock_irqrestore(&ec->curr_lock, tmp); | 294 | spin_unlock_irqrestore(&ec->curr_lock, tmp); |