Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] acpi: reboot: fix racing after writing to ACPI RESET_REG
@ 2020-10-10  2:26 Zhang Rui
  2020-10-12 10:42 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Rui @ 2020-10-10  2:26 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 | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index ca707f5b521d..88e6b083d702 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,10 @@ void acpi_reboot(void)
 		acpi_reset();
 		break;
 	}
+
+	/*
+	 * delay for 15ms in case the system does not shutdown immediately after
+	 * writing to the ACPI reset register
+	 */
+	mdelay(15);
 }
-- 
2.17.1


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

* Re: [PATCH] acpi: reboot: fix racing after writing to ACPI RESET_REG
  2020-10-10  2:26 [PATCH] acpi: reboot: fix racing after writing to ACPI RESET_REG Zhang Rui
@ 2020-10-12 10:42 ` Rafael J. Wysocki
  2020-10-13  8:19   ` Zhang Rui
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2020-10-12 10:42 UTC (permalink / raw)
  To: Zhang Rui; +Cc: ACPI Devel Maling List, Rafael J. Wysocki, sukumar.ghorai

On Sat, Oct 10, 2020 at 4: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 | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
> index ca707f5b521d..88e6b083d702 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,10 @@ void acpi_reboot(void)
>                 acpi_reset();
>                 break;
>         }
> +
> +       /*
> +        * delay for 15ms in case the system does not shutdown immediately after
> +        * writing to the ACPI reset register

It would also be good to make a note of where the 15ms value comes from.

Even if it has been guessed, it will still be good to know that, say,
5 years from now.

> +        */
> +       mdelay(15);
>  }
> --
> 2.17.1
>

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

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

On Mon, 2020-10-12 at 12:42 +0200, Rafael J. Wysocki wrote:
> On Sat, Oct 10, 2020 at 4: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 | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
> > index ca707f5b521d..88e6b083d702 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,10 @@ void acpi_reboot(void)
> >                 acpi_reset();
> >                 break;
> >         }
> > +
> > +       /*
> > +        * delay for 15ms in case the system does not shutdown
> > immediately after
> > +        * writing to the ACPI reset register
> 
> It would also be good to make a note of where the 15ms value comes
> from.
> 
> Even if it has been guessed, it will still be good to know that, say,
> 5 years from now.
> 
Agreed, patch V2 sent out.

-rui
> > +        */
> > +       mdelay(15);
> >  }
> > --
> > 2.17.1
> > 


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

end of thread, back to index

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

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git