Jesse Keating 7a3296
https://bugzilla.kernel.org/show_bug.cgi?id=14733#c41
Jesse Keating 7a3296
Jesse Keating 7a3296
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
Jesse Keating 7a3296
index 27e0b92..09fbb69 100644
Jesse Keating 7a3296
--- a/drivers/acpi/ec.c
Jesse Keating 7a3296
+++ b/drivers/acpi/ec.c
Jesse Keating 7a3296
@@ -226,6 +226,7 @@ static int ec_poll(struct acpi_ec *ec)
Jesse Keating 7a3296
 				if (ec_transaction_done(ec))
Jesse Keating 7a3296
 					return 0;
Jesse Keating 7a3296
 			} else {
Jesse Keating 7a3296
+				msleep(1);
Jesse Keating 7a3296
 				if (wait_event_timeout(ec->wait,
Jesse Keating 7a3296
 						ec_transaction_done(ec),
Jesse Keating 7a3296
 						msecs_to_jiffies(1)))
Jesse Keating 7a3296
@@ -233,8 +234,8 @@ static int ec_poll(struct acpi_ec *ec)
Jesse Keating 7a3296
 			}
Jesse Keating 7a3296
 			advance_transaction(ec, acpi_ec_read_status(ec));
Jesse Keating 7a3296
 		} while (time_before(jiffies, delay));
Jesse Keating 7a3296
-		if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
Jesse Keating 7a3296
-			break;
Jesse Keating 7a3296
+//		if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
Jesse Keating 7a3296
+//			break;
Jesse Keating 7a3296
 		pr_debug(PREFIX "controller reset, restart transaction\n");
Jesse Keating 7a3296
 		spin_lock_irqsave(&ec->curr_lock, flags);
Jesse Keating 7a3296
 		start_transaction(ec);
Jesse Keating 7a3296
@@ -271,15 +272,25 @@ static int ec_check_ibf0(struct acpi_ec *ec)
Jesse Keating 7a3296
 	return (status & ACPI_EC_FLAG_IBF) == 0;
Jesse Keating 7a3296
 }
Jesse Keating 7a3296
 
Jesse Keating 7a3296
+/* try to clean input buffer with burst_disable transaction */
Jesse Keating 7a3296
+static int acpi_ec_clean_buffer(struct acpi_ec *ec)
Jesse Keating 7a3296
+{
Jesse Keating 7a3296
+	struct transaction t = {.command = ACPI_EC_BURST_DISABLE,
Jesse Keating 7a3296
+				.wdata = NULL, .rdata = NULL,
Jesse Keating 7a3296
+				.wlen = 0, .rlen = 0};
Jesse Keating 7a3296
+	return acpi_ec_transaction_unlocked(ec, &t);
Jesse Keating 7a3296
+}
Jesse Keating 7a3296
+
Jesse Keating 7a3296
 static int ec_wait_ibf0(struct acpi_ec *ec)
Jesse Keating 7a3296
 {
Jesse Keating 7a3296
+	
Jesse Keating 7a3296
 	unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
Jesse Keating 7a3296
 	/* interrupt wait manually if GPE mode is not active */
Jesse Keating 7a3296
 	while (time_before(jiffies, delay))
Jesse Keating 7a3296
 		if (wait_event_timeout(ec->wait, ec_check_ibf0(ec),
Jesse Keating 7a3296
 					msecs_to_jiffies(1)))
Jesse Keating 7a3296
 			return 0;
Jesse Keating 7a3296
-	return -ETIME;
Jesse Keating 7a3296
+	return acpi_ec_clean_buffer(ec);
Jesse Keating 7a3296
 }
Jesse Keating 7a3296
 
Jesse Keating 7a3296
 static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)