alistair23-linux/drivers/acpi
Lv Zheng 66b42b78bc ACPI / EC: Avoid race condition related to advance_transaction()
The advance_transaction() will be invoked from the IRQ context GPE handler
and the task context ec_poll(). The handling of this function is locked so
that the EC state machine are ensured to be advanced sequentially.

But there is a problem. Before invoking advance_transaction(), EC_SC(R) is
read. Then for advance_transaction(), there could be race condition around
the lock from both contexts. The first one reading the register could fail
this race and when it passes the stale register value to the state machine
advancement code, the hardware condition is totally different from when
the register is read. And the hardware accesses determined from the wrong
hardware status can break the EC state machine. And there could be cases
that the functionalities of the platform firmware are seriously affected.
For example:
 1. When 2 EC_DATA(W) writes compete the IBF=0, the 2nd EC_DATA(W) write may
    be invalid due to IBF=1 after the 1st EC_DATA(W) write. Then the
    hardware will either refuse to respond a next EC_SC(W) write of the next
    command or discard the current WR_EC command when it receives a EC_SC(W)
    write of the next command.
 2. When 1 EC_SC(W) write and 1 EC_DATA(W) write compete the IBF=0, the
    EC_DATA(W) write may be invalid due to IBF=1 after the EC_SC(W) write.
    The next EC_DATA(R) could never be responded by the hardware. This is
    the root cause of the reported issue.

Fix this issue by moving the EC_SC(R) access into the lock so that we can
ensure that the state machine is advanced consistently.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=70891
Link: https://bugzilla.kernel.org/show_bug.cgi?id=63931
Link: https://bugzilla.kernel.org/show_bug.cgi?id=59911
Reported-and-tested-by: Gareth Williams <gareth@garethwilliams.me.uk>
Reported-and-tested-by: Hans de Goede <jwrdegoede@fedoraproject.org>
Reported-by: Barton Xu <tank.xuhan@gmail.com>
Tested-by: Steffen Weber <steffen.weber@gmail.com>
Tested-by: Arthur Chen <axchen@nvidia.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-07-07 12:50:25 +02:00
..
acpica ACPICA: Namespace: Remove _PRP method support. 2014-06-03 14:53:35 +02:00
apei ACPI: Clean up acpi_os_map/unmap_memory() to eliminate __iomem. 2014-05-27 18:13:08 +02:00
ac.c ACPI: Revert "ACPI / AC: convert ACPI ac driver to platform bus" 2014-05-08 00:37:28 +02:00
acpi_cmos_rtc.c ACPI / PNP: use device ID list for PNPACPI device enumeration 2014-05-30 16:04:35 +02:00
acpi_extlog.c ACPI: Clean up acpi_os_map/unmap_memory() to eliminate __iomem. 2014-05-27 18:13:08 +02:00
acpi_ipmi.c
acpi_lpss.c ACPI / LPSS: Take I2C host controllers out of reset 2014-06-17 13:46:48 +02:00
acpi_memhotplug.c ACPI / scan: always register memory hotplug scan handler 2014-05-30 16:04:36 +02:00
acpi_pad.c ACPI / PAD: Use time_before() for time comparison 2014-05-27 01:38:23 +02:00
acpi_platform.c Merge branch 'acpi-platform' 2014-06-03 23:11:52 +02:00
acpi_pnp.c ACPI / scan: drop unsupported serial IDs from PNP ACPI scan handler ID list 2014-05-30 16:04:36 +02:00
acpi_processor.c ACPI / processor: Check if LAPIC is present during initialization 2014-05-16 16:27:35 +02:00
battery.c Merge branches 'acpi-general', 'acpi-processor', 'acpi-lpss' and 'acpi-battery' 2014-06-19 14:40:48 +02:00
battery.h ACPI / battery: move some ACPI_BATTERY_* definitions to header 2014-03-19 01:57:46 +01:00
bgrt.c
blacklist.c ACPI / blacklist: Add dmi_enable_osi_linux quirk for Asus EEE PC 1015PX 2014-05-08 00:35:50 +02:00
bus.c Merge branch 'acpica' 2014-06-03 23:12:27 +02:00
button.c ACPI / button: Add ACPI Button event via netlink routine 2014-03-19 02:06:15 +01:00
cm_sbs.c ACPI: Revert "ACPI: Remove CONFIG_ACPI_PROCFS_POWER and cm_sbsc.c" 2014-05-06 01:52:09 +02:00
container.c ACPI / scan: always register container scan handler 2014-05-30 16:04:36 +02:00
custom_method.c
debugfs.c
device_pm.c ACPI / PM: Export rest of the subsys PM callbacks 2014-05-20 13:23:07 +02:00
dock.c ACPI / dock: Drop dock_device_ids[] table 2014-04-07 14:11:35 +02:00
ec.c ACPI / EC: Avoid race condition related to advance_transaction() 2014-07-07 12:50:25 +02:00
ec_sys.c
event.c
fan.c
glue.c
hed.c
internal.h ACPI / scan: always register ACPI LPSS scan handler 2014-05-30 16:04:36 +02:00
Kconfig ACPI / proc: Do not say when /proc interfaces will be deleted in Kconfig 2014-05-10 13:51:36 +02:00
Makefile ACPI / scan: always register ACPI LPSS scan handler 2014-05-30 16:04:36 +02:00
numa.c
nvs.c ACPI: Clean up acpi_os_map/unmap_memory() to eliminate __iomem. 2014-05-27 18:13:08 +02:00
osl.c ACPI: use kstrto*() instead of simple_strto*() 2014-06-17 14:01:56 +02:00
pci_irq.c
pci_link.c ACPI: Remove duplicate definitions of PREFIX 2014-03-19 02:01:57 +01:00
pci_root.c Merge branches 'acpi-cleanup', 'acpi-thermal', 'acpi-pci', 'acpi-lpss' and 'acpi-button' 2014-03-20 13:20:47 +01:00
pci_slot.c
power.c ACPI: Remove duplicate definitions of PREFIX 2014-03-19 02:01:57 +01:00
proc.c
processor_core.c Merge branches 'acpi-processor' and 'pnp' 2014-04-01 22:09:50 +02:00
processor_driver.c ACPI / processor: Fix STARTING/DYING action in acpi_cpu_soft_notify() 2014-05-16 16:36:03 +02:00
processor_idle.c
processor_perflib.c
processor_thermal.c
processor_throttling.c
reboot.c
resource.c
sbs.c ACPI / battery: move some ACPI_BATTERY_* definitions to header 2014-03-19 01:57:46 +01:00
sbshc.c
sbshc.h
scan.c Merge branch 'acpi-enumeration' 2014-06-03 23:12:20 +02:00
sleep.c PM / sleep: trace events for suspend/resume 2014-06-07 00:18:07 +02:00
sleep.h
sysfs.c ACPI: Remove duplicate definitions of PREFIX 2014-03-19 02:01:57 +01:00
tables.c ACPI: use kstrto*() instead of simple_strto*() 2014-06-17 14:01:56 +02:00
thermal.c Merge back earlier ACPI thermal material. 2014-05-29 13:28:14 +02:00
utils.c ACPI: add dynamic_debug support 2014-05-26 14:38:57 +02:00
video.c ACPI / video: Change the default for video.use_native_backlight to 1 2014-06-05 22:47:35 +02:00
video_detect.c ACPI: Remove duplicate definitions of PREFIX 2014-03-19 02:01:57 +01:00
wakeup.c