summaryrefslogtreecommitdiffstats
path: root/freed-ora/current/f13/acpi-ec-add-delay-before-write.patch
blob: af49cccbd7ab08a18a1c7043ecb72ad9be8cfb59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
https://bugzilla.kernel.org/show_bug.cgi?id=14733#c41

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