diff mbox

ACPI: Execute the _PTS method when system reboot

Message ID BCBE834BAC19744BA2C3AC4D68DBF2198D8270D9@CNMAILEX03.lenovo.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Ocean HY1 He May 24, 2016, 6:41 a.m. UTC
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(+)

-- 
1.8.3.1

Comments

Prarit Bhargava May 24, 2016, 10:15 a.m. UTC | #1
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
Ocean HY1 He May 30, 2016, 3:28 a.m. UTC | #2
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBQcmFyaXQgQmhhcmdhdmEgW21h
aWx0bzpwcmFyaXRAcmVkaGF0LmNvbV0NCj4gU2VudDogVHVlc2RheSwgTWF5IDI0LCAyMDE2IDY6
MTYgUE0NCj4gVG86IE9jZWFuIEhZMSBIZTsgamNtQHJlZGhhdC5jb20NCj4gQ2M6IGxpbnV4LWFj
cGlAdmdlci5rZXJuZWwub3JnOyBsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnOyBEYXZpZCBU
YW5ha2E7DQo+IE5hZ2FuYW5kYSBDaHVtYmFsa2FyOyByandAcmp3eXNvY2tpLm5ldDsgbGVuYkBr
ZXJuZWwub3JnOw0KPiB3ZWZ1QHJlZGhhdC5jb20NCj4gU3ViamVjdDogUmU6IFtQQVRDSF0gQUNQ
STogRXhlY3V0ZSB0aGUgX1BUUyBtZXRob2Qgd2hlbiBzeXN0ZW0gcmVib290DQo+IA0KPiANCj4g
DQo+IE9uIDA1LzI0LzIwMTYgMDI6NDEgQU0sIE9jZWFuIEhZMSBIZSB3cm90ZToNCj4gPiBIaSBQ
cmFyaXQgYW5kIEpvbiwNCj4gPg0KPiA+IEhvdyBkbyB5b3UgdGhpbmsgb2YgdGhpcz8NCj4gPg0K
PiA+IFRoYW5rcy4NCj4gPg0KPiA+IE9jZWFuIEhlIC8gus66o9HzDQo+ID4gU1cgRGV2ZWxvcG1l
bnQgR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iArfTsNCj4gPiArDQo+ID4gIHN0YXRpYyBpbnQgYWNwaV9zbGVlcF9w
cmVwYXJlKHUzMiBhY3BpX3N0YXRlKQ0KPiA+ICB7DQo+ID4gICNpZmRlZiBDT05GSUdfQUNQSV9T
TEVFUA0KPiA+IEBAIC04OTYsNSArOTE2LDEyIEBAIGludCBfX2luaXQgYWNwaV9zbGVlcF9pbml0
KHZvaWQpDQo+ID4gIAkgKiBvYmplY3QgY2FuIGFsc28gYmUgZXZhbHVhdGVkIHdoZW4gdGhlIHN5
c3RlbSBlbnRlcnMgUzUuDQo+ID4gIAkgKi8NCj4gPiAgCXJlZ2lzdGVyX3JlYm9vdF9ub3RpZmll
cigmdHRzX25vdGlmaWVyKTsNCj4gPiArDQo+ID4gKwkvKg0KPiA+ICsJICogQWNjb3JkaW5nIHRv
IHNlY3Rpb24gNy41IG9mIGFjcGkgNi4wIHNwZWMsIF9QVFMgc2hvdWxkIHJ1biBhZnRlcg0KPiA+
ICsJICogX1RUUyB3aGVuIHRoZSBzeXN0ZW0gZW50ZXJzIFM1Lg0KPiA+ICsJICovDQo+ID4gKwly
ZWdpc3Rlcl9yZWJvb3Rfbm90aWZpZXIoJnB0c19ub3RpZmllcik7DQo+ID4gKw0KPiA+ICAJcmV0
dXJuIDA7DQo+ID4gIH0NCj4gPg0K
--
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
Prarit Bhargava May 31, 2016, 9:59 a.m. UTC | #3
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
diff mbox

Patch

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;
 }