Bug 12091

Summary: ACPI AC driver doesn't work on Toshiba Portege R500 (bisected)
Product: ACPI Reporter: Rafael J. Wysocki (rjw)
Component: Power-OtherAssignee: Zhang Rui (rui.zhang)
Severity: normal CC: acpi-bugzilla, walken
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.28-rc1 Subsystem:
Regression: Yes Bisected commit-id:
Bug Depends on:    
Bug Blocks: 11808    
Attachments: dmesg log from the affected box
lspci -vxxx from the affected box
Output of acpidump from the affected box
patch: PCI root bridge always enable wakeup

Description Rafael J. Wysocki 2008-11-23 17:16:27 UTC
Subject    : ACPI AC driver doesn't work on Toshiba Portege R500 (bisected)
Submitter  : "Rafael J. Wysocki" <rjw@sisk.pl>
Date       : 2008-11-23 23:37
References : http://marc.info/?l=linux-kernel&m=122748347622592&w=4
Notify-Also : Zhao Yakui <yakui.zhao@intel.com>

This entry is being used for tracking a regression from 2.6.27.  Please don't
close it until the problem is fixed in the mainline.
Comment 1 Rafael J. Wysocki 2008-11-23 17:17:41 UTC
Introduced by:

commit faee816b1502385dc9bc5abf2960d1cc645844d1
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Fri Sep 12 11:12:25 2008 +0800

    ACPI: don't enable control method power button as wakeup device when Fixed Power button is used

    don't enable control method power button as wakeup device
    when Fixed Power button is used.


    Tested-by: walken@zoy.org <walken@zoy.org>
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

First-Bad-Commit : faee816b1502385dc9bc5abf2960d1cc645844d1
Comment 2 Rafael J. Wysocki 2008-11-23 17:19:16 UTC
Created attachment 18993 [details]
dmesg log from the affected box

It contains boot messages and a suspend/resume cycle.
Comment 3 Rafael J. Wysocki 2008-11-23 17:19:43 UTC
Created attachment 18994 [details]
lspci -vxxx from the affected box
Comment 4 Rafael J. Wysocki 2008-11-23 17:20:13 UTC
Created attachment 18995 [details]
Output of acpidump from the affected box
Comment 5 Zhang Rui 2008-11-23 17:37:20 UTC
1. kill acpid and run "cat /proc/acpi/event"
2. suspend and resume
3. attach the output of /proc/acpi/event

please do this test in both and 2.6.28-rc1
Comment 6 Zhang Rui 2008-11-23 18:09:10 UTC
okay, seems that the problem is clear now.
In bug #10503, power button share the GPE with PNP0A03. we don't want to enable the PNP0A03 events(PME) when suspend to ram, thus we set the Power button GPE as a WAKE GPE which is usually disabled during suspend/resume.
And in this bug, power button share the GPE with AC adapter. If the patch for bug #10503 is applied, GPE 0x08 is never enabled at runtime, thus we can not get the AC adapter events.
Comment 7 Zhang Rui 2008-11-23 18:35:22 UTC
look at this section in ACPI spec,
"Events that wake may not be intermixed with non-wake (runtime) events on the same GPE input. The only exception to this rule is made for the special devices below. Only the following devices are allowed to utilize a single GPE for both wake and runtime events:
1) Button Devices
     •     PNP0C0C — Power Button Device
     •     PNP0C0D — Lid Device
     •     PNP0C0E — Sleep Button Device
2) PCI Bus Wakeup Event Reporting (PME)
     •     PNP0A03 — PCI Host Bridge

the ideal solution should be:
1. revert faee816b1502385dc9bc5abf2960d1cc645844d1 to fix this regression.

2. set Both button devices and PCI host bridge as RUN_WAKE devices according to ACPI spec.

3. As the PNP0A03 GPE is a RUN_WAKE GPE then, it's always enabled during suspend/resume. Then it's the PCI device's responsibility to determine when PMEs should be issued, done by commit 49db139955d3392c6c4facf987905d0a9afed581. 

But in order to prove this, first of all we should make sure bug #10503 can't be reproduced in the latest kernel after faee816b1502385dc9bc5abf2960d1cc645844d1 is reverted. 

what do you think?
Comment 8 walken 2008-11-23 20:14:23 UTC
Zhang, I can try whatever kernel you direct me to if this helps. Would 2.6.27.x work or do I have to go with a 2.6.28 RC ?
(Posting here because bug 10503 was about one of my boxes)
Comment 9 Zhang Rui 2008-11-24 00:40:23 UTC
Created attachment 18997 [details]
patch: PCI root bridge always enable wakeup

good news.
it seems that we should always enable the PCI root bridge GPE.
and PCI device drivers issue the PME if necessary.
But I'm not sure if there are some devices/drivers with PME bit enabled during S3 by default. if yes, this patch may brings another regression (system resumes soon after suspends).
Comment 10 Zhang Rui 2008-11-24 00:41:43 UTC
walken, please try this patch
and attach the content of /proc/acpi/wakeup.
Comment 11 walken 2008-11-24 01:10:47 UTC
Seems to work too !

% cat /proc/acpi/wakeup 
Device  S-state   Status   Sysfs node
PWRB      S5    *enabled   
PCI0      S4    *enabled   no-bus:pci0000:00
USB0      S4     disabled  pci:0000:00:04.2
USB1      S4     disabled  pci:0000:00:04.3
Comment 12 Rafael J. Wysocki 2008-11-24 11:54:33 UTC
Handled-By : Zhang Rui <rui.zhang@intel.com>
Notify-Also : walken <walken@zoy.org>
Comment 13 Rafael J. Wysocki 2008-11-24 11:55:05 UTC
It seems the info has been provided.
Comment 14 Zhang Rui 2008-11-24 17:30:54 UTC
okay, problem is clear.
And Rafael, please revert faee816b1502385dc9bc5abf2960d1cc645844d1 as a solution.

I prefer to enable PCI root bright GPE at both runtime at wakeup, but it's another problem, and I think its target is 2.6.29. :)

Rafael, please close it when the commit is reverted.
Comment 15 Len Brown 2008-11-26 14:56:17 UTC
revert checked into acpi tree:

commit 3bdca1b863c1ebcb2244fc0cb683876d7330e62b
Author: Len Brown <len.brown@intel.com>
Date:   Wed Nov 26 17:55:15 2008 -0500

    Revert "ACPI: don't enable control method power button as wakeup device when Fixed Power button is used"
    This reverts commit faee816b1502385dc9bc5abf2960d1cc645844d1.