From: Lv Zheng Subject: [DBG PATCH] ACPI/EC: Add support to disallow QR_EC issued when SCI_EVT isn't set. Currently we rely on the behaviour that the firmware can respond something (for example, 0x00 to indicate "no outstanding events") to QR_EC even when SCI_EVT is not set. But reporters has complained for AC/battery pluging/unpluging, video brightness change delay caused on such platform that the EC firmware refuse to respond QR_EC when SCI_EVT isn't set. This is because the work queue that has issued QR_EC has to wait until timeout in this case, and the _Qxx method evaluation queued after this work item will be delayed. By disallowing QR_EC issuing without completing the previous one, we are able to handle this case. Note that this patch can also fix CLEAR_ON_RESUME quirk which also relies on this behavior. Link: https://bugzilla.kernel.org/show_bug.cgi?id=82611 Reported-by: Alexander Mezin Signed-off-by: Lv Zheng --- Index: linux-acpica/drivers/acpi/ec.c =================================================================== --- linux-acpica.orig/drivers/acpi/ec.c +++ linux-acpica/drivers/acpi/ec.c @@ -186,6 +186,21 @@ static bool advance_transaction(struct a t = ec->curr; if (!t) goto err; + /* + * There is firmware refusing to respond QR_EC when SCI_EVT is not + * set, for which case, we complete the QR_EC without issuing it to + * the firmware. + * https://bugzilla.kernel.org/show_bug.cgi?id=86211 + */ + if (t->command == ACPI_EC_COMMAND_QUERY && + !(t->flags & ACPI_EC_COMMAND_POLL) && + !(status & ACPI_EC_FLAG_SCI)) { + pr_debug("gpe query is completed by software\n"); + t->flags |= ACPI_EC_COMMAND_POLL; + t->rdata[t->ri++] = 0x00; + t->flags |= ACPI_EC_COMMAND_COMPLETE; + wakeup = true; + } if (t->flags & ACPI_EC_COMMAND_POLL) { if (t->wlen > t->wi) { if ((status & ACPI_EC_FLAG_IBF) == 0) @@ -196,6 +211,8 @@ static bool advance_transaction(struct a if ((status & ACPI_EC_FLAG_OBF) == 1) { t->rdata[t->ri++] = acpi_ec_read_data(ec); if (t->rlen == t->ri) { + if (t->command == ACPI_EC_COMMAND_QUERY) + pr_debug("gpe query is completed by hardware\n"); t->flags |= ACPI_EC_COMMAND_COMPLETE; wakeup = true; }