lkml.org 
[lkml]   [2020]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ACPI: EC: Fix flushing of pending work
Date
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Commit 016b87ca5c8c ("ACPI: EC: Rework flushing of pending work")
introduced a subtle bug into the flushing of pending EC work while
suspended to idle, which may cause the EC driver to fail to
re-enable the EC GPE after handling a non-wakeup event (like a
battery status change event, for example).

The problem is that one of the work items flushed by the
flush_scheduled_work() in __acpi_ec_flush_work() may disable the EC
GPE and schedule another work item expected to re-enable it, but that
new work item is not flushed, so __acpi_ec_flush_work() returns with
the EC GPE disabled and the CPU running it goes into an idle state
subsequently. If all of the other CPUs are in idle states at that
point, the EC GPE won't be re-enabled until at least one CPU is woken
up by another interrupt source, so system wakeup events that would
normally come from the EC then don't work.

This is reproducible on a Dell XPS13 9360 in my office which
sometimes stops reacting to power button and lid events (triggered
by the EC on that machine) after switching from AC power to battery
power or vice versa while suspended to idle (each of those switches
causes the EC GPE to trigger for several times in a row, but they
are not system wakeup events).

To avoid this problem, change __acpi_ec_flush_work() to call
drain_workqueue() on system_wq instead of flush_scheduled_work(),
which is sufficient to make it go away on the machine mentioned
above.

Fixes: 016b87ca5c8c ("ACPI: EC: Rework flushing of pending work")
Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/ec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-pm/drivers/acpi/ec.c
===================================================================
--- linux-pm.orig/drivers/acpi/ec.c
+++ linux-pm/drivers/acpi/ec.c
@@ -535,7 +535,7 @@ static void acpi_ec_enable_event(struct
#ifdef CONFIG_PM_SLEEP
static void __acpi_ec_flush_work(void)
{
- flush_scheduled_work(); /* flush ec->work */
+ drain_workqueue(system_wq); /* flush ec->work */
flush_workqueue(ec_query_wq); /* flush queries */
}



\
 
 \ /
  Last update: 2020-02-06 11:32    [W:0.101 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site