Bug 35262

Summary: Toshiba C670D-10C restarts instead of poweroff when on AC
Product: ACPI Reporter: Anisse Astier (anisse)
Component: Power-OffAssignee: Zhang Rui (rui.zhang)
Status: CLOSED CODE_FIX    
Severity: normal CC: alan, florian, lenb, linux, rui.zhang, sebastien.wilmet
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.4-rc3 3.5.3 3.6.0-rc5 Tree: Mainline
Regression: No
Attachments: DSDT of Toshiba C670D-10C
dmesg
Patch to disable ACPI LID wakeup at shutdown
patch: do not use Lid and sleep button for S5 wakeup
patch: do not use Lid and sleep button for S5 wakeup

Description Anisse Astier 2011-05-17 15:42:05 UTC
Created attachment 58292 [details]
DSDT of Toshiba C670D-10C

Toshiba C670D-10C restarts instead of powering off when on AC. It shuts down correctly when on battery.

I tried booting with:
acpi_osi="Linux"
acpi=copy_dsdt (even though it should be the default on all Toshiba hardware now)
acpi_os_name="Windows 2009"
acpi_os_name="Windows 2001"

Works under Windows 7, and in LILO/grub.

No BIOS update available from vendor ATM.

Attaching DSDT.
Comment 1 Anisse Astier 2011-05-17 15:42:47 UTC
Created attachment 58302 [details]
dmesg
Comment 2 Sébastien Wilmet 2011-06-03 16:19:33 UTC
I have the same problem with Fedora 15 (version 2.6.38 of the kernel). My computer is an Asus PRO50N.

See this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=710532
Comment 3 Sébastien Wilmet 2011-06-03 16:22:36 UTC
Ah, I didn't try on battery. On AC, sometimes it's OK, sometimes not (for the Asus PRO50N).
Comment 4 Richard Körber 2011-06-07 08:35:36 UTC
Same here. It's Fedora 15 on a desktop machine with Asus mainboard, so it does not seem to be just notebook related. With Fedora 14, the system always shut down reliably.
Comment 5 Anisse Astier 2011-07-26 16:09:41 UTC
Did a few more tests:
I tested with 2.6.33 and 2.6.35, and it's not working either, so this does not seem to be a (recent) regression.

Tried disabling enabled GPE interrupts before shutting down, in /sys/firmware/acpi/interrupts/, it didn't have any effect.

Finally, I tried disabling wakeup sources in /proc/acpi/wakeup, and I found the culprit: the "LID" wakeup source.
So running:
echo " LID" > /proc/acpi/wakeup
before shutting down, will have the laptop halt without rebooting whether it's plugged or not.

I checked in the BIOS, and there's an option "Panel Open - Power On", and it wasn't enabled. I tried enabling/disabling it, and the problem is reproduced whether it's on or off.
Also, the problem is reproduced whether the lid is open or closed. And the problem is fixed with 
echo " LID" > /proc/acpi/wakeup
whether the lid is open or closed.

I don't know yet how to solve this at the kernel level.
Comment 6 Richard Körber 2011-07-27 08:51:42 UTC
The echo " LID" fixes this issue even on my desktop machine. :)
Comment 7 Anisse Astier 2011-07-28 15:10:14 UTC
Richard, Sébastien : what BIOS does your computer have ?

The Toshiba laptop has an AMI (American Megatrends Inc) Aptio bios.
Comment 8 Anisse Astier 2011-07-28 16:00:35 UTC
Created attachment 67032 [details]
Patch to disable ACPI LID wakeup at shutdown

Attached patch should do the same as the echo " LID" thing, but in kernel.
Comment 9 Sébastien Wilmet 2011-07-28 19:30:06 UTC
Anisse, my BIOS is an AMI v02.59 (for the Asus PRO50N).

But now I've installed Gentoo, and I don't have the problem anymore. So it was maybe the fault of systemd in Fedora 15 or another module, since I used the same kernel version (2.6.38).
Comment 10 Richard Körber 2011-07-28 21:07:14 UTC
It's a Phoenix AwardBIOS here.
Comment 11 Zhang Rui 2012-01-18 05:15:32 UTC
It's great that the kernel bugzilla is back.

Can you please verify if the problem still exists in the latest upstream
kernel?
Comment 12 Adrian Batzill 2012-04-21 11:59:50 UTC
For me, the bug also exist in the latest kernel (3.4-rc3).

Applying the patch posted above fixes it for me (Asus EEE PC r252b).

If you want:
Tested-by: Adrian Batzill <linux@batzill.com>
Comment 13 Anisse Astier 2012-04-22 20:47:25 UTC
Thanks Adrian for the Tested-by, but I don't think this patch will be accepted as-is, it's just a hack. That's why I didn't sign it off.

I stopped working on this hardware, but if anyone wants to implement a proper fix for this they should probably look at the acpi "button" driver.
Comment 14 Adrian Batzill 2012-04-22 20:51:38 UTC
Hey,
Thanks for responding anyway. I'd love to work on a proper patch, but I'm pretty new to kernel development (especially on ACPI).

Could you give a few hints on where/how I could start on this, if you have time?
That would be really awesome.
(If not, I'll just try a few days until I have figured it out myself :/)

Thanks
Comment 15 Anisse Astier 2012-09-14 14:56:28 UTC
This bug also impacts the Toshiba Satellite C870-16F.

I think we can label that as a generic Linux bug, something that is done differently from windows and impacts different hardware and BIOS.
Comment 16 Zhang Rui 2012-11-28 03:18:11 UTC
anisse,

you patch disables the Lid Wake GPE when shutdown, right?
IMO, a proper fix would be disabling unused GPEs before shutdown, and we should do it in ACPI general code instead.
what do you think?
Comment 17 Anisse Astier 2012-11-28 09:21:50 UTC
Zhang Rui,

Yes, that would be the best course of action. I didn't look much at the details, but how would you know if a GPE is unused ?
Plus, I thought this was already done, see drivers/acpi/sleep.c acpi_power_off_prepare calls acpi_disable_all_gpes(), so I might be missing something here, but maybe it's related to the order in which the actions are done ?
Comment 18 Zhang Rui 2012-11-29 04:43:37 UTC
then the difference would be:
            Method (_PSW, 1, NotSerialized)  // _PSW: Power State Wake
            {
                Store (Arg0, LDST)
            }

you patch disables _PSW, while acpi_disable_all_gpes does not.
this also make sens.
I'll cook up a patch to disable _PRW before shutdown.
Comment 19 Zhang Rui 2012-11-30 06:40:33 UTC
Created attachment 87911 [details]
patch: do not use Lid and sleep button for S5 wakeup

please try this patch to see if it helps.
Comment 20 Zhang Rui 2012-12-04 16:07:17 UTC
Created attachment 88431 [details]
patch: do not use Lid and sleep button for S5 wakeup

please try this patch instead.
Comment 21 Zhang Rui 2012-12-11 01:04:45 UTC
Patch has been sent out and queued for 3.8
Comment 22 Florian Mickler 2012-12-22 09:19:36 UTC
A patch referencing this bug report has been merged in Linux v3.8-rc1:

commit b7e383046c2c7c13ad928cd7407eafff758ddd4b
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Tue Dec 4 23:23:16 2012 +0100

    ACPI : do not use Lid and Sleep button for S5 wakeup