ACPI: reboot: Avoid racing after writing to ACPI RESET_REG
authorZhang Rui <rui.zhang@intel.com>
Tue, 13 Oct 2020 07:35:57 +0000 (15:35 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 16 Oct 2020 16:04:52 +0000 (18:04 +0200)
According to the ACPI spec, "The system must reset immediately following
the write to the ACPI RESET_REG register.", but there are cases that the
system does not follow this and results in racing with the subsequetial
reboot mechanism, which brings unexpected behavior.

Fix this by adding a 15ms delay after writing to the ACPI RESET_REG.

Reported-by: Ghorai, Sukumar <sukumar.ghorai@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[ rjw: Edit comment in the code and subject ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/reboot.c

index ca707f5b521d0990370e9f7fdbc531d97497cb4f..2a61f884e2228c8c64a62e1c15a0b73988ea7f90 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <acpi/reboot.h>
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <acpi/reboot.h>
+#include <linux/delay.h>
 
 #ifdef CONFIG_PCI
 static void acpi_pci_reboot(struct acpi_generic_address *rr, u8 reset_value)
 
 #ifdef CONFIG_PCI
 static void acpi_pci_reboot(struct acpi_generic_address *rr, u8 reset_value)
@@ -66,4 +67,14 @@ void acpi_reboot(void)
                acpi_reset();
                break;
        }
                acpi_reset();
                break;
        }
+
+       /*
+        * Some platforms do not shut down immediately after writing to the
+        * ACPI reset register, and this results in racing with the
+        * subsequent reboot mechanism.
+        *
+        * The 15ms delay has been found to be long enough for the system
+        * to reboot on the affected platforms.
+        */
+       mdelay(15);
 }
 }