]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.16.3/acpi-ec-add-support-to-disallow-qr_ec-to-be-issued-when-sci_evt-isn-t-set.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / acpi-ec-add-support-to-disallow-qr_ec-to-be-issued-when-sci_evt-isn-t-set.patch
CommitLineData
bf9ffb20
GKH
1From 3afcf2ece453e1a8c2c6de19cdf06da3772a1b08 Mon Sep 17 00:00:00 2001
2From: Lv Zheng <lv.zheng@intel.com>
3Date: Thu, 21 Aug 2014 14:41:13 +0800
4Subject: ACPI / EC: Add support to disallow QR_EC to be issued when SCI_EVT isn't set
5
6From: Lv Zheng <lv.zheng@intel.com>
7
8commit 3afcf2ece453e1a8c2c6de19cdf06da3772a1b08 upstream.
9
10There is a platform refusing to respond QR_EC when SCI_EVT isn't set
11(Acer Aspire V5-573G).
12
13Currently, we rely on the behaviour that the EC firmware can respond
14something (for example, 0x00 to indicate "no outstanding events") to
15QR_EC even when SCI_EVT is not set, but the reporter has complained
16about AC/battery pluging/unpluging and video brightness change delay
17on that platform.
18
19This is because the work item that has issued QR_EC has to wait until
20timeout in this case, and the _Qxx method evaluation work item queued
21after QR_EC one is delayed.
22
23It sounds reasonable to fix this issue by:
24 1. Implementing SCI_EVT sanity check before issuing QR_EC in the EC
25 driver's main state machine.
26 2. Moving QR_EC issuing out of the work queue used by _Qxx evaluation
27 to a seperate IRQ handling thread.
28
29This patch fixes this issue using solution 1.
30
31By disallowing QR_EC to be issued when SCI_EVT isn't set, we are able to
32handle such platform in the EC driver's main state machine. This patch
33enhances the state machine in this way to survive with such malfunctioning
34EC firmware.
35
36Note that this patch can also fix CLEAR_ON_RESUME quirk which also relies
37on the assumption that the platforms are able to respond even when SCI_EVT
38isn't set.
39
40Fixes: c0d653412fc8 ACPI / EC: Fix race condition in ec_transaction_completed()
41Link: https://bugzilla.kernel.org/show_bug.cgi?id=82611
42Reported-and-tested-by: Alexander Mezin <mezin.alexander@gmail.com>
43Signed-off-by: Lv Zheng <lv.zheng@intel.com>
44Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
45Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
46
47---
48 drivers/acpi/ec.c | 17 ++++++++++++++++-
49 1 file changed, 16 insertions(+), 1 deletion(-)
50
51--- a/drivers/acpi/ec.c
52+++ b/drivers/acpi/ec.c
53@@ -197,6 +197,8 @@ static bool advance_transaction(struct a
54 t->rdata[t->ri++] = acpi_ec_read_data(ec);
55 if (t->rlen == t->ri) {
56 t->flags |= ACPI_EC_COMMAND_COMPLETE;
57+ if (t->command == ACPI_EC_COMMAND_QUERY)
58+ pr_debug("hardware QR_EC completion\n");
59 wakeup = true;
60 }
61 } else
62@@ -208,7 +210,20 @@ static bool advance_transaction(struct a
63 }
64 return wakeup;
65 } else {
66- if ((status & ACPI_EC_FLAG_IBF) == 0) {
67+ /*
68+ * There is firmware refusing to respond QR_EC when SCI_EVT
69+ * is not set, for which case, we complete the QR_EC
70+ * without issuing it to the firmware.
71+ * https://bugzilla.kernel.org/show_bug.cgi?id=86211
72+ */
73+ if (!(status & ACPI_EC_FLAG_SCI) &&
74+ (t->command == ACPI_EC_COMMAND_QUERY)) {
75+ t->flags |= ACPI_EC_COMMAND_POLL;
76+ t->rdata[t->ri++] = 0x00;
77+ t->flags |= ACPI_EC_COMMAND_COMPLETE;
78+ pr_debug("software QR_EC completion\n");
79+ wakeup = true;
80+ } else if ((status & ACPI_EC_FLAG_IBF) == 0) {
81 acpi_ec_write_cmd(ec, t->command);
82 t->flags |= ACPI_EC_COMMAND_POLL;
83 } else