All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: Execute the _PTS method when system reboot
@ 2016-05-09  5:50 Ocean HY1 He
  2016-05-16  3:04 ` Ocean HY1 He
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Ocean HY1 He @ 2016-05-09  5:50 UTC (permalink / raw)
  To: rjw, lenb
  Cc: linux-acpi, linux-kernel, David Tanaka, Ocean HY1 He,
	Nagananda Chumbalkar

The _PTS control method is defined in the section 7.4.1 of acpi 6.0
spec. The _PTS control method is executed by the OS during the sleep
transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
soft-off state) is passed to the _PTS control method. This method
is called after OSPM has notified native device drivers of the sleep
state transition and before the OSPM has had a chance to fully
prepare the system for a sleep state transition.

The _PTS control method provides the BIOS a mechanism for performing
some housekeeping, such as writing the sleep type value to the embedded
controller, before entering the system sleeping state.

According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.

Thus, a _PTS block notifier is added to the reboot notifier list so that
the _PTS object will also be evaluated when the system reboot.

Signed-off-by: Ocean He <hehy1@lenovo.com>
Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
---
 drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 2a8b596..8b290fb 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
 	.priority	= 0,
 };
 
+static int pts_notify_reboot(struct notifier_block *this,
+			unsigned long code, void *x)
+{
+	acpi_status status;
+
+	status = acpi_execute_simple_method(NULL, "\\_PTS", ACPI_STATE_S5);
+	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+		/* It won't break anything. */
+		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
+	}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block pts_notifier = {
+	.notifier_call	= pts_notify_reboot,
+	.next		= NULL,
+	.priority	= 0,
+};
+
 static int acpi_sleep_prepare(u32 acpi_state)
 {
 #ifdef CONFIG_ACPI_SLEEP
@@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
 	 * object can also be evaluated when the system enters S5.
 	 */
 	register_reboot_notifier(&tts_notifier);
+
+	/*
+	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
+	 * _TTS when the system enters S5.
+	 */
+	register_reboot_notifier(&pts_notifier);
+
 	return 0;
 }
-- 
1.8.3.1

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

* RE: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-05-09  5:50 [PATCH] ACPI: Execute the _PTS method when system reboot Ocean HY1 He
@ 2016-05-16  3:04 ` Ocean HY1 He
  2016-05-24  6:41 ` Ocean HY1 He
  2016-06-21 23:56 ` Rafael J. Wysocki
  2 siblings, 0 replies; 15+ messages in thread
From: Ocean HY1 He @ 2016-05-16  3:04 UTC (permalink / raw)
  To: rjw, lenb; +Cc: linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar

To whom may concern,

A Lenovo feature depends on _PTS method execution when reboot. And after check the ACPI spec, I think _PTS should be exectued when reboo. This patch could fix the problem.

Any comments of this patch? Many thanks!

Ocean He / 何海洋
SW Development Dept. 
Beijing Design Center
Enterprise Product Group
Mobile: 18911778926
E-mail: hehy1@lenovo.com
No.6 Chuang Ye Road, Haidian District, Beijing, China 100085

-----Original Message-----
From: Ocean HY1 He 
Sent: Monday, May 09, 2016 1:50 PM
To: rjw@rjwysocki.net; lenb@kernel.org
Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka; Ocean HY1 He; Nagananda Chumbalkar
Subject: [PATCH] ACPI: Execute the _PTS method when system reboot

The _PTS control method is defined in the section 7.4.1 of acpi 6.0
spec. The _PTS control method is executed by the OS during the sleep
transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
soft-off state) is passed to the _PTS control method. This method
is called after OSPM has notified native device drivers of the sleep
state transition and before the OSPM has had a chance to fully
prepare the system for a sleep state transition.

The _PTS control method provides the BIOS a mechanism for performing
some housekeeping, such as writing the sleep type value to the embedded
controller, before entering the system sleeping state.

According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.

Thus, a _PTS block notifier is added to the reboot notifier list so that
the _PTS object will also be evaluated when the system reboot.

Signed-off-by: Ocean He <hehy1@lenovo.com>
Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
---
 drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 2a8b596..8b290fb 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
 	.priority	= 0,
 };
 
+static int pts_notify_reboot(struct notifier_block *this,
+			unsigned long code, void *x)
+{
+	acpi_status status;
+
+	status = acpi_execute_simple_method(NULL, "\\_PTS", ACPI_STATE_S5);
+	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+		/* It won't break anything. */
+		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
+	}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block pts_notifier = {
+	.notifier_call	= pts_notify_reboot,
+	.next		= NULL,
+	.priority	= 0,
+};
+
 static int acpi_sleep_prepare(u32 acpi_state)
 {
 #ifdef CONFIG_ACPI_SLEEP
@@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
 	 * object can also be evaluated when the system enters S5.
 	 */
 	register_reboot_notifier(&tts_notifier);
+
+	/*
+	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
+	 * _TTS when the system enters S5.
+	 */
+	register_reboot_notifier(&pts_notifier);
+
 	return 0;
 }
-- 
1.8.3.1

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

* RE: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-05-09  5:50 [PATCH] ACPI: Execute the _PTS method when system reboot Ocean HY1 He
  2016-05-16  3:04 ` Ocean HY1 He
@ 2016-05-24  6:41 ` Ocean HY1 He
  2016-05-24 10:15     ` Prarit Bhargava
  2016-06-21 23:56 ` Rafael J. Wysocki
  2 siblings, 1 reply; 15+ messages in thread
From: Ocean HY1 He @ 2016-05-24  6:41 UTC (permalink / raw)
  To: Prarit Bhargava (prarit@redhat.com), jcm
  Cc: linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar,
	rjw, lenb, wefu

Hi Prarit and Jon,

How do you think of this?

Thanks.

Ocean He / 何海洋
SW Development Dept. 
Beijing Design Center
Enterprise Product Group
Mobile: 18911778926
E-mail: hehy1@lenovo.com
No.6 Chuang Ye Road, Haidian District, Beijing, China 100085

-----Original Message-----
From: Ocean HY1 He 
Sent: Monday, May 16, 2016 11:04 AM
To: rjw@rjwysocki.net; lenb@kernel.org
Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
Subject: RE: [PATCH] ACPI: Execute the _PTS method when system reboot

To whom may concern,

A Lenovo feature depends on _PTS method execution when reboot. And after check the ACPI spec, I think _PTS should be exectued when reboo. This patch could fix the problem.

Any comments of this patch? Many thanks!

Ocean He / 何海洋
SW Development Dept. 
Beijing Design Center
Enterprise Product Group
Mobile: 18911778926
E-mail: hehy1@lenovo.com
No.6 Chuang Ye Road, Haidian District, Beijing, China 100085

-----Original Message-----
From: Ocean HY1 He 
Sent: Monday, May 09, 2016 1:50 PM
To: rjw@rjwysocki.net; lenb@kernel.org
Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka; Ocean HY1 He; Nagananda Chumbalkar
Subject: [PATCH] ACPI: Execute the _PTS method when system reboot

The _PTS control method is defined in the section 7.4.1 of acpi 6.0
spec. The _PTS control method is executed by the OS during the sleep
transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
soft-off state) is passed to the _PTS control method. This method
is called after OSPM has notified native device drivers of the sleep
state transition and before the OSPM has had a chance to fully
prepare the system for a sleep state transition.

The _PTS control method provides the BIOS a mechanism for performing
some housekeeping, such as writing the sleep type value to the embedded
controller, before entering the system sleeping state.

According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.

Thus, a _PTS block notifier is added to the reboot notifier list so that
the _PTS object will also be evaluated when the system reboot.

Signed-off-by: Ocean He <hehy1@lenovo.com>
Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
---
 drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 2a8b596..8b290fb 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
 	.priority	= 0,
 };
 
+static int pts_notify_reboot(struct notifier_block *this,
+			unsigned long code, void *x)
+{
+	acpi_status status;
+
+	status = acpi_execute_simple_method(NULL, "\\_PTS", ACPI_STATE_S5);
+	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+		/* It won't break anything. */
+		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
+	}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block pts_notifier = {
+	.notifier_call	= pts_notify_reboot,
+	.next		= NULL,
+	.priority	= 0,
+};
+
 static int acpi_sleep_prepare(u32 acpi_state)
 {
 #ifdef CONFIG_ACPI_SLEEP
@@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
 	 * object can also be evaluated when the system enters S5.
 	 */
 	register_reboot_notifier(&tts_notifier);
+
+	/*
+	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
+	 * _TTS when the system enters S5.
+	 */
+	register_reboot_notifier(&pts_notifier);
+
 	return 0;
 }
-- 
1.8.3.1

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

* Re: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-05-24  6:41 ` Ocean HY1 He
@ 2016-05-24 10:15     ` Prarit Bhargava
  0 siblings, 0 replies; 15+ messages in thread
From: Prarit Bhargava @ 2016-05-24 10:15 UTC (permalink / raw)
  To: Ocean HY1 He, jcm
  Cc: linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar,
	rjw, lenb, wefu



On 05/24/2016 02:41 AM, Ocean HY1 He wrote:
> Hi Prarit and Jon,
> 
> How do you think of this?
> 
> Thanks.
> 
> Ocean He / 何海洋
> SW Development Dept. 
> Beijing Design Center
> Enterprise Product Group
> Mobile: 18911778926
> E-mail: hehy1@lenovo.com
> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> 
> -----Original Message-----
> From: Ocean HY1 He 
> Sent: Monday, May 16, 2016 11:04 AM
> To: rjw@rjwysocki.net; lenb@kernel.org
> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> Subject: RE: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> To whom may concern,
> 
> A Lenovo feature depends on _PTS method execution when reboot. And after check the ACPI spec, I think _PTS should be exectued when reboo. This patch could fix the problem.
> 
> Any comments of this patch? Many thanks!
> 
> Ocean He / 何海洋
> SW Development Dept. 
> Beijing Design Center
> Enterprise Product Group
> Mobile: 18911778926
> E-mail: hehy1@lenovo.com
> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> 
> -----Original Message-----
> From: Ocean HY1 He 
> Sent: Monday, May 09, 2016 1:50 PM
> To: rjw@rjwysocki.net; lenb@kernel.org
> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka; Ocean HY1 He; Nagananda Chumbalkar
> Subject: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> spec. The _PTS control method is executed by the OS during the sleep
> transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> soft-off state) is passed to the _PTS control method. This method
> is called after OSPM has notified native device drivers of the sleep
> state transition and before the OSPM has had a chance to fully
> prepare the system for a sleep state transition.
> 
> The _PTS control method provides the BIOS a mechanism for performing
> some housekeeping, such as writing the sleep type value to the embedded
> controller, before entering the system sleeping state.
> 
> According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> 
> Thus, a _PTS block notifier is added to the reboot notifier list so that
> the _PTS object will also be evaluated when the system reboot.
> 
> Signed-off-by: Ocean He <hehy1@lenovo.com>
> Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> ---
>  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index 2a8b596..8b290fb 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
>  	.priority	= 0,
>  };
>  
> +static int pts_notify_reboot(struct notifier_block *this,
> +			unsigned long code, void *x)
> +{
> +	acpi_status status;
> +
> +	status = acpi_execute_simple_method(NULL, "\\_PTS", ACPI_STATE_S5);
> +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> +		/* It won't break anything. */
> +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");

^^^^
	pr_debug("No _PTS object found.\n");

It isn't a warning or error, so don't put the word "Failure" in there.

Beyond that, looks entirely reasonable to me.

P.


> +	}
> +
> +	return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block pts_notifier = {
> +	.notifier_call	= pts_notify_reboot,
> +	.next		= NULL,
> +	.priority	= 0,
> +};
> +
>  static int acpi_sleep_prepare(u32 acpi_state)
>  {
>  #ifdef CONFIG_ACPI_SLEEP
> @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
>  	 * object can also be evaluated when the system enters S5.
>  	 */
>  	register_reboot_notifier(&tts_notifier);
> +
> +	/*
> +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
> +	 * _TTS when the system enters S5.
> +	 */
> +	register_reboot_notifier(&pts_notifier);
> +
>  	return 0;
>  }
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] ACPI: Execute the _PTS method when system reboot
@ 2016-05-24 10:15     ` Prarit Bhargava
  0 siblings, 0 replies; 15+ messages in thread
From: Prarit Bhargava @ 2016-05-24 10:15 UTC (permalink / raw)
  To: Ocean HY1 He, jcm
  Cc: linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar,
	rjw, lenb, wefu



On 05/24/2016 02:41 AM, Ocean HY1 He wrote:
> Hi Prarit and Jon,
> 
> How do you think of this?
> 
> Thanks.
> 
> Ocean He / 何海洋
> SW Development Dept. 
> Beijing Design Center
> Enterprise Product Group
> Mobile: 18911778926
> E-mail: hehy1@lenovo.com
> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> 
> -----Original Message-----
> From: Ocean HY1 He 
> Sent: Monday, May 16, 2016 11:04 AM
> To: rjw@rjwysocki.net; lenb@kernel.org
> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> Subject: RE: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> To whom may concern,
> 
> A Lenovo feature depends on _PTS method execution when reboot. And after check the ACPI spec, I think _PTS should be exectued when reboo. This patch could fix the problem.
> 
> Any comments of this patch? Many thanks!
> 
> Ocean He / 何海洋
> SW Development Dept. 
> Beijing Design Center
> Enterprise Product Group
> Mobile: 18911778926
> E-mail: hehy1@lenovo.com
> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> 
> -----Original Message-----
> From: Ocean HY1 He 
> Sent: Monday, May 09, 2016 1:50 PM
> To: rjw@rjwysocki.net; lenb@kernel.org
> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka; Ocean HY1 He; Nagananda Chumbalkar
> Subject: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> spec. The _PTS control method is executed by the OS during the sleep
> transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> soft-off state) is passed to the _PTS control method. This method
> is called after OSPM has notified native device drivers of the sleep
> state transition and before the OSPM has had a chance to fully
> prepare the system for a sleep state transition.
> 
> The _PTS control method provides the BIOS a mechanism for performing
> some housekeeping, such as writing the sleep type value to the embedded
> controller, before entering the system sleeping state.
> 
> According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> 
> Thus, a _PTS block notifier is added to the reboot notifier list so that
> the _PTS object will also be evaluated when the system reboot.
> 
> Signed-off-by: Ocean He <hehy1@lenovo.com>
> Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> ---
>  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index 2a8b596..8b290fb 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
>  	.priority	= 0,
>  };
>  
> +static int pts_notify_reboot(struct notifier_block *this,
> +			unsigned long code, void *x)
> +{
> +	acpi_status status;
> +
> +	status = acpi_execute_simple_method(NULL, "\\_PTS", ACPI_STATE_S5);
> +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> +		/* It won't break anything. */
> +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");

^^^^
	pr_debug("No _PTS object found.\n");

It isn't a warning or error, so don't put the word "Failure" in there.

Beyond that, looks entirely reasonable to me.

P.


> +	}
> +
> +	return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block pts_notifier = {
> +	.notifier_call	= pts_notify_reboot,
> +	.next		= NULL,
> +	.priority	= 0,
> +};
> +
>  static int acpi_sleep_prepare(u32 acpi_state)
>  {
>  #ifdef CONFIG_ACPI_SLEEP
> @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
>  	 * object can also be evaluated when the system enters S5.
>  	 */
>  	register_reboot_notifier(&tts_notifier);
> +
> +	/*
> +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
> +	 * _TTS when the system enters S5.
> +	 */
> +	register_reboot_notifier(&pts_notifier);
> +
>  	return 0;
>  }
> 

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

* RE: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-05-24 10:15     ` Prarit Bhargava
  (?)
@ 2016-05-30  3:28     ` Ocean HY1 He
  2016-05-31  9:59         ` Prarit Bhargava
  -1 siblings, 1 reply; 15+ messages in thread
From: Ocean HY1 He @ 2016-05-30  3:28 UTC (permalink / raw)
  To: Prarit Bhargava, jcm
  Cc: linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar,
	rjw, lenb, wefu

> -----Original Message-----
> From: Prarit Bhargava [mailto:prarit@redhat.com]
> Sent: Tuesday, May 24, 2016 6:16 PM
> To: Ocean HY1 He; jcm@redhat.com
> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka;
> Nagananda Chumbalkar; rjw@rjwysocki.net; lenb@kernel.org;
> wefu@redhat.com
> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> 
> 
> On 05/24/2016 02:41 AM, Ocean HY1 He wrote:
> > Hi Prarit and Jon,
> >
> > How do you think of this?
> >
> > Thanks.
> >
> > Ocean He / 何海洋
> > SW Development Dept.
> > Beijing Design Center
> > Enterprise Product Group
> > Mobile: 18911778926
> > E-mail: hehy1@lenovo.com
> > No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> >
> > -----Original Message-----
> > From: Ocean HY1 He
> > Sent: Monday, May 16, 2016 11:04 AM
> > To: rjw@rjwysocki.net; lenb@kernel.org
> > Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David
> Tanaka; Nagananda Chumbalkar
> > Subject: RE: [PATCH] ACPI: Execute the _PTS method when system
> reboot
> >
> > To whom may concern,
> >
> > A Lenovo feature depends on _PTS method execution when reboot. And
> after check the ACPI spec, I think _PTS should be exectued when reboo.
> This patch could fix the problem.
> >
> > Any comments of this patch? Many thanks!
> >
> > Ocean He / 何海洋
> > SW Development Dept.
> > Beijing Design Center
> > Enterprise Product Group
> > Mobile: 18911778926
> > E-mail: hehy1@lenovo.com
> > No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> >
> > -----Original Message-----
> > From: Ocean HY1 He
> > Sent: Monday, May 09, 2016 1:50 PM
> > To: rjw@rjwysocki.net; lenb@kernel.org
> > Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David
> Tanaka; Ocean HY1 He; Nagananda Chumbalkar
> > Subject: [PATCH] ACPI: Execute the _PTS method when system reboot
> >
> > The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> > spec. The _PTS control method is executed by the OS during the sleep
> > transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> > The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> > soft-off state) is passed to the _PTS control method. This method
> > is called after OSPM has notified native device drivers of the sleep
> > state transition and before the OSPM has had a chance to fully
> > prepare the system for a sleep state transition.
> >
> > The _PTS control method provides the BIOS a mechanism for performing
> > some housekeeping, such as writing the sleep type value to the
> embedded
> > controller, before entering the system sleeping state.
> >
> > According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> >
> > Thus, a _PTS block notifier is added to the reboot notifier list so that
> > the _PTS object will also be evaluated when the system reboot.
> >
> > Signed-off-by: Ocean He <hehy1@lenovo.com>
> > Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> > ---
> >  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> >
> > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> > index 2a8b596..8b290fb 100644
> > --- a/drivers/acpi/sleep.c
> > +++ b/drivers/acpi/sleep.c
> > @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
> >  	.priority	= 0,
> >  };
> >
> > +static int pts_notify_reboot(struct notifier_block *this,
> > +			unsigned long code, void *x)
> > +{
> > +	acpi_status status;
> > +
> > +	status = acpi_execute_simple_method(NULL, "\\_PTS",
> ACPI_STATE_S5);
> > +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > +		/* It won't break anything. */
> > +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
> 
> ^^^^
> 	pr_debug("No _PTS object found.\n");
> 
> It isn't a warning or error, so don't put the word "Failure" in there.
> 
> Beyond that, looks entirely reasonable to me.
> 
> P.
> 
Hi Prarit,

The message outputs when _PTS is found but fail to execute. I copy this code
from existed function acpi_sleep_tts_switch(). I just wants to keep new codes
as the same style as existed codes. Make sense? ;-)

Ocean.
> 
> > +	}
> > +
> > +	return NOTIFY_DONE;
> > +}
> > +
> > +static struct notifier_block pts_notifier = {
> > +	.notifier_call	= pts_notify_reboot,
> > +	.next		= NULL,
> > +	.priority	= 0,
> > +};
> > +
> >  static int acpi_sleep_prepare(u32 acpi_state)
> >  {
> >  #ifdef CONFIG_ACPI_SLEEP
> > @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
> >  	 * object can also be evaluated when the system enters S5.
> >  	 */
> >  	register_reboot_notifier(&tts_notifier);
> > +
> > +	/*
> > +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
> > +	 * _TTS when the system enters S5.
> > +	 */
> > +	register_reboot_notifier(&pts_notifier);
> > +
> >  	return 0;
> >  }
> >

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

* Re: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-05-30  3:28     ` Ocean HY1 He
@ 2016-05-31  9:59         ` Prarit Bhargava
  0 siblings, 0 replies; 15+ messages in thread
From: Prarit Bhargava @ 2016-05-31  9:59 UTC (permalink / raw)
  To: Ocean HY1 He, jcm
  Cc: linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar,
	rjw, lenb, wefu



On 05/29/2016 11:28 PM, Ocean HY1 He wrote:
>> -----Original Message-----
>> From: Prarit Bhargava [mailto:prarit@redhat.com]
>> Sent: Tuesday, May 24, 2016 6:16 PM
>> To: Ocean HY1 He; jcm@redhat.com
>> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka;
>> Nagananda Chumbalkar; rjw@rjwysocki.net; lenb@kernel.org;
>> wefu@redhat.com
>> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system reboot
>>
>>
>>
>> On 05/24/2016 02:41 AM, Ocean HY1 He wrote:
>>> Hi Prarit and Jon,
>>>
>>> How do you think of this?
>>>
>>> Thanks.
>>>
>>> Ocean He / 何海洋
>>> SW Development Dept.
>>> Beijing Design Center
>>> Enterprise Product Group
>>> Mobile: 18911778926
>>> E-mail: hehy1@lenovo.com
>>> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
>>>
>>> -----Original Message-----
>>> From: Ocean HY1 He
>>> Sent: Monday, May 16, 2016 11:04 AM
>>> To: rjw@rjwysocki.net; lenb@kernel.org
>>> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David
>> Tanaka; Nagananda Chumbalkar
>>> Subject: RE: [PATCH] ACPI: Execute the _PTS method when system
>> reboot
>>>
>>> To whom may concern,
>>>
>>> A Lenovo feature depends on _PTS method execution when reboot. And
>> after check the ACPI spec, I think _PTS should be exectued when reboo.
>> This patch could fix the problem.
>>>
>>> Any comments of this patch? Many thanks!
>>>
>>> Ocean He / 何海洋
>>> SW Development Dept.
>>> Beijing Design Center
>>> Enterprise Product Group
>>> Mobile: 18911778926
>>> E-mail: hehy1@lenovo.com
>>> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
>>>
>>> -----Original Message-----
>>> From: Ocean HY1 He
>>> Sent: Monday, May 09, 2016 1:50 PM
>>> To: rjw@rjwysocki.net; lenb@kernel.org
>>> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David
>> Tanaka; Ocean HY1 He; Nagananda Chumbalkar
>>> Subject: [PATCH] ACPI: Execute the _PTS method when system reboot
>>>
>>> The _PTS control method is defined in the section 7.4.1 of acpi 6.0
>>> spec. The _PTS control method is executed by the OS during the sleep
>>> transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
>>> The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
>>> soft-off state) is passed to the _PTS control method. This method
>>> is called after OSPM has notified native device drivers of the sleep
>>> state transition and before the OSPM has had a chance to fully
>>> prepare the system for a sleep state transition.
>>>
>>> The _PTS control method provides the BIOS a mechanism for performing
>>> some housekeeping, such as writing the sleep type value to the
>> embedded
>>> controller, before entering the system sleeping state.
>>>
>>> According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
>>>
>>> Thus, a _PTS block notifier is added to the reboot notifier list so that
>>> the _PTS object will also be evaluated when the system reboot.
>>>
>>> Signed-off-by: Ocean He <hehy1@lenovo.com>
>>> Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
>>> ---
>>>  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
>>>  1 file changed, 27 insertions(+)
>>>
>>> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
>>> index 2a8b596..8b290fb 100644
>>> --- a/drivers/acpi/sleep.c
>>> +++ b/drivers/acpi/sleep.c
>>> @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
>>>  	.priority	= 0,
>>>  };
>>>
>>> +static int pts_notify_reboot(struct notifier_block *this,
>>> +			unsigned long code, void *x)
>>> +{
>>> +	acpi_status status;
>>> +
>>> +	status = acpi_execute_simple_method(NULL, "\\_PTS",
>> ACPI_STATE_S5);
>>> +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
>>> +		/* It won't break anything. */
>>> +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
>>
>> ^^^^
>> 	pr_debug("No _PTS object found.\n");
>>
>> It isn't a warning or error, so don't put the word "Failure" in there.
>>
>> Beyond that, looks entirely reasonable to me.
>>
>> P.
>>
> Hi Prarit,
> 
> The message outputs when _PTS is found but fail to execute. I copy this code
> from existed function acpi_sleep_tts_switch(). I just wants to keep new codes
> as the same style as existed codes. Make sense? ;-)

Not really.  "Failure" is something that QE groups look for when testing,
debugging, or verifying.  This message implies something went wrong when the
_PTS object is an optional implementation of ACPI.

P.

> 
> Ocean.
>>
>>> +	}
>>> +
>>> +	return NOTIFY_DONE;
>>> +}
>>> +
>>> +static struct notifier_block pts_notifier = {
>>> +	.notifier_call	= pts_notify_reboot,
>>> +	.next		= NULL,
>>> +	.priority	= 0,
>>> +};
>>> +
>>>  static int acpi_sleep_prepare(u32 acpi_state)
>>>  {
>>>  #ifdef CONFIG_ACPI_SLEEP
>>> @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
>>>  	 * object can also be evaluated when the system enters S5.
>>>  	 */
>>>  	register_reboot_notifier(&tts_notifier);
>>> +
>>> +	/*
>>> +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
>>> +	 * _TTS when the system enters S5.
>>> +	 */
>>> +	register_reboot_notifier(&pts_notifier);
>>> +
>>>  	return 0;
>>>  }
>>>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] ACPI: Execute the _PTS method when system reboot
@ 2016-05-31  9:59         ` Prarit Bhargava
  0 siblings, 0 replies; 15+ messages in thread
From: Prarit Bhargava @ 2016-05-31  9:59 UTC (permalink / raw)
  To: Ocean HY1 He, jcm
  Cc: linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar,
	rjw, lenb, wefu



On 05/29/2016 11:28 PM, Ocean HY1 He wrote:
>> -----Original Message-----
>> From: Prarit Bhargava [mailto:prarit@redhat.com]
>> Sent: Tuesday, May 24, 2016 6:16 PM
>> To: Ocean HY1 He; jcm@redhat.com
>> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David Tanaka;
>> Nagananda Chumbalkar; rjw@rjwysocki.net; lenb@kernel.org;
>> wefu@redhat.com
>> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system reboot
>>
>>
>>
>> On 05/24/2016 02:41 AM, Ocean HY1 He wrote:
>>> Hi Prarit and Jon,
>>>
>>> How do you think of this?
>>>
>>> Thanks.
>>>
>>> Ocean He / 何海洋
>>> SW Development Dept.
>>> Beijing Design Center
>>> Enterprise Product Group
>>> Mobile: 18911778926
>>> E-mail: hehy1@lenovo.com
>>> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
>>>
>>> -----Original Message-----
>>> From: Ocean HY1 He
>>> Sent: Monday, May 16, 2016 11:04 AM
>>> To: rjw@rjwysocki.net; lenb@kernel.org
>>> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David
>> Tanaka; Nagananda Chumbalkar
>>> Subject: RE: [PATCH] ACPI: Execute the _PTS method when system
>> reboot
>>>
>>> To whom may concern,
>>>
>>> A Lenovo feature depends on _PTS method execution when reboot. And
>> after check the ACPI spec, I think _PTS should be exectued when reboo.
>> This patch could fix the problem.
>>>
>>> Any comments of this patch? Many thanks!
>>>
>>> Ocean He / 何海洋
>>> SW Development Dept.
>>> Beijing Design Center
>>> Enterprise Product Group
>>> Mobile: 18911778926
>>> E-mail: hehy1@lenovo.com
>>> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
>>>
>>> -----Original Message-----
>>> From: Ocean HY1 He
>>> Sent: Monday, May 09, 2016 1:50 PM
>>> To: rjw@rjwysocki.net; lenb@kernel.org
>>> Cc: linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; David
>> Tanaka; Ocean HY1 He; Nagananda Chumbalkar
>>> Subject: [PATCH] ACPI: Execute the _PTS method when system reboot
>>>
>>> The _PTS control method is defined in the section 7.4.1 of acpi 6.0
>>> spec. The _PTS control method is executed by the OS during the sleep
>>> transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
>>> The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
>>> soft-off state) is passed to the _PTS control method. This method
>>> is called after OSPM has notified native device drivers of the sleep
>>> state transition and before the OSPM has had a chance to fully
>>> prepare the system for a sleep state transition.
>>>
>>> The _PTS control method provides the BIOS a mechanism for performing
>>> some housekeeping, such as writing the sleep type value to the
>> embedded
>>> controller, before entering the system sleeping state.
>>>
>>> According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
>>>
>>> Thus, a _PTS block notifier is added to the reboot notifier list so that
>>> the _PTS object will also be evaluated when the system reboot.
>>>
>>> Signed-off-by: Ocean He <hehy1@lenovo.com>
>>> Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
>>> ---
>>>  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
>>>  1 file changed, 27 insertions(+)
>>>
>>> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
>>> index 2a8b596..8b290fb 100644
>>> --- a/drivers/acpi/sleep.c
>>> +++ b/drivers/acpi/sleep.c
>>> @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
>>>  	.priority	= 0,
>>>  };
>>>
>>> +static int pts_notify_reboot(struct notifier_block *this,
>>> +			unsigned long code, void *x)
>>> +{
>>> +	acpi_status status;
>>> +
>>> +	status = acpi_execute_simple_method(NULL, "\\_PTS",
>> ACPI_STATE_S5);
>>> +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
>>> +		/* It won't break anything. */
>>> +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
>>
>> ^^^^
>> 	pr_debug("No _PTS object found.\n");
>>
>> It isn't a warning or error, so don't put the word "Failure" in there.
>>
>> Beyond that, looks entirely reasonable to me.
>>
>> P.
>>
> Hi Prarit,
> 
> The message outputs when _PTS is found but fail to execute. I copy this code
> from existed function acpi_sleep_tts_switch(). I just wants to keep new codes
> as the same style as existed codes. Make sense? ;-)

Not really.  "Failure" is something that QE groups look for when testing,
debugging, or verifying.  This message implies something went wrong when the
_PTS object is an optional implementation of ACPI.

P.

> 
> Ocean.
>>
>>> +	}
>>> +
>>> +	return NOTIFY_DONE;
>>> +}
>>> +
>>> +static struct notifier_block pts_notifier = {
>>> +	.notifier_call	= pts_notify_reboot,
>>> +	.next		= NULL,
>>> +	.priority	= 0,
>>> +};
>>> +
>>>  static int acpi_sleep_prepare(u32 acpi_state)
>>>  {
>>>  #ifdef CONFIG_ACPI_SLEEP
>>> @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
>>>  	 * object can also be evaluated when the system enters S5.
>>>  	 */
>>>  	register_reboot_notifier(&tts_notifier);
>>> +
>>> +	/*
>>> +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
>>> +	 * _TTS when the system enters S5.
>>> +	 */
>>> +	register_reboot_notifier(&pts_notifier);
>>> +
>>>  	return 0;
>>>  }
>>>

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

* Re: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-05-09  5:50 [PATCH] ACPI: Execute the _PTS method when system reboot Ocean HY1 He
  2016-05-16  3:04 ` Ocean HY1 He
  2016-05-24  6:41 ` Ocean HY1 He
@ 2016-06-21 23:56 ` Rafael J. Wysocki
  2016-06-23 12:55   ` Ocean HY1 He
  2 siblings, 1 reply; 15+ messages in thread
From: Rafael J. Wysocki @ 2016-06-21 23:56 UTC (permalink / raw)
  To: Ocean HY1 He
  Cc: lenb, linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar

On Monday, May 09, 2016 05:50:11 AM Ocean HY1 He wrote:
> The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> spec. The _PTS control method is executed by the OS during the sleep
> transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> soft-off state) is passed to the _PTS control method. This method
> is called after OSPM has notified native device drivers of the sleep
> state transition and before the OSPM has had a chance to fully
> prepare the system for a sleep state transition.
> 
> The _PTS control method provides the BIOS a mechanism for performing
> some housekeeping, such as writing the sleep type value to the embedded
> controller, before entering the system sleeping state.
> 
> According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> 
> Thus, a _PTS block notifier is added to the reboot notifier list so that
> the _PTS object will also be evaluated when the system reboot.

So I understand why it may be necessary to evaluate _PTS before entering S5,
but I'm totally unsure about reboot.

What does reboot have to do with S5?

> Signed-off-by: Ocean He <hehy1@lenovo.com>
> Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> ---
>  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index 2a8b596..8b290fb 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
>  	.priority	= 0,
>  };
>  
> +static int pts_notify_reboot(struct notifier_block *this,
> +			unsigned long code, void *x)
> +{
> +	acpi_status status;
> +
> +	status = acpi_execute_simple_method(NULL, "\\_PTS", ACPI_STATE_S5);
> +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> +		/* It won't break anything. */
> +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
> +	}
> +
> +	return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block pts_notifier = {
> +	.notifier_call	= pts_notify_reboot,
> +	.next		= NULL,
> +	.priority	= 0,
> +};
> +
>  static int acpi_sleep_prepare(u32 acpi_state)
>  {
>  #ifdef CONFIG_ACPI_SLEEP
> @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
>  	 * object can also be evaluated when the system enters S5.
>  	 */
>  	register_reboot_notifier(&tts_notifier);
> +
> +	/*
> +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
> +	 * _TTS when the system enters S5.
> +	 */
> +	register_reboot_notifier(&pts_notifier);

Why do you have to add a second notifier?

Why can't _TTS and _PTS be evaluated from one notifier?

> +
>  	return 0;
>  }
> 

Thanks,
Rafael

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

* RE: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-06-21 23:56 ` Rafael J. Wysocki
@ 2016-06-23 12:55   ` Ocean HY1 He
  2016-06-23 13:12     ` Rafael J. Wysocki
  2016-06-24  0:30     ` Zheng, Lv
  0 siblings, 2 replies; 15+ messages in thread
From: Ocean HY1 He @ 2016-06-23 12:55 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: lenb, linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar

Hi Rafael,
Please see my reply in below.

Regards,
Ocean He
SW Development Dept. 
Beijing Design Center
Enterprise Product Group
Mobile: 18911778926
E-mail: hehy1@lenovo.com
No.6 Chuang Ye Road, Haidian District, Beijing, China 100085

> -----Original Message-----
> From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> Sent: Wednesday, June 22, 2016 7:56 AM
> To: Ocean HY1 He
> Cc: lenb@kernel.org; linux-acpi@vger.kernel.org;
> linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> On Monday, May 09, 2016 05:50:11 AM Ocean HY1 He wrote:
> > The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> > spec. The _PTS control method is executed by the OS during the sleep
> > transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> > The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> > soft-off state) is passed to the _PTS control method. This method
> > is called after OSPM has notified native device drivers of the sleep
> > state transition and before the OSPM has had a chance to fully
> > prepare the system for a sleep state transition.
> >
> > The _PTS control method provides the BIOS a mechanism for performing
> > some housekeeping, such as writing the sleep type value to the
> embedded
> > controller, before entering the system sleeping state.
> >
> > According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> >
> > Thus, a _PTS block notifier is added to the reboot notifier list so that
> > the _PTS object will also be evaluated when the system reboot.
> 
> So I understand why it may be necessary to evaluate _PTS before entering
> S5,
> but I'm totally unsure about reboot.
> 
> What does reboot have to do with S5?
> 
In ACPI spec, there is no explicit words saying _PTS should be 
executed when reboot. But reboot could be equal to the 
process S0->S5->S0. Thus _PTS should be executed when reboot.

I am thinking this is the same as _TTS. In ACPI spec, there is also
no explicit words saying _TTS should be executed when reboot.
But kernel executes _TTS when reboot indeed.

> > Signed-off-by: Ocean He <hehy1@lenovo.com>
> > Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> > ---
> >  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> >
> > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> > index 2a8b596..8b290fb 100644
> > --- a/drivers/acpi/sleep.c
> > +++ b/drivers/acpi/sleep.c
> > @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
> >  	.priority	= 0,
> >  };
> >
> > +static int pts_notify_reboot(struct notifier_block *this,
> > +			unsigned long code, void *x)
> > +{
> > +	acpi_status status;
> > +
> > +	status = acpi_execute_simple_method(NULL, "\\_PTS",
> ACPI_STATE_S5);
> > +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > +		/* It won't break anything. */
> > +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
> > +	}
> > +
> > +	return NOTIFY_DONE;
> > +}
> > +
> > +static struct notifier_block pts_notifier = {
> > +	.notifier_call	= pts_notify_reboot,
> > +	.next		= NULL,
> > +	.priority	= 0,
> > +};
> > +
> >  static int acpi_sleep_prepare(u32 acpi_state)
> >  {
> >  #ifdef CONFIG_ACPI_SLEEP
> > @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
> >  	 * object can also be evaluated when the system enters S5.
> >  	 */
> >  	register_reboot_notifier(&tts_notifier);
> > +
> > +	/*
> > +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
> > +	 * _TTS when the system enters S5.
> > +	 */
> > +	register_reboot_notifier(&pts_notifier);
> 
> Why do you have to add a second notifier?
> 
> Why can't _TTS and _PTS be evaluated from one notifier?
> 
If execute _PTS method in tts_notify_reboot(), then it would break
definition of tts_notify_reboot(). My intention is to keep new codes 
has limited impact on existed codes.
Of course, it's possible to merge _TTS and _PTS into one unified notifier.
The advantage is more actions could be added into the unified notifier in future.
Which way you prefer?
> > +
> >  	return 0;
> >  }
> >
> 
> Thanks,
> Rafael


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

* Re: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-06-23 12:55   ` Ocean HY1 He
@ 2016-06-23 13:12     ` Rafael J. Wysocki
  2016-06-24  2:59       ` Ocean HY1 He
  2016-06-24  0:30     ` Zheng, Lv
  1 sibling, 1 reply; 15+ messages in thread
From: Rafael J. Wysocki @ 2016-06-23 13:12 UTC (permalink / raw)
  To: Ocean HY1 He
  Cc: Rafael J. Wysocki, lenb, linux-acpi, linux-kernel, David Tanaka,
	Nagananda Chumbalkar

On Thu, Jun 23, 2016 at 2:55 PM, Ocean HY1 He <hehy1@lenovo.com> wrote:
> Hi Rafael,
> Please see my reply in below.
>
> Regards,
> Ocean He
> SW Development Dept.
> Beijing Design Center
> Enterprise Product Group
> Mobile: 18911778926
> E-mail: hehy1@lenovo.com
> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
>
>> -----Original Message-----
>> From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
>> Sent: Wednesday, June 22, 2016 7:56 AM
>> To: Ocean HY1 He
>> Cc: lenb@kernel.org; linux-acpi@vger.kernel.org;
>> linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
>> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system reboot
>>
>> On Monday, May 09, 2016 05:50:11 AM Ocean HY1 He wrote:
>> > The _PTS control method is defined in the section 7.4.1 of acpi 6.0
>> > spec. The _PTS control method is executed by the OS during the sleep
>> > transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
>> > The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
>> > soft-off state) is passed to the _PTS control method. This method
>> > is called after OSPM has notified native device drivers of the sleep
>> > state transition and before the OSPM has had a chance to fully
>> > prepare the system for a sleep state transition.
>> >
>> > The _PTS control method provides the BIOS a mechanism for performing
>> > some housekeeping, such as writing the sleep type value to the
>> embedded
>> > controller, before entering the system sleeping state.
>> >
>> > According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
>> >
>> > Thus, a _PTS block notifier is added to the reboot notifier list so that
>> > the _PTS object will also be evaluated when the system reboot.
>>
>> So I understand why it may be necessary to evaluate _PTS before entering
>> S5,
>> but I'm totally unsure about reboot.
>>
>> What does reboot have to do with S5?
>>
> In ACPI spec, there is no explicit words saying _PTS should be
> executed when reboot. But reboot could be equal to the
> process S0->S5->S0.

Not in general.

In particular, wakeup devices that would be set up for S5 need not be
set up for that.  Also the mechanism by which transitions to S5 are
entered is different from the reboot one, at least from the OS
perspective.

> Thus _PTS should be executed when reboot.

No, it doesn't follow.

> I am thinking this is the same as _TTS. In ACPI spec, there is also
> no explicit words saying _TTS should be executed when reboot.
> But kernel executes _TTS when reboot indeed.

Yes, it does.  Maybe it shouldn't?

It may not hurt to call _PTS before reboot too, but is it guaranteed
to work across the board on all systems everywhere?

>> > Signed-off-by: Ocean He <hehy1@lenovo.com>
>> > Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
>> > ---
>> >  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
>> >  1 file changed, 27 insertions(+)
>> >
>> > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
>> > index 2a8b596..8b290fb 100644
>> > --- a/drivers/acpi/sleep.c
>> > +++ b/drivers/acpi/sleep.c
>> > @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
>> >     .priority       = 0,
>> >  };
>> >
>> > +static int pts_notify_reboot(struct notifier_block *this,
>> > +                   unsigned long code, void *x)
>> > +{
>> > +   acpi_status status;
>> > +
>> > +   status = acpi_execute_simple_method(NULL, "\\_PTS",
>> ACPI_STATE_S5);
>> > +   if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
>> > +           /* It won't break anything. */
>> > +           printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
>> > +   }
>> > +
>> > +   return NOTIFY_DONE;
>> > +}
>> > +
>> > +static struct notifier_block pts_notifier = {
>> > +   .notifier_call  = pts_notify_reboot,
>> > +   .next           = NULL,
>> > +   .priority       = 0,
>> > +};
>> > +
>> >  static int acpi_sleep_prepare(u32 acpi_state)
>> >  {
>> >  #ifdef CONFIG_ACPI_SLEEP
>> > @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
>> >      * object can also be evaluated when the system enters S5.
>> >      */
>> >     register_reboot_notifier(&tts_notifier);
>> > +
>> > +   /*
>> > +    * According to section 7.5 of acpi 6.0 spec, _PTS should run after
>> > +    * _TTS when the system enters S5.
>> > +    */
>> > +   register_reboot_notifier(&pts_notifier);
>>
>> Why do you have to add a second notifier?
>>
>> Why can't _TTS and _PTS be evaluated from one notifier?
>>
> If execute _PTS method in tts_notify_reboot(), then it would break
> definition of tts_notify_reboot().

What exactly would it break?

> My intention is to keep new codes
> has limited impact on existed codes.

Even if that makes a little sense?

> Of course, it's possible to merge _TTS and _PTS into one unified notifier.
> The advantage is more actions could be added into the unified notifier in future.
> Which way you prefer?

I would just use one notifier.

Thanks,
Rafael

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

* RE: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-06-23 12:55   ` Ocean HY1 He
  2016-06-23 13:12     ` Rafael J. Wysocki
@ 2016-06-24  0:30     ` Zheng, Lv
  2016-06-24  2:06       ` Ocean HY1 He
  1 sibling, 1 reply; 15+ messages in thread
From: Zheng, Lv @ 2016-06-24  0:30 UTC (permalink / raw)
  To: Ocean HY1 He, Rafael J. Wysocki
  Cc: lenb, linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar

Hi,

> From: linux-acpi-owner@vger.kernel.org [mailto:linux-acpi-
> owner@vger.kernel.org] On Behalf Of Ocean HY1 He
> Subject: RE: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> Hi Rafael,
> Please see my reply in below.
> 
> Regards,
> Ocean He
> SW Development Dept.
> Beijing Design Center
> Enterprise Product Group
> Mobile: 18911778926
> E-mail: hehy1@lenovo.com
> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> 
> > -----Original Message-----
> > From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> > Sent: Wednesday, June 22, 2016 7:56 AM
> > To: Ocean HY1 He
> > Cc: lenb@kernel.org; linux-acpi@vger.kernel.org;
> > linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> > Subject: Re: [PATCH] ACPI: Execute the _PTS method when system
> reboot
> >
> > On Monday, May 09, 2016 05:50:11 AM Ocean HY1 He wrote:
> > > The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> > > spec. The _PTS control method is executed by the OS during the sleep
> > > transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> > > The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> > > soft-off state) is passed to the _PTS control method. This method
> > > is called after OSPM has notified native device drivers of the sleep
> > > state transition and before the OSPM has had a chance to fully
> > > prepare the system for a sleep state transition.
> > >
> > > The _PTS control method provides the BIOS a mechanism for
> performing
> > > some housekeeping, such as writing the sleep type value to the
> > embedded
> > > controller, before entering the system sleeping state.
> > >
> > > According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> > >
> > > Thus, a _PTS block notifier is added to the reboot notifier list so that
> > > the _PTS object will also be evaluated when the system reboot.
> >
> > So I understand why it may be necessary to evaluate _PTS before
> entering
> > S5,
> > but I'm totally unsure about reboot.
> >
> > What does reboot have to do with S5?
> >
> In ACPI spec, there is no explicit words saying _PTS should be
> executed when reboot. But reboot could be equal to the
> process S0->S5->S0. Thus _PTS should be executed when reboot.
> 
> I am thinking this is the same as _TTS. In ACPI spec, there is also
> no explicit words saying _TTS should be executed when reboot.
> But kernel executes _TTS when reboot indeed.
[Lv Zheng] 
What's the de-facto standard behavior here?
Lenovo should be able to modify BIOS, should you try to boot different Windows clones to confirm the necessity of doing this?

Thanks and best regards
-Lv

> 
> > > Signed-off-by: Ocean He <hehy1@lenovo.com>
> > > Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> > > ---
> > >  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
> > >  1 file changed, 27 insertions(+)
> > >
> > > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> > > index 2a8b596..8b290fb 100644
> > > --- a/drivers/acpi/sleep.c
> > > +++ b/drivers/acpi/sleep.c
> > > @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
> > >  	.priority	= 0,
> > >  };
> > >
> > > +static int pts_notify_reboot(struct notifier_block *this,
> > > +			unsigned long code, void *x)
> > > +{
> > > +	acpi_status status;
> > > +
> > > +	status = acpi_execute_simple_method(NULL, "\\_PTS",
> > ACPI_STATE_S5);
> > > +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > > +		/* It won't break anything. */
> > > +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
> > > +	}
> > > +
> > > +	return NOTIFY_DONE;
> > > +}
> > > +
> > > +static struct notifier_block pts_notifier = {
> > > +	.notifier_call	= pts_notify_reboot,
> > > +	.next		= NULL,
> > > +	.priority	= 0,
> > > +};
> > > +
> > >  static int acpi_sleep_prepare(u32 acpi_state)
> > >  {
> > >  #ifdef CONFIG_ACPI_SLEEP
> > > @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
> > >  	 * object can also be evaluated when the system enters S5.
> > >  	 */
> > >  	register_reboot_notifier(&tts_notifier);
> > > +
> > > +	/*
> > > +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
> > > +	 * _TTS when the system enters S5.
> > > +	 */
> > > +	register_reboot_notifier(&pts_notifier);
> >
> > Why do you have to add a second notifier?
> >
> > Why can't _TTS and _PTS be evaluated from one notifier?
> >
> If execute _PTS method in tts_notify_reboot(), then it would break
> definition of tts_notify_reboot(). My intention is to keep new codes
> has limited impact on existed codes.
> Of course, it's possible to merge _TTS and _PTS into one unified notifier.
> The advantage is more actions could be added into the unified notifier in
> future.
> Which way you prefer?
> > > +
> > >  	return 0;
> > >  }
> > >
> >
> > Thanks,
> > Rafael
> 
> \x13��칻\x1c�&�~�&�\x18��+-
> ��ݶ\x17��w��˛���m�b��Zr����^n�r���z�\x1a��h����&��\x1e�G���h�\x03(�階
> �ݢj"��\x1a�^[m�����z�ޖ���f���h���~�m�

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

* RE: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-06-24  0:30     ` Zheng, Lv
@ 2016-06-24  2:06       ` Ocean HY1 He
  0 siblings, 0 replies; 15+ messages in thread
From: Ocean HY1 He @ 2016-06-24  2:06 UTC (permalink / raw)
  To: Zheng, Lv, Rafael J. Wysocki
  Cc: lenb, linux-acpi, linux-kernel, David Tanaka, Nagananda Chumbalkar



Regards,
Ocean He
SW Development Dept. 
Beijing Design Center
Enterprise Product Group
Mobile: 18911778926
E-mail: hehy1@lenovo.com
No.6 Chuang Ye Road, Haidian District, Beijing, China 100085

> -----Original Message-----
> From: Zheng, Lv [mailto:lv.zheng@intel.com]
> Sent: Friday, June 24, 2016 8:30 AM
> To: Ocean HY1 He; Rafael J. Wysocki
> Cc: lenb@kernel.org; linux-acpi@vger.kernel.org;
> linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> Subject: RE: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> Hi,
> 
> > From: linux-acpi-owner@vger.kernel.org [mailto:linux-acpi-
> > owner@vger.kernel.org] On Behalf Of Ocean HY1 He
> > Subject: RE: [PATCH] ACPI: Execute the _PTS method when system
> reboot
> >
> > Hi Rafael,
> > Please see my reply in below.
> >
> > Regards,
> > Ocean He
> > SW Development Dept.
> > Beijing Design Center
> > Enterprise Product Group
> > Mobile: 18911778926
> > E-mail: hehy1@lenovo.com
> > No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> >
> > > -----Original Message-----
> > > From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> > > Sent: Wednesday, June 22, 2016 7:56 AM
> > > To: Ocean HY1 He
> > > Cc: lenb@kernel.org; linux-acpi@vger.kernel.org;
> > > linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> > > Subject: Re: [PATCH] ACPI: Execute the _PTS method when system
> > reboot
> > >
> > > On Monday, May 09, 2016 05:50:11 AM Ocean HY1 He wrote:
> > > > The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> > > > spec. The _PTS control method is executed by the OS during the
> sleep
> > > > transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> > > > The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> > > > soft-off state) is passed to the _PTS control method. This method
> > > > is called after OSPM has notified native device drivers of the sleep
> > > > state transition and before the OSPM has had a chance to fully
> > > > prepare the system for a sleep state transition.
> > > >
> > > > The _PTS control method provides the BIOS a mechanism for
> > performing
> > > > some housekeeping, such as writing the sleep type value to the
> > > embedded
> > > > controller, before entering the system sleeping state.
> > > >
> > > > According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> > > >
> > > > Thus, a _PTS block notifier is added to the reboot notifier list so that
> > > > the _PTS object will also be evaluated when the system reboot.
> > >
> > > So I understand why it may be necessary to evaluate _PTS before
> > entering
> > > S5,
> > > but I'm totally unsure about reboot.
> > >
> > > What does reboot have to do with S5?
> > >
> > In ACPI spec, there is no explicit words saying _PTS should be
> > executed when reboot. But reboot could be equal to the
> > process S0->S5->S0. Thus _PTS should be executed when reboot.
> >
> > I am thinking this is the same as _TTS. In ACPI spec, there is also
> > no explicit words saying _TTS should be executed when reboot.
> > But kernel executes _TTS when reboot indeed.
> [Lv Zheng]
> What's the de-facto standard behavior here?
> Lenovo should be able to modify BIOS, should you try to boot different
> Windows clones to confirm the necessity of doing this?
> 
> Thanks and best regards
> -Lv
> 
I have consulted Lenovo UEFI/BIOS archtect, David Tanaka. He says
the de-facto standard behavior is that _PTS should be executed when reboot,
at least for Windows. Windows does not differentiate OS reboot and shutdown.

And, our test on Windows shows _PTS is executed when reboot actually.

I try to find the difference between OS reboot and shutdown(S5) in ACPI spec,
but I cann't find the answer. So, in my mind I consider reboot equals S0->S5->S0.
Maybe you have evidence shows they are different, please let me know. It would
help me a lot. Thanks.

Ocean.
> >
> > > > Signed-off-by: Ocean He <hehy1@lenovo.com>
> > > > Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> > > > ---
> > > >  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
> > > >  1 file changed, 27 insertions(+)
> > > >
> > > > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> > > > index 2a8b596..8b290fb 100644
> > > > --- a/drivers/acpi/sleep.c
> > > > +++ b/drivers/acpi/sleep.c
> > > > @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
> > > >  	.priority	= 0,
> > > >  };
> > > >
> > > > +static int pts_notify_reboot(struct notifier_block *this,
> > > > +			unsigned long code, void *x)
> > > > +{
> > > > +	acpi_status status;
> > > > +
> > > > +	status = acpi_execute_simple_method(NULL, "\\_PTS",
> > > ACPI_STATE_S5);
> > > > +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > > > +		/* It won't break anything. */
> > > > +		printk(KERN_NOTICE "Failure in evaluating _PTS object\n");
> > > > +	}
> > > > +
> > > > +	return NOTIFY_DONE;
> > > > +}
> > > > +
> > > > +static struct notifier_block pts_notifier = {
> > > > +	.notifier_call	= pts_notify_reboot,
> > > > +	.next		= NULL,
> > > > +	.priority	= 0,
> > > > +};
> > > > +
> > > >  static int acpi_sleep_prepare(u32 acpi_state)
> > > >  {
> > > >  #ifdef CONFIG_ACPI_SLEEP
> > > > @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
> > > >  	 * object can also be evaluated when the system enters S5.
> > > >  	 */
> > > >  	register_reboot_notifier(&tts_notifier);
> > > > +
> > > > +	/*
> > > > +	 * According to section 7.5 of acpi 6.0 spec, _PTS should run after
> > > > +	 * _TTS when the system enters S5.
> > > > +	 */
> > > > +	register_reboot_notifier(&pts_notifier);
> > >
> > > Why do you have to add a second notifier?
> > >
> > > Why can't _TTS and _PTS be evaluated from one notifier?
> > >
> > If execute _PTS method in tts_notify_reboot(), then it would break
> > definition of tts_notify_reboot(). My intention is to keep new codes
> > has limited impact on existed codes.
> > Of course, it's possible to merge _TTS and _PTS into one unified notifier.
> > The advantage is more actions could be added into the unified notifier
> in
> > future.
> > Which way you prefer?
> > > > +
> > > >  	return 0;
> > > >  }
> > > >
> > >
> > > Thanks,
> > > Rafael
> >
> > \x13��칻\x1c�&�~�&�\x18��+-
> >
> ��ݶ\x17��w��˛���m�b��Zr����^n�r���z�\x1a��h����&��\x1e�G���h�\x03(�
> 階
> > �ݢj"��\x1a�^[m�����z�ޖ���f���h���~�m�

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

* RE: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-06-23 13:12     ` Rafael J. Wysocki
@ 2016-06-24  2:59       ` Ocean HY1 He
  2016-06-24 12:36         ` Rafael J. Wysocki
  0 siblings, 1 reply; 15+ messages in thread
From: Ocean HY1 He @ 2016-06-24  2:59 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J. Wysocki, lenb, linux-acpi, linux-kernel, David Tanaka,
	Nagananda Chumbalkar, Zheng, Lv, Sumeet Kochar



Regards,
Ocean He
SW Development Dept. 
Beijing Design Center
Enterprise Product Group
Mobile: 18911778926
E-mail: hehy1@lenovo.com
No.6 Chuang Ye Road, Haidian District, Beijing, China 100085


> -----Original Message-----
> From: rjwysocki@gmail.com [mailto:rjwysocki@gmail.com] On Behalf Of
> Rafael J. Wysocki
> Sent: Thursday, June 23, 2016 9:13 PM
> To: Ocean HY1 He
> Cc: Rafael J. Wysocki; lenb@kernel.org; linux-acpi@vger.kernel.org;
> linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system reboot
> 
> On Thu, Jun 23, 2016 at 2:55 PM, Ocean HY1 He <hehy1@lenovo.com>
> wrote:
> > Hi Rafael,
> > Please see my reply in below.
> >
> > Regards,
> > Ocean He
> > SW Development Dept.
> > Beijing Design Center
> > Enterprise Product Group
> > Mobile: 18911778926
> > E-mail: hehy1@lenovo.com
> > No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> >
> >> -----Original Message-----
> >> From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> >> Sent: Wednesday, June 22, 2016 7:56 AM
> >> To: Ocean HY1 He
> >> Cc: lenb@kernel.org; linux-acpi@vger.kernel.org;
> >> linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> >> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system
> reboot
> >>
> >> On Monday, May 09, 2016 05:50:11 AM Ocean HY1 He wrote:
> >> > The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> >> > spec. The _PTS control method is executed by the OS during the sleep
> >> > transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> >> > The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> >> > soft-off state) is passed to the _PTS control method. This method
> >> > is called after OSPM has notified native device drivers of the sleep
> >> > state transition and before the OSPM has had a chance to fully
> >> > prepare the system for a sleep state transition.
> >> >
> >> > The _PTS control method provides the BIOS a mechanism for
> performing
> >> > some housekeeping, such as writing the sleep type value to the
> >> embedded
> >> > controller, before entering the system sleeping state.
> >> >
> >> > According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> >> >
> >> > Thus, a _PTS block notifier is added to the reboot notifier list so that
> >> > the _PTS object will also be evaluated when the system reboot.
> >>
> >> So I understand why it may be necessary to evaluate _PTS before
> entering
> >> S5,
> >> but I'm totally unsure about reboot.
> >>
> >> What does reboot have to do with S5?
> >>
> > In ACPI spec, there is no explicit words saying _PTS should be
> > executed when reboot. But reboot could be equal to the
> > process S0->S5->S0.
> 
> Not in general.
> 
> In particular, wakeup devices that would be set up for S5 need not be
> set up for that.  Also the mechanism by which transitions to S5 are
> entered is different from the reboot one, at least from the OS
> perspective.
> 
> > Thus _PTS should be executed when reboot.
> 
> No, it doesn't follow.
> 
> > I am thinking this is the same as _TTS. In ACPI spec, there is also
> > no explicit words saying _TTS should be executed when reboot.
> > But kernel executes _TTS when reboot indeed.
> 
> Yes, it does.  Maybe it shouldn't?
> 
> It may not hurt to call _PTS before reboot too, but is it guaranteed
> to work across the board on all systems everywhere?
> 
I try to clarify the key point of this case: does devices should go to S5(shutdown) when reboot?

I think the answer is yes. 
And It has no hurt to let devices go to S5 before reboot is invoked, here is the reasons:
#1 The new _PTS codes block nothing thus reboot can be guaranteed to be invoked eventually.
#2. Devices are mandatory to support S5 state, this means go to S5 could be a safe trip.
#3 Reboot would cause devices re-initialization from the scratch.

What's your decision then? ;-)

Regards,
Ocean.

> >> > Signed-off-by: Ocean He <hehy1@lenovo.com>
> >> > Signed-off-by: Nagananda Chumbalkar <nchumbalkar@lenovo.com>
> >> > ---
> >> >  drivers/acpi/sleep.c | 27 +++++++++++++++++++++++++++
> >> >  1 file changed, 27 insertions(+)
> >> >
> >> > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> >> > index 2a8b596..8b290fb 100644
> >> > --- a/drivers/acpi/sleep.c
> >> > +++ b/drivers/acpi/sleep.c
> >> > @@ -55,6 +55,26 @@ static struct notifier_block tts_notifier = {
> >> >     .priority       = 0,
> >> >  };
> >> >
> >> > +static int pts_notify_reboot(struct notifier_block *this,
> >> > +                   unsigned long code, void *x)
> >> > +{
> >> > +   acpi_status status;
> >> > +
> >> > +   status = acpi_execute_simple_method(NULL, "\\_PTS",
> >> ACPI_STATE_S5);
> >> > +   if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> >> > +           /* It won't break anything. */
> >> > +           printk(KERN_NOTICE "Failure in evaluating _PTS
> object\n");
> >> > +   }
> >> > +
> >> > +   return NOTIFY_DONE;
> >> > +}
> >> > +
> >> > +static struct notifier_block pts_notifier = {
> >> > +   .notifier_call  = pts_notify_reboot,
> >> > +   .next           = NULL,
> >> > +   .priority       = 0,
> >> > +};
> >> > +
> >> >  static int acpi_sleep_prepare(u32 acpi_state)
> >> >  {
> >> >  #ifdef CONFIG_ACPI_SLEEP
> >> > @@ -896,5 +916,12 @@ int __init acpi_sleep_init(void)
> >> >      * object can also be evaluated when the system enters S5.
> >> >      */
> >> >     register_reboot_notifier(&tts_notifier);
> >> > +
> >> > +   /*
> >> > +    * According to section 7.5 of acpi 6.0 spec, _PTS should run
> after
> >> > +    * _TTS when the system enters S5.
> >> > +    */
> >> > +   register_reboot_notifier(&pts_notifier);
> >>
> >> Why do you have to add a second notifier?
> >>
> >> Why can't _TTS and _PTS be evaluated from one notifier?
> >>
> > If execute _PTS method in tts_notify_reboot(), then it would break
> > definition of tts_notify_reboot().
> 
> What exactly would it break?
> 
> > My intention is to keep new codes
> > has limited impact on existed codes.
> 
> Even if that makes a little sense?
> 
> > Of course, it's possible to merge _TTS and _PTS into one unified notifier.
> > The advantage is more actions could be added into the unified notifier
> in future.
> > Which way you prefer?
> 
> I would just use one notifier.
I follow you.
> 
> Thanks,
> Rafael

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

* Re: [PATCH] ACPI: Execute the _PTS method when system reboot
  2016-06-24  2:59       ` Ocean HY1 He
@ 2016-06-24 12:36         ` Rafael J. Wysocki
  0 siblings, 0 replies; 15+ messages in thread
From: Rafael J. Wysocki @ 2016-06-24 12:36 UTC (permalink / raw)
  To: Ocean HY1 He
  Cc: Rafael J. Wysocki, lenb, linux-acpi, linux-kernel, David Tanaka,
	Nagananda Chumbalkar, Zheng, Lv, Sumeet Kochar

On Friday, June 24, 2016 02:59:24 AM Ocean HY1 He wrote:
> 
> Regards,
> Ocean He
> SW Development Dept. 
> Beijing Design Center
> Enterprise Product Group
> Mobile: 18911778926
> E-mail: hehy1@lenovo.com
> No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> 
> 
> > -----Original Message-----
> > From: rjwysocki@gmail.com [mailto:rjwysocki@gmail.com] On Behalf Of
> > Rafael J. Wysocki
> > Sent: Thursday, June 23, 2016 9:13 PM
> > To: Ocean HY1 He
> > Cc: Rafael J. Wysocki; lenb@kernel.org; linux-acpi@vger.kernel.org;
> > linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> > Subject: Re: [PATCH] ACPI: Execute the _PTS method when system reboot
> > 
> > On Thu, Jun 23, 2016 at 2:55 PM, Ocean HY1 He <hehy1@lenovo.com>
> > wrote:
> > > Hi Rafael,
> > > Please see my reply in below.
> > >
> > > Regards,
> > > Ocean He
> > > SW Development Dept.
> > > Beijing Design Center
> > > Enterprise Product Group
> > > Mobile: 18911778926
> > > E-mail: hehy1@lenovo.com
> > > No.6 Chuang Ye Road, Haidian District, Beijing, China 100085
> > >
> > >> -----Original Message-----
> > >> From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net]
> > >> Sent: Wednesday, June 22, 2016 7:56 AM
> > >> To: Ocean HY1 He
> > >> Cc: lenb@kernel.org; linux-acpi@vger.kernel.org;
> > >> linux-kernel@vger.kernel.org; David Tanaka; Nagananda Chumbalkar
> > >> Subject: Re: [PATCH] ACPI: Execute the _PTS method when system
> > reboot
> > >>
> > >> On Monday, May 09, 2016 05:50:11 AM Ocean HY1 He wrote:
> > >> > The _PTS control method is defined in the section 7.4.1 of acpi 6.0
> > >> > spec. The _PTS control method is executed by the OS during the sleep
> > >> > transition process for S1, S2, S3, S4, and for orderly S5 shutdown.
> > >> > The sleeping state value (For example, 1, 2, 3, 4 or 5 for the S5
> > >> > soft-off state) is passed to the _PTS control method. This method
> > >> > is called after OSPM has notified native device drivers of the sleep
> > >> > state transition and before the OSPM has had a chance to fully
> > >> > prepare the system for a sleep state transition.
> > >> >
> > >> > The _PTS control method provides the BIOS a mechanism for
> > performing
> > >> > some housekeeping, such as writing the sleep type value to the
> > >> embedded
> > >> > controller, before entering the system sleeping state.
> > >> >
> > >> > According to section 7.5 of acpi 6.0 spec, _PTS should run after _TTS.
> > >> >
> > >> > Thus, a _PTS block notifier is added to the reboot notifier list so that
> > >> > the _PTS object will also be evaluated when the system reboot.
> > >>
> > >> So I understand why it may be necessary to evaluate _PTS before
> > entering
> > >> S5,
> > >> but I'm totally unsure about reboot.
> > >>
> > >> What does reboot have to do with S5?
> > >>
> > > In ACPI spec, there is no explicit words saying _PTS should be
> > > executed when reboot. But reboot could be equal to the
> > > process S0->S5->S0.
> > 
> > Not in general.
> > 
> > In particular, wakeup devices that would be set up for S5 need not be
> > set up for that.  Also the mechanism by which transitions to S5 are
> > entered is different from the reboot one, at least from the OS
> > perspective.
> > 
> > > Thus _PTS should be executed when reboot.
> > 
> > No, it doesn't follow.
> > 
> > > I am thinking this is the same as _TTS. In ACPI spec, there is also
> > > no explicit words saying _TTS should be executed when reboot.
> > > But kernel executes _TTS when reboot indeed.
> > 
> > Yes, it does.  Maybe it shouldn't?
> > 
> > It may not hurt to call _PTS before reboot too, but is it guaranteed
> > to work across the board on all systems everywhere?
> > 
> I try to clarify the key point of this case: does devices should go to S5(shutdown) when reboot?
> 
> I think the answer is yes. 
> And It has no hurt to let devices go to S5 before reboot is invoked, here is the reasons:

S5 is a platform (system) state, not a device state.

You seem to be confusing platforms with devices.

> #1 The new _PTS codes block nothing thus reboot can be guaranteed to be invoked eventually.
> #2. Devices are mandatory to support S5 state, this means go to S5 could be a safe trip.
> #3 Reboot would cause devices re-initialization from the scratch.
> 
> What's your decision then? ;-)

I guess you can argue that since _TTS is already executed in the reboot
path, it might be good to execute _PTS in that path too and that might help
to avoid issues in some cases.

That is a reasonable argument, but then there still is the question if that
is not going to break anything.

I guess that cannot be answered without trying, so the simplest patch would
be to add a _PTS evaulation to the existing notifier (and maybe change the
notifiers name to reflect the fact that it's not for _TTS ony any more).

Thanks,
Rafael


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

end of thread, other threads:[~2016-06-24 12:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-09  5:50 [PATCH] ACPI: Execute the _PTS method when system reboot Ocean HY1 He
2016-05-16  3:04 ` Ocean HY1 He
2016-05-24  6:41 ` Ocean HY1 He
2016-05-24 10:15   ` Prarit Bhargava
2016-05-24 10:15     ` Prarit Bhargava
2016-05-30  3:28     ` Ocean HY1 He
2016-05-31  9:59       ` Prarit Bhargava
2016-05-31  9:59         ` Prarit Bhargava
2016-06-21 23:56 ` Rafael J. Wysocki
2016-06-23 12:55   ` Ocean HY1 He
2016-06-23 13:12     ` Rafael J. Wysocki
2016-06-24  2:59       ` Ocean HY1 He
2016-06-24 12:36         ` Rafael J. Wysocki
2016-06-24  0:30     ` Zheng, Lv
2016-06-24  2:06       ` Ocean HY1 He

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.