]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/revert-acpi-ec-remove-old-clear_on_resume-quirk.patch
autosel patches for 5.0
[thirdparty/kernel/stable-queue.git] / queue-5.0 / revert-acpi-ec-remove-old-clear_on_resume-quirk.patch
1 From f498fb3b053fbe31b1bbc4daf7b246946d8f27ea Mon Sep 17 00:00:00 2001
2 From: Zhang Rui <rui.zhang@intel.com>
3 Date: Fri, 1 Feb 2019 14:13:41 +0800
4 Subject: Revert "ACPI / EC: Remove old CLEAR_ON_RESUME quirk"
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 [ Upstream commit b6a3e1475b0220378ad32bdf4d8692f058b1fc03 ]
10
11 On some Samsung hardware, it is necessary to clear events accumulated by
12 the EC during sleep. These ECs stop reporting GPEs until they are manually
13 polled, if too many events are accumulated.
14 Thus the CLEAR_ON_RESUME quirk is introduced to send EC query commands
15 unconditionally after resume to clear all the EC query events on those
16 platforms.
17
18 Later, commit 4c237371f290 ("ACPI / EC: Remove old CLEAR_ON_RESUME quirk")
19 removes the CLEAR_ON_RESUME quirk because we thought the new EC IRQ
20 polling logic should handle this case.
21
22 Now it has been proved that the EC IRQ Polling logic does not fix the
23 issue actually because we got regression report on these Samsung
24 platforms after removing the quirk.
25
26 Thus revert commit 4c237371f290 ("ACPI / EC: Remove old CLEAR_ON_RESUME
27 quirk") to introduce back the Samsung quirk in this patch.
28
29 Link: https://bugzilla.kernel.org/show_bug.cgi?id=44161
30 Tested-by: Ortwin Glück <odi@odi.ch>
31 Tested-by: Francisco Cribari <cribari@gmail.com>
32 Tested-by: Balazs Varga <balazs4web@gmail.com>
33 Signed-off-by: Zhang Rui <rui.zhang@intel.com>
34 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
35 Signed-off-by: Sasha Levin <sashal@kernel.org>
36 ---
37 drivers/acpi/ec.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
38 1 file changed, 53 insertions(+)
39
40 diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
41 index 9d66a47d32fb..49e16f009095 100644
42 --- a/drivers/acpi/ec.c
43 +++ b/drivers/acpi/ec.c
44 @@ -194,6 +194,7 @@ static struct workqueue_struct *ec_query_wq;
45 static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */
46 static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */
47 static int EC_FLAGS_IGNORE_DSDT_GPE; /* Needs ECDT GPE as correction setting */
48 +static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
49
50 /* --------------------------------------------------------------------------
51 * Logging/Debugging
52 @@ -499,6 +500,26 @@ static inline void __acpi_ec_disable_event(struct acpi_ec *ec)
53 ec_log_drv("event blocked");
54 }
55
56 +/*
57 + * Process _Q events that might have accumulated in the EC.
58 + * Run with locked ec mutex.
59 + */
60 +static void acpi_ec_clear(struct acpi_ec *ec)
61 +{
62 + int i, status;
63 + u8 value = 0;
64 +
65 + for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) {
66 + status = acpi_ec_query(ec, &value);
67 + if (status || !value)
68 + break;
69 + }
70 + if (unlikely(i == ACPI_EC_CLEAR_MAX))
71 + pr_warn("Warning: Maximum of %d stale EC events cleared\n", i);
72 + else
73 + pr_info("%d stale EC events cleared\n", i);
74 +}
75 +
76 static void acpi_ec_enable_event(struct acpi_ec *ec)
77 {
78 unsigned long flags;
79 @@ -507,6 +528,10 @@ static void acpi_ec_enable_event(struct acpi_ec *ec)
80 if (acpi_ec_started(ec))
81 __acpi_ec_enable_event(ec);
82 spin_unlock_irqrestore(&ec->lock, flags);
83 +
84 + /* Drain additional events if hardware requires that */
85 + if (EC_FLAGS_CLEAR_ON_RESUME)
86 + acpi_ec_clear(ec);
87 }
88
89 #ifdef CONFIG_PM_SLEEP
90 @@ -1820,6 +1845,31 @@ static int ec_flag_query_handshake(const struct dmi_system_id *id)
91 }
92 #endif
93
94 +/*
95 + * On some hardware it is necessary to clear events accumulated by the EC during
96 + * sleep. These ECs stop reporting GPEs until they are manually polled, if too
97 + * many events are accumulated. (e.g. Samsung Series 5/9 notebooks)
98 + *
99 + * https://bugzilla.kernel.org/show_bug.cgi?id=44161
100 + *
101 + * Ideally, the EC should also be instructed NOT to accumulate events during
102 + * sleep (which Windows seems to do somehow), but the interface to control this
103 + * behaviour is not known at this time.
104 + *
105 + * Models known to be affected are Samsung 530Uxx/535Uxx/540Uxx/550Pxx/900Xxx,
106 + * however it is very likely that other Samsung models are affected.
107 + *
108 + * On systems which don't accumulate _Q events during sleep, this extra check
109 + * should be harmless.
110 + */
111 +static int ec_clear_on_resume(const struct dmi_system_id *id)
112 +{
113 + pr_debug("Detected system needing EC poll on resume.\n");
114 + EC_FLAGS_CLEAR_ON_RESUME = 1;
115 + ec_event_clearing = ACPI_EC_EVT_TIMING_STATUS;
116 + return 0;
117 +}
118 +
119 /*
120 * Some ECDTs contain wrong register addresses.
121 * MSI MS-171F
122 @@ -1869,6 +1919,9 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
123 ec_honor_ecdt_gpe, "ASUS X580VD", {
124 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
125 DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL},
126 + {
127 + ec_clear_on_resume, "Samsung hardware", {
128 + DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL},
129 {},
130 };
131
132 --
133 2.19.1
134