Skip to contentSkip to conversation

acpi: reboot: fix racing after writing to ACPI RESET_REG

PATCH Applied Zhang Rui 2 participants 2 messages Oct 13, 2020 – Oct 16, 2020 ACPI

lore
Share & tools
lore

Zhang Rui

author
#0 lore raw

PATCH v2 1/1 acpi: reboot: fix racing after writing to ACPI RESET_REG

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.

---
 drivers/acpi/reboot.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/acpi/reboot.c +10 -0
index ca707f5b521d..0e357cb5612f 100644
@@ -3,6 +3,7 @@
 #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)
@@ -66,4 +67,13 @@ void acpi_reboot(void)
 		acpi_reset();
 		break;
 	}
+
+	/*
+	 * Some platforms do not shutdown immediately after writing to the
+	 * ACPI reset register, and this results in racing with the
+	 * subsequetial reboot mechanism.
+	 * Delay for 15ms has been proved to be long enough for the system
+	 * to reboot, for these platforms.
+	 */
+	mdelay(15);
 }
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 31 lines · Zhang Rui

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.

---
 drivers/acpi/reboot.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/acpi/reboot.c +2 -0
index ca707f5b521d..0e357cb5612f 100644
@@ -3,6 +3,7 @@
 #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)
@@ -66,4 +67,13 @@ void acpi_reboot(void)
                acpi_reset();
                break;
        }
+

drivers/acpi/reboot.c void acpi_reboot(void)

Quoted 10 lines
drivers/acpi/reboot.c +8 -1
+       /*
+        * Some platforms do not shutdown immediately after writing to the
+        * ACPI reset register, and this results in racing with the
+        * subsequetial reboot mechanism.
+        * Delay for 15ms has been proved to be long enough for the system
+        * to reboot, for these platforms.
+        */
+       mdelay(15);
 }
--

Applied as 5.10-rc material with some edits in the comment above and subject.

Thanks!