linux-stable/drivers/acpi
Rafael J. Wysocki 77af47f269 ACPI: EC: Rework flushing of EC work while suspended to idle
[ Upstream commit 4a9af6cac0 ]

The flushing of pending work in the EC driver uses drain_workqueue()
to flush the event handling work that can requeue itself via
advance_transaction(), but this is problematic, because that
work may also be requeued from the query workqueue.

Namely, if an EC transaction is carried out during the execution of
a query handler, it involves calling advance_transaction() which
may queue up the event handling work again.  This causes the kernel
to complain about attempts to add a work item to the EC event
workqueue while it is being drained and worst-case it may cause a
valid event to be skipped.

To avoid this problem, introduce two new counters, events_in_progress
and queries_in_progress, incremented when a work item is queued on
the event workqueue or the query workqueue, respectively, and
decremented at the end of the corresponding work function, and make
acpi_ec_dispatch_gpe() the workqueues in a loop until the both of
these counters are zero (or system wakeup is pending) instead of
calling acpi_ec_flush_work().

At the same time, change __acpi_ec_flush_work() to call
flush_workqueue() instead of drain_workqueue() to flush the event
workqueue.

While at it, use the observation that the work item queued in
acpi_ec_query() cannot be pending at that time, because it is used
only once, to simplify the code in there.

Additionally, clean up a comment in acpi_ec_query() and adjust white
space in acpi_ec_event_processor().

Fixes: f0ac20c3f6 ("ACPI: EC: Fix flushing of pending work")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-27 09:19:32 +01:00
..
acpica ACPICA: Avoid evaluating methods too early during system resume 2021-11-17 09:48:30 +01:00
apei x86/mm: split vmalloc_sync_all() 2020-03-25 08:25:58 +01:00
arm64 acpi/arm64: fix next_platform_timer() section mismatch error 2021-10-20 11:40:17 +02:00
dptf
hmat ACPI: HMAT: Fix handling of changes from ACPI 6.2 to ACPI 6.3 2020-11-05 11:43:19 +01:00
nfit ACPI: NFIT: Fix support for virtual SPA ranges 2021-08-18 08:56:57 +02:00
pmic ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses 2021-11-17 09:48:47 +01:00
x86 x86/intel: Aggregate big core mobile naming 2019-08-28 11:29:31 +02:00
ac.c
acpi_adxl.c
acpi_amba.c ACPI: AMBA: Fix resource name in /proc/iomem 2021-07-20 16:10:48 +02:00
acpi_apd.c i2c: imx: ACPI support for NXP i2c controller 2019-09-13 15:12:38 +01:00
acpi_cmos_rtc.c
acpi_configfs.c ACPI: configfs: add missing check after configfs_register_default_group() 2021-03-04 10:26:40 +01:00
acpi_dbg.c ACPI: debug: don't allow debugging when ACPI is disabled 2020-11-05 11:43:25 +01:00
acpi_extlog.c ACPI / extlog: Check for RDMSR failure 2020-11-05 11:43:24 +01:00
acpi_ipmi.c
acpi_lpat.c
acpi_lpit.c Merge branches 'acpi-pm' and 'pm-pci' 2019-07-08 10:49:36 +02:00
acpi_lpss.c ACPI: LPSS: Add dmi quirk for skipping _DEP check for some device-links 2019-12-17 19:56:32 +01:00
acpi_memhotplug.c mm/memory_hotplug: rename walk_memory_range() and pass start+size instead of pfns 2019-07-18 17:08:06 -07:00
acpi_pad.c ACPI: Use DEVICE_ATTR_<RW|RO|WO> macros 2021-07-14 16:53:25 +02:00
acpi_platform.c ACPI: platform: Unregister stale platform devices 2020-01-26 10:01:04 +01:00
acpi_pnp.c ACPI: PNP: compare the string length in the matching_id() 2020-12-30 11:51:32 +01:00
acpi_processor.c ACPI / processor: don't print errors for processorIDs == 0xff 2019-08-09 10:48:34 +02:00
acpi_tad.c ACPI: Use DEVICE_ATTR_<RW|RO|WO> macros 2021-07-14 16:53:25 +02:00
acpi_video.c ACPI: video: Add quirk for the Dell Vostro 3350 2021-07-20 16:10:48 +02:00
acpi_watchdog.c ACPI: watchdog: Allow disabling WDAT at boot 2020-03-21 08:11:47 +01:00
battery.c ACPI: battery: Accept charges over the design capacity as full 2021-11-17 09:48:30 +01:00
bgrt.c ACPI: bgrt: Fix CFI violation 2021-07-14 16:53:25 +02:00
blacklist.c ACPI: blacklist: fix clang warning for unused DMI table 2019-07-11 22:45:00 +02:00
bus.c ACPI: bus: Call kobject_put() in acpi_init() error path 2021-07-14 16:53:17 +02:00
button.c ACPI: button: Add DMI quirk for Medion Akoya E2228T 2020-11-24 13:29:00 +01:00
cm_sbs.c
container.c
cppc_acpi.c ACPI: CPPC: Replace cppc_attr with kobj_attribute 2021-05-14 09:44:20 +02:00
custom_method.c ACPI: custom_method: fix a possible memory leak 2021-05-11 14:04:01 +02:00
debugfs.c
device_pm.c PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup() 2020-12-30 11:51:32 +01:00
device_sysfs.c ACPI: Use DEVICE_ATTR_<RW|RO|WO> macros 2021-07-14 16:53:25 +02:00
dock.c ACPI: Use DEVICE_ATTR_<RW|RO|WO> macros 2021-07-14 16:53:25 +02:00
ec.c ACPI: EC: Rework flushing of EC work while suspended to idle 2022-01-27 09:19:32 +01:00
ec_sys.c
event.c
evged.c ACPI: GED: fix -Wformat 2020-11-22 10:14:12 +01:00
fan.c
glue.c
hed.c
internal.h ACPI: EC: Rework flushing of EC work while suspended to idle 2022-01-27 09:19:32 +01:00
ioapic.c
irq.c Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 11:01:13 -07:00
Kconfig ia64: remove support for machvecs 2019-08-16 14:32:26 -07:00
Makefile ACPI: tables: Add custom DSDT file as makefile prerequisite 2021-07-14 16:53:19 +02:00
numa.c ACPI: Add out of bounds and numa_off protections to pxm_to_node() 2020-11-05 11:43:18 +01:00
nvs.c
osi.c
osl.c ACPI: OSL: only free map once in osl.c 2019-12-17 19:56:33 +01:00
pci_irq.c ACPI / PCI: fix acpi_pci_irq_enable() memory leak 2019-09-03 09:41:25 +02:00
pci_link.c ACPI/PCI: Remove surplus parentheses from a return statement 2019-08-21 00:05:20 +02:00
pci_mcfg.c PCI/ACPI: Add Ampere Altra SOC MCFG quirk 2021-09-26 14:07:05 +02:00
pci_root.c PCI: Move ASPM declarations to linux/pci.h 2019-08-28 08:28:39 -05:00
pci_slot.c
power.c ACPI: Use DEVICE_ATTR_<RW|RO|WO> macros 2021-07-14 16:53:25 +02:00
pptt.c ACPI/PPTT: Add support for ACPI 6.3 thread flag 2019-08-12 12:59:15 +01:00
proc.c
processor_core.c
processor_driver.c cpufreq: Use per-policy frequency QoS 2019-10-21 02:05:21 +02:00
processor_idle.c ACPI: processor idle: Fix up C-state latency if not ordered 2021-07-14 16:53:16 +02:00
processor_pdc.c
processor_perflib.c ACPI: processor: Add QoS requests for all CPUs 2019-10-25 11:33:48 +02:00
processor_thermal.c ACPI: processor: Add QoS requests for all CPUs 2019-10-25 11:33:48 +02:00
processor_throttling.c x86: ACPI: fix CPU hotplug deadlock 2020-04-23 10:36:38 +02:00
property.c ACPI: property: Fix fwnode string properties matching 2021-03-04 10:26:40 +01:00
reboot.c
resource.c Revert "ACPI: resources: Add checks for ACPI IRQ override" 2021-08-04 12:27:37 +02:00
sbs.c
sbshc.c
sbshc.h ACPI: SBS: remove unused const variable 'SMBUS_PEC' 2019-08-23 12:55:09 +02:00
scan.c ACPI: scan: Fix a memory leak in an error handling path 2021-05-19 10:08:30 +02:00
sleep.c ACPI: EC: PM: Avoid flushing EC work when EC GPE is inactive 2020-05-27 17:46:10 +02:00
sleep.h ACPI: PM: Add acpi_[un]register_wakeup_handler() 2020-04-13 10:48:08 +02:00
spcr.c
sysfs.c ACPI: sysfs: Fix pm_profile_attr type 2020-06-30 15:37:06 -04:00
tables.c ACPI: tables: x86: Reserve memory occupied by ACPI tables 2021-05-07 10:51:36 +02:00
thermal.c ACPI: thermal: Do not call acpi_thermal_check() directly 2021-02-07 15:35:47 +01:00
utils.c
video_detect.c ACPI: video: Add missing callback back for Sony VPCEH3U1E 2021-03-30 14:35:23 +02:00
wakeup.c ACPI: PM: Add acpi_[un]register_wakeup_handler() 2020-04-13 10:48:08 +02:00