|
Lee, Chun-Yi |
12d6fa |
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
|
|
Lee, Chun-Yi |
12d6fa |
Date: Tue, 23 Nov 2021 19:37:39 +0100
|
|
Lee, Chun-Yi |
12d6fa |
Subject: ACPI: EC: Call advance_transaction() from acpi_ec_dispatch_gpe()
|
|
Lee, Chun-Yi |
12d6fa |
Patch-mainline: v5.17-rc1
|
|
Lee, Chun-Yi |
12d6fa |
Git-commit: ca8283dcd933a2ca776fade77fb4527321521463
|
|
Lee, Chun-Yi |
12d6fa |
References: jsc#PED-1408
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
Calling acpi_dispatch_gpe() from acpi_ec_dispatch_gpe() is generally
|
|
Lee, Chun-Yi |
12d6fa |
problematic, because it may cause the spurious interrupt handling in
|
|
Lee, Chun-Yi |
12d6fa |
advance_transaction() to trigger in theory.
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
However, instead of calling acpi_dispatch_gpe() to dispatch the EC
|
|
Lee, Chun-Yi |
12d6fa |
GPE, acpi_ec_dispatch_gpe() can call advance_transaction() directly
|
|
Lee, Chun-Yi |
12d6fa |
on first_ec and it can pass 'false' as its second argument to indicate
|
|
Lee, Chun-Yi |
12d6fa |
calling it from process context.
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
Moreover, if advance_transaction() is modified to return a bool value
|
|
Lee, Chun-Yi |
12d6fa |
indicating whether or not the EC work needs to be flushed, it can be
|
|
Lee, Chun-Yi |
12d6fa |
used to avoid unnecessary EC work flushing in acpi_ec_dispatch_gpe(),
|
|
Lee, Chun-Yi |
12d6fa |
so change the code accordingly.
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
|
Lee, Chun-Yi |
12d6fa |
Acked-by: Lee, Chun-Yi <jlee@suse.com>
|
|
Lee, Chun-Yi |
12d6fa |
---
|
|
Lee, Chun-Yi |
12d6fa |
drivers/acpi/ec.c | 39 ++++++++++++++++++++++++++++-----------
|
|
Lee, Chun-Yi |
12d6fa |
1 file changed, 28 insertions(+), 11 deletions(-)
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
--- a/drivers/acpi/ec.c
|
|
Lee, Chun-Yi |
12d6fa |
+++ b/drivers/acpi/ec.c
|
|
Lee, Chun-Yi |
12d6fa |
@@ -170,7 +170,7 @@ struct acpi_ec_query {
|
|
Lee, Chun-Yi |
12d6fa |
};
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
static int acpi_ec_query(struct acpi_ec *ec, u8 *data);
|
|
Lee, Chun-Yi |
12d6fa |
-static void advance_transaction(struct acpi_ec *ec, bool interrupt);
|
|
Lee, Chun-Yi |
12d6fa |
+static bool advance_transaction(struct acpi_ec *ec, bool interrupt);
|
|
Lee, Chun-Yi |
12d6fa |
static void acpi_ec_event_handler(struct work_struct *work);
|
|
Lee, Chun-Yi |
12d6fa |
static void acpi_ec_event_processor(struct work_struct *work);
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
@@ -444,18 +444,25 @@ static bool acpi_ec_submit_flushable_req
|
|
Lee, Chun-Yi |
12d6fa |
return true;
|
|
Lee, Chun-Yi |
12d6fa |
}
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
-static void acpi_ec_submit_query(struct acpi_ec *ec)
|
|
Lee, Chun-Yi |
12d6fa |
+static bool acpi_ec_submit_query(struct acpi_ec *ec)
|
|
Lee, Chun-Yi |
12d6fa |
{
|
|
Lee, Chun-Yi |
12d6fa |
acpi_ec_mask_events(ec);
|
|
Lee, Chun-Yi |
12d6fa |
if (!acpi_ec_event_enabled(ec))
|
|
Lee, Chun-Yi |
12d6fa |
- return;
|
|
Lee, Chun-Yi |
12d6fa |
+ return false;
|
|
Lee, Chun-Yi |
12d6fa |
+
|
|
Lee, Chun-Yi |
12d6fa |
if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) {
|
|
Lee, Chun-Yi |
12d6fa |
ec_dbg_evt("Command(%s) submitted/blocked",
|
|
Lee, Chun-Yi |
12d6fa |
acpi_ec_cmd_string(ACPI_EC_COMMAND_QUERY));
|
|
Lee, Chun-Yi |
12d6fa |
ec->nr_pending_queries++;
|
|
Lee, Chun-Yi |
12d6fa |
ec->events_in_progress++;
|
|
Lee, Chun-Yi |
12d6fa |
- queue_work(ec_wq, &ec->work);
|
|
Lee, Chun-Yi |
12d6fa |
+ return queue_work(ec_wq, &ec->work);
|
|
Lee, Chun-Yi |
12d6fa |
}
|
|
Lee, Chun-Yi |
12d6fa |
+
|
|
Lee, Chun-Yi |
12d6fa |
+ /*
|
|
Lee, Chun-Yi |
12d6fa |
+ * The event handling work has not been completed yet, so it needs to be
|
|
Lee, Chun-Yi |
12d6fa |
+ * flushed.
|
|
Lee, Chun-Yi |
12d6fa |
+ */
|
|
Lee, Chun-Yi |
12d6fa |
+ return true;
|
|
Lee, Chun-Yi |
12d6fa |
}
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
static void acpi_ec_complete_query(struct acpi_ec *ec)
|
|
Lee, Chun-Yi |
12d6fa |
@@ -628,10 +635,11 @@ static void acpi_ec_spurious_interrupt(s
|
|
Lee, Chun-Yi |
12d6fa |
acpi_ec_mask_events(ec);
|
|
Lee, Chun-Yi |
12d6fa |
}
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
-static void advance_transaction(struct acpi_ec *ec, bool interrupt)
|
|
Lee, Chun-Yi |
12d6fa |
+static bool advance_transaction(struct acpi_ec *ec, bool interrupt)
|
|
Lee, Chun-Yi |
12d6fa |
{
|
|
Lee, Chun-Yi |
12d6fa |
struct transaction *t = ec->curr;
|
|
Lee, Chun-Yi |
12d6fa |
bool wakeup = false;
|
|
Lee, Chun-Yi |
12d6fa |
+ bool ret = false;
|
|
Lee, Chun-Yi |
12d6fa |
u8 status;
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
ec_dbg_stm("%s (%d)", interrupt ? "IRQ" : "TASK", smp_processor_id());
|
|
Lee, Chun-Yi |
12d6fa |
@@ -698,10 +706,12 @@ static void advance_transaction(struct a
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
out:
|
|
Lee, Chun-Yi |
12d6fa |
if (status & ACPI_EC_FLAG_SCI)
|
|
Lee, Chun-Yi |
12d6fa |
- acpi_ec_submit_query(ec);
|
|
Lee, Chun-Yi |
12d6fa |
+ ret = acpi_ec_submit_query(ec);
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
if (wakeup && interrupt)
|
|
Lee, Chun-Yi |
12d6fa |
wake_up(&ec->wait);
|
|
Lee, Chun-Yi |
12d6fa |
+
|
|
Lee, Chun-Yi |
12d6fa |
+ return ret;
|
|
Lee, Chun-Yi |
12d6fa |
}
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
static void start_transaction(struct acpi_ec *ec)
|
|
Lee, Chun-Yi |
12d6fa |
@@ -2038,8 +2048,7 @@ void acpi_ec_set_gpe_wake_mask(u8 action
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
bool acpi_ec_dispatch_gpe(void)
|
|
Lee, Chun-Yi |
12d6fa |
{
|
|
Lee, Chun-Yi |
12d6fa |
- bool work_in_progress;
|
|
Lee, Chun-Yi |
12d6fa |
- u32 ret;
|
|
Lee, Chun-Yi |
12d6fa |
+ bool work_in_progress = false;
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
if (!first_ec)
|
|
Lee, Chun-Yi |
12d6fa |
return acpi_any_gpe_status_set(U32_MAX);
|
|
Lee, Chun-Yi |
12d6fa |
@@ -2055,9 +2064,17 @@ bool acpi_ec_dispatch_gpe(void)
|
|
Lee, Chun-Yi |
12d6fa |
* Dispatch the EC GPE in-band, but do not report wakeup in any case
|
|
Lee, Chun-Yi |
12d6fa |
* to allow the caller to process events properly after that.
|
|
Lee, Chun-Yi |
12d6fa |
*/
|
|
Lee, Chun-Yi |
12d6fa |
- ret = acpi_dispatch_gpe(NULL, first_ec->gpe);
|
|
Lee, Chun-Yi |
12d6fa |
- if (ret == ACPI_INTERRUPT_HANDLED)
|
|
Lee, Chun-Yi |
12d6fa |
- pm_pr_dbg("ACPI EC GPE dispatched\n");
|
|
Lee, Chun-Yi |
12d6fa |
+ spin_lock_irq(&first_ec->lock);
|
|
Lee, Chun-Yi |
12d6fa |
+
|
|
Lee, Chun-Yi |
12d6fa |
+ if (acpi_ec_gpe_status_set(first_ec))
|
|
Lee, Chun-Yi |
12d6fa |
+ work_in_progress = advance_transaction(first_ec, false);
|
|
Lee, Chun-Yi |
12d6fa |
+
|
|
Lee, Chun-Yi |
12d6fa |
+ spin_unlock_irq(&first_ec->lock);
|
|
Lee, Chun-Yi |
12d6fa |
+
|
|
Lee, Chun-Yi |
12d6fa |
+ if (!work_in_progress)
|
|
Lee, Chun-Yi |
12d6fa |
+ return false;
|
|
Lee, Chun-Yi |
12d6fa |
+
|
|
Lee, Chun-Yi |
12d6fa |
+ pm_pr_dbg("ACPI EC GPE dispatched\n");
|
|
Lee, Chun-Yi |
12d6fa |
|
|
Lee, Chun-Yi |
12d6fa |
/* Drain EC work. */
|
|
Lee, Chun-Yi |
12d6fa |
do {
|