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