linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] acpi: reboot: fix racing after writing to ACPI RESET_REG
@ 2020-10-13  7:35 Zhang Rui
  2020-10-16 16:06 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Rui @ 2020-10-13  7:35 UTC (permalink / raw)
  To: linux-acpi, rjw; +Cc: sukumar.ghorai, rui.zhang

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>
---
 drivers/acpi/reboot.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index ca707f5b521d..0e357cb5612f 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -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);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] acpi: reboot: fix racing after writing to ACPI RESET_REG
  2020-10-13  7:35 [PATCH V2] acpi: reboot: fix racing after writing to ACPI RESET_REG Zhang Rui
@ 2020-10-16 16:06 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-10-16 16:06 UTC (permalink / raw)
  To: Zhang Rui; +Cc: ACPI Devel Maling List, Rafael J. Wysocki, sukumar.ghorai

On Tue, Oct 13, 2020 at 9:36 AM Zhang Rui <rui.zhang@intel.com> wrote:
>
> 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>
> ---
>  drivers/acpi/reboot.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
> index ca707f5b521d..0e357cb5612f 100644
> --- a/drivers/acpi/reboot.c
> +++ b/drivers/acpi/reboot.c
> @@ -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);
>  }
> --

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

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-16 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13  7:35 [PATCH V2] acpi: reboot: fix racing after writing to ACPI RESET_REG Zhang Rui
2020-10-16 16:06 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).