Bug 206629 - S2IDLE wakes up after disconnecting any USB device on Dell XPS 13 9370
Summary: S2IDLE wakes up after disconnecting any USB device on Dell XPS 13 9370
Status: RESOLVED PATCH_ALREADY_AVAILABLE
Alias: None
Product: ACPI
Classification: Unclassified
Component: Power-Sleep-Wake (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: Rafael J. Wysocki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-21 17:42 UTC by Ondřej Caletka
Modified: 2020-04-26 09:21 UTC (History)
3 users (show)

See Also:
Kernel Version: 5.5.5
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments
Dmesg suspend-wakeup cycle with device_pm.c debug on (9.81 KB, text/plain)
2020-03-16 11:14 UTC, Ondřej Caletka
Details
Wakeup debug patch (438 bytes, patch)
2020-03-18 09:57 UTC, Rafael J. Wysocki
Details | Diff
Dmesg suspend-wakeup cycle with debug patch (249.38 KB, text/plain)
2020-03-18 15:59 UTC, Ondřej Caletka
Details
acpidump od XPS 13 9370 (1.12 MB, text/plain)
2020-03-19 11:15 UTC, Ondřej Caletka
Details
Debug patch for __acpi_ec_flush_work() (528 bytes, patch)
2020-03-20 13:43 UTC, Rafael J. Wysocki
Details | Diff
acpi_s2idle_wake() debug patch (1.03 KB, patch)
2020-03-21 11:20 UTC, Rafael J. Wysocki
Details | Diff
Dmesg suspend-wakeup cycle with wake loop patch (9.27 KB, text/plain)
2020-03-21 13:40 UTC, Ondřej Caletka
Details
ACPI: PM: s2idle: Refine the active GPEs check in acpi_s2idle_wake() (7.94 KB, patch)
2020-03-23 15:18 UTC, Rafael J. Wysocki
Details | Diff
v2: ACPI: PM: s2idle: Refine the active GPEs check in acpi_s2idle_wake() (8.90 KB, patch)
2020-03-24 13:20 UTC, Rafael J. Wysocki
Details | Diff
Dmesg with refine active GPE check patch (168.24 KB, text/plain)
2020-03-24 15:33 UTC, Ondřej Caletka
Details

Description Ondřej Caletka 2020-02-21 17:42:03 UTC
After updating from kernel 5.5.3 to 5.5.5 my Dell XPS 13 9370 wakes up from S2IDLE whenever a USB device is connected or disconnected. The laptop will wake up even when charger is unplugged, which is pretty inconvenient. Reverting to 5.5.3 fixes the issue.

Both S0 wakeup sources listed in /proc/acpi/wakeup are disabled.
Comment 1 Ondřej Caletka 2020-02-25 12:17:59 UTC
Using git-bissect, I was able to trace down the problem to this commit:

commit 3a7a68b0b7ceba6f0ce6f2f50ecef278c0a77a51 (HEAD, refs/bisect/bad)
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Tue Feb 11 10:07:43 2020 +0100

    ACPI: EC: Fix flushing of pending work
Comment 2 Ondřej Caletka 2020-03-12 19:56:55 UTC
Update: This issue still persist as of 5.6-rc5.
Comment 3 Rafael J. Wysocki 2020-03-14 11:16:05 UTC
(In reply to Ondřej Caletka from comment #1)
> Using git-bissect, I was able to trace down the problem to this commit:
> 
> commit 3a7a68b0b7ceba6f0ce6f2f50ecef278c0a77a51 (HEAD, refs/bisect/bad)
> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Date:   Tue Feb 11 10:07:43 2020 +0100
> 
>     ACPI: EC: Fix flushing of pending work

This is mainline commit:

f0ac20c3f613 ACPI: EC: Fix flushing of pending work
Comment 4 Rafael J. Wysocki 2020-03-14 11:22:40 UTC
Please run

$ grep -r '.*' /sys/bus/usb/devices/*/power/wakeup

on your system and let me know the result.
Comment 5 Ondřej Caletka 2020-03-15 17:38:26 UTC
(In reply to Rafael J. Wysocki from comment #4)
> Please run
> 
> $ grep -r '.*' /sys/bus/usb/devices/*/power/wakeup
> 
> on your system and let me know the result.

Here is the result:

    $ grep -r '.*' /sys/bus/usb/devices/*/power/wakeup
    /sys/bus/usb/devices/usb1/power/wakeup:disabled
    /sys/bus/usb/devices/usb2/power/wakeup:disabled
    /sys/bus/usb/devices/usb3/power/wakeup:disabled
    /sys/bus/usb/devices/usb4/power/wakeup:disabled
    /sys/bus/usb/devices/1-10/power/wakeup:disabled
    /sys/bus/usb/devices/1-7/power/wakeup:disabled
Comment 6 Rafael J. Wysocki 2020-03-15 19:20:19 UTC
Please echo 1 (as root) into /sys/power/pm_debug_messages:

# echo 1 > /sys/power/pm_debug_messages

suspend the system, unplug/plug the AC adapter (or a USB device) to wake it up and attach the output of dmesg.
Comment 7 Ondřej Caletka 2020-03-15 19:31:52 UTC
Here comes the dmesg from suspend to wakeup:

[  118.428777] PM: suspend entry (s2idle)
[  118.428918] Filesystems sync: 0.000 seconds
[  118.428919] PM: Preparing system for sleep (s2idle)
[  118.429903] Freezing user space processes ... (elapsed 0.001 seconds) done.
[  118.431449] OOM killer disabled.
[  118.431449] Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done.
[  118.432398] PM: Suspending system (s2idle)
[  118.432399] printk: Suspending console(s) (use no_console_suspend to debug)
[  118.432671] wlan0: deauthenticating from 04:f0:21:24:20:54 by local choice (Reason: 3=DEAUTH_LEAVING)
[  118.991748] PM: suspend of devices complete after 559.228 msecs
[  118.991753] PM: start suspend of devices complete after 559.377 msecs
[  119.006626] PM: late suspend of devices complete after 14.861 msecs
[  119.011968] ACPI: EC: interrupt blocked
[  119.045432] PM: noirq suspend of devices complete after 34.576 msecs
[  119.045441] ACPI: \_PR_.PR00: LPI: Device not power manageable
[  119.045444] ACPI: \_PR_.PR01: LPI: Device not power manageable
[  119.045447] ACPI: \_PR_.PR02: LPI: Device not power manageable
[  119.045450] ACPI: \_PR_.PR03: LPI: Device not power manageable
[  119.045452] ACPI: \_PR_.PR04: LPI: Device not power manageable
[  119.045455] ACPI: \_PR_.PR05: LPI: Device not power manageable
[  119.045457] ACPI: \_PR_.PR06: LPI: Device not power manageable
[  119.045460] ACPI: \_PR_.PR07: LPI: Device not power manageable
[  119.045463] ACPI: \_SB_.PCI0.GFX0: LPI: Device not power manageable
[  119.045470] ACPI: \_SB_.PCI0.RP03.PXSX: LPI: Device not power manageable
[  119.045474] ACPI: \_SB_.PCI0.RP09.PXSX: LPI: Device not power manageable
[  119.083482] PM: suspend-to-idle
[  119.083583] PM: EC GPE dispatched
[  119.123408] PM: EC GPE dispatched
[  136.525444] PM: Timekeeping suspended for 16.044 seconds
[  136.525748] PM: EC GPE dispatched
[  136.574896] ACPI: \_PR_.PR00: Found 3 idle states
[  136.574967] ACPI: \_PR_.PR00: Found 3 idle states
[  136.575177] ACPI: \_PR_.PR01: Found 3 idle states
[  136.576945] ACPI: \_PR_.PR02: Found 3 idle states
[  136.577054] ACPI: \_PR_.PR03: Found 3 idle states
[  136.577238] ACPI: \_PR_.PR04: Found 3 idle states
[  136.579019] ACPI: \_PR_.PR05: Found 3 idle states
[  136.579125] ACPI: \_PR_.PR06: Found 3 idle states
[  136.579214] ACPI: \_PR_.PR07: Found 3 idle states
[  136.596980] PM: EC GPE dispatched
[  136.597095] PM: EC GPE dispatched
[  136.597774] PM: EC GPE dispatched
[  136.597969] PM: EC GPE dispatched
[  136.598077] PM: EC GPE dispatched
[  136.598859] PM: EC GPE dispatched
[  136.599063] PM: EC GPE dispatched
[  136.599174] PM: EC GPE dispatched
[  136.599949] PM: EC GPE dispatched
[  136.600144] PM: EC GPE dispatched
[  136.600255] PM: EC GPE dispatched
[  136.600424] PM: EC GPE dispatched
[  136.601035] PM: EC GPE dispatched
[  136.601232] PM: EC GPE dispatched
[  136.601335] PM: EC GPE dispatched
[  136.601511] PM: EC GPE dispatched
[  136.602125] PM: EC GPE dispatched
[  136.602320] PM: EC GPE dispatched
[  136.602428] PM: EC GPE dispatched
[  136.603206] PM: EC GPE dispatched
[  136.603407] PM: EC GPE dispatched
[  136.603518] PM: EC GPE dispatched
[  136.604297] PM: EC GPE dispatched
[  136.604495] PM: EC GPE dispatched
[  136.604607] PM: EC GPE dispatched
[  136.608316] PM: EC GPE dispatched
[  136.608936] PM: EC GPE dispatched
[  136.609136] PM: EC GPE dispatched
[  136.609245] PM: EC GPE dispatched
[  136.609410] PM: EC GPE dispatched
[  136.610027] PM: EC GPE dispatched
[  136.610220] PM: EC GPE dispatched
[  136.610327] PM: EC GPE dispatched
[  136.610494] PM: EC GPE dispatched
[  136.611110] PM: EC GPE dispatched
[  136.611310] PM: EC GPE dispatched
[  136.611419] PM: EC GPE dispatched
[  136.611588] PM: EC GPE dispatched
[  136.612197] PM: EC GPE dispatched
[  136.612397] PM: EC GPE dispatched
[  136.612507] PM: EC GPE dispatched
[  136.613286] PM: EC GPE dispatched
[  136.613483] PM: EC GPE dispatched
[  136.613594] PM: EC GPE dispatched
[  136.613757] PM: EC GPE dispatched
[  136.614376] PM: EC GPE dispatched
[  136.614578] PM: EC GPE dispatched
[  136.614687] PM: EC GPE dispatched
[  136.615462] PM: EC GPE dispatched
[  136.615660] PM: EC GPE dispatched
[  136.615771] PM: EC GPE dispatched
[  136.616549] PM: EC GPE dispatched
[  136.616749] PM: EC GPE dispatched
[  136.616855] PM: EC GPE dispatched
[  136.617012] PM: EC GPE dispatched
[  136.617638] PM: EC GPE dispatched
[  136.617836] PM: EC GPE dispatched
[  136.617954] PM: EC GPE dispatched
[  136.618725] PM: EC GPE dispatched
[  136.618923] PM: EC GPE dispatched
[  136.619031] PM: EC GPE dispatched
[  136.619191] PM: EC GPE dispatched
[  136.619808] PM: EC GPE dispatched
[  136.620010] PM: EC GPE dispatched
[  136.620114] PM: EC GPE dispatched
[  136.620282] PM: EC GPE dispatched
[  136.620900] PM: EC GPE dispatched
[  136.621097] PM: EC GPE dispatched
[  136.621202] PM: EC GPE dispatched
[  136.621369] PM: EC GPE dispatched
[  136.621982] PM: EC GPE dispatched
[  136.622186] PM: EC GPE dispatched
[  136.622296] PM: EC GPE dispatched
[  136.622459] PM: EC GPE dispatched
[  136.623071] PM: EC GPE dispatched
[  136.623268] PM: EC GPE dispatched
[  136.623381] PM: EC GPE dispatched
[  136.623537] PM: EC GPE dispatched
[  136.624161] PM: EC GPE dispatched
[  136.624358] PM: EC GPE dispatched
[  136.624467] PM: EC GPE dispatched
[  136.624635] PM: EC GPE dispatched
[  136.625248] PM: EC GPE dispatched
[  136.625445] PM: EC GPE dispatched
[  136.625560] PM: EC GPE dispatched
[  136.625716] PM: EC GPE dispatched
[  136.626331] PM: EC GPE dispatched
[  136.626529] PM: EC GPE dispatched
[  136.626632] PM: EC GPE dispatched
[  136.626799] PM: EC GPE dispatched
[  136.627417] PM: EC GPE dispatched
[  136.627619] PM: EC GPE dispatched
[  136.627965] PM: EC GPE dispatched
[  136.654372] PM: EC GPE dispatched
[  136.704195] PM: EC GPE dispatched
[  136.704387] PM: EC GPE dispatched
[  136.704491] PM: EC GPE dispatched
[  136.704659] PM: EC GPE dispatched
[  136.705073] PM: EC GPE dispatched
[  136.705264] PM: EC GPE dispatched
[  136.705373] PM: EC GPE dispatched
[  136.705957] PM: EC GPE dispatched
[  136.706142] PM: EC GPE dispatched
[  136.706245] PM: EC GPE dispatched
[  136.706834] PM: EC GPE dispatched
[  136.707025] PM: EC GPE dispatched
[  136.707126] PM: EC GPE dispatched
[  136.707297] PM: EC GPE dispatched
[  136.707715] PM: EC GPE dispatched
[  136.707906] PM: EC GPE dispatched
[  136.708007] PM: EC GPE dispatched
[  136.708183] PM: EC GPE dispatched
[  136.708596] PM: EC GPE dispatched
[  136.708782] PM: EC GPE dispatched
[  136.708879] PM: EC GPE dispatched
[  136.709055] PM: EC GPE dispatched
[  136.709472] PM: EC GPE dispatched
[  136.709669] PM: EC GPE dispatched
[  136.709770] PM: EC GPE dispatched
[  136.709937] PM: EC GPE dispatched
[  136.710354] PM: EC GPE dispatched
[  136.710544] PM: EC GPE dispatched
[  136.710639] PM: EC GPE dispatched
[  136.710747] PM: EC GPE dispatched
[  136.711333] PM: EC GPE dispatched
[  136.711518] PM: EC GPE dispatched
[  136.711620] PM: EC GPE dispatched
[  136.711792] PM: EC GPE dispatched
[  136.712208] PM: EC GPE dispatched
[  136.712400] PM: EC GPE dispatched
[  136.712503] PM: EC GPE dispatched
[  136.712673] PM: EC GPE dispatched
[  136.713090] PM: EC GPE dispatched
[  136.713278] PM: EC GPE dispatched
[  136.713380] PM: EC GPE dispatched
[  136.713495] PM: EC GPE dispatched
[  136.713971] PM: EC GPE dispatched
[  136.714163] PM: EC GPE dispatched
[  136.714265] PM: EC GPE dispatched
[  136.714367] PM: EC GPE dispatched
[  136.714945] PM: EC GPE dispatched
[  136.715137] PM: EC GPE dispatched
[  136.715239] PM: EC GPE dispatched
[  136.715824] PM: EC GPE dispatched
[  136.716016] PM: EC GPE dispatched
[  136.716118] PM: EC GPE dispatched
[  136.716232] PM: EC GPE dispatched
[  136.716709] PM: EC GPE dispatched
[  136.716894] PM: EC GPE dispatched
[  136.716996] PM: EC GPE dispatched
[  136.717170] PM: EC GPE dispatched
[  136.717585] PM: EC GPE dispatched
[  136.717779] PM: EC GPE dispatched
[  136.717882] PM: EC GPE dispatched
[  136.718047] PM: EC GPE dispatched
[  136.718468] PM: EC GPE dispatched
[  136.718661] PM: EC GPE dispatched
[  136.718757] PM: EC GPE dispatched
[  136.718927] PM: EC GPE dispatched
[  136.719345] PM: EC GPE dispatched
[  136.719536] PM: EC GPE dispatched
[  136.719631] PM: EC GPE dispatched
[  136.719809] PM: EC GPE dispatched
[  136.720224] PM: EC GPE dispatched
[  136.720416] PM: EC GPE dispatched
[  136.720516] PM: EC GPE dispatched
[  136.720687] PM: EC GPE dispatched
[  136.721104] PM: EC GPE dispatched
[  136.721296] PM: EC GPE dispatched
[  136.721397] PM: EC GPE dispatched
[  136.721567] PM: EC GPE dispatched
[  136.721984] PM: EC GPE dispatched
[  136.722177] PM: EC GPE dispatched
[  136.722271] PM: EC GPE dispatched
[  136.722446] PM: EC GPE dispatched
[  136.722864] PM: EC GPE dispatched
[  136.723055] PM: EC GPE dispatched
[  136.723167] PM: EC GPE dispatched
[  136.723336] PM: EC GPE dispatched
[  136.723746] PM: EC GPE dispatched
[  136.723933] PM: EC GPE dispatched
[  136.724036] PM: EC GPE dispatched
[  136.724147] PM: EC GPE dispatched
[  136.724628] PM: EC GPE dispatched
[  136.724812] PM: EC GPE dispatched
[  136.724914] PM: EC GPE dispatched
[  136.725029] PM: EC GPE dispatched
[  136.725503] PM: EC GPE dispatched
[  136.725699] PM: EC GPE dispatched
[  136.725801] PM: EC GPE dispatched
[  136.725902] PM: resume from suspend-to-idle
[  136.825764] ACPI: EC: interrupt unblocked
[  136.863069] PM: noirq resume of devices complete after 37.458 msecs
[  136.885386] PM: early resume of devices complete after 1.407 msecs
[  136.897887] iwlwifi 0000:02:00.0: Applying debug destination EXTERNAL_DRAM
[  137.032252] iwlwifi 0000:02:00.0: Applying debug destination EXTERNAL_DRAM
[  137.099029] iwlwifi 0000:02:00.0: FW already configured (0) - re-configuring
[  137.183044] PM: resume of devices complete after 297.668 msecs
[  137.183448] PM: Finishing wakeup.
[  137.183449] OOM killer enabled.
[  137.183449] Restarting tasks ... done.
[  137.185038] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops 0xffffffff820c5cb0)
[  137.881516] psmouse serio1: synaptics: queried max coordinates: x [..5666], y [..4734]
[  137.912437] psmouse serio1: synaptics: queried min coordinates: x [1276..], y [1118..]
[  137.979765] PM: suspend exit
[  140.877392] wlan0: authenticate with 04:f0:21:24:20:54
[  140.879733] wlan0: send auth to 04:f0:21:24:20:54 (try 1/3)
[  140.885460] wlan0: authenticated
[  140.886466] wlan0: associate with 04:f0:21:24:20:54 (try 1/3)
[  140.887785] wlan0: RX AssocResp from 04:f0:21:24:20:54 (capab=0x11 status=0 aid=2)
[  140.890160] wlan0: associated
[  141.324177] ACPI: \_PR_.PR00: Found 3 idle states
[  141.324877] ACPI: \_PR_.PR00: Found 3 idle states
[  141.325688] ACPI: \_PR_.PR01: Found 3 idle states
[  141.326398] ACPI: \_PR_.PR02: Found 3 idle states
[  141.327066] ACPI: \_PR_.PR03: Found 3 idle states
[  141.327747] ACPI: \_PR_.PR04: Found 3 idle states
[  141.328426] ACPI: \_PR_.PR05: Found 3 idle states
[  141.329098] ACPI: \_PR_.PR06: Found 3 idle states
[  141.329780] ACPI: \_PR_.PR07: Found 3 idle states
Comment 8 Rafael J. Wysocki 2020-03-16 09:16:47 UTC
Thanks!  It is better to add the logs as attachments instead of pasting them in, though, because it gets hard to browse the bug entry when there are too many of them in-line.

Please also enable dynamic debug in device_pm.c:

# echo 'file device_pm.c +p' > /sys/kernel/debug/dynamic_debug/control

in addition to what was requested in comment #6, run a suspend-resume cycle and attach the output of dmesg.
Comment 9 Rafael J. Wysocki 2020-03-16 09:17:39 UTC
In addition, please run

grep -r '.*' /sys/bus/pci/devices/*/power/wakeup

and let me know the result.
Comment 10 Ondřej Caletka 2020-03-16 11:14:38 UTC
Created attachment 287949 [details]
Dmesg suspend-wakeup cycle with device_pm.c debug on
Comment 11 Ondřej Caletka 2020-03-16 11:17:06 UTC
(In reply to Rafael J. Wysocki from comment #9)
> In addition, please run
> 
> grep -r '.*' /sys/bus/pci/devices/*/power/wakeup
> 
> and let me know the result.

# grep -r '.*' /sys/bus/pci/devices/*/power/wakeup
/sys/bus/pci/devices/0000:00:1c.0/power/wakeup:enabled
/sys/bus/pci/devices/0000:00:1c.2/power/wakeup:enabled
/sys/bus/pci/devices/0000:00:1c.4/power/wakeup:disabled
/sys/bus/pci/devices/0000:00:1d.0/power/wakeup:enabled
/sys/bus/pci/devices/0000:00:1f.3/power/wakeup:disabled
/sys/bus/pci/devices/0000:00:14.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:00:16.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:01:00.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:02:00.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:03:00.0/power/wakeup:enabled
/sys/bus/pci/devices/0000:04:00.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:04:01.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:04:02.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:04:04.0/power/wakeup:disabled
/sys/bus/pci/devices/0000:39:00.0/power/wakeup:enabled
/sys/bus/pci/devices/0000:6e:00.0/power/wakeup:disabled

You may also need output from lspci:

# lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 08)
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)
00:04.0 Signal processing controller: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem (rev 08)
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21)
00:15.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #0 (rev 21)
00:15.1 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #1 (rev 21)
00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI #1 (rev 21)
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #1 (rev f1)
00:1c.2 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #3 (rev f1)
00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #5 (rev f1)
00:1d.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #9 (rev f1)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point LPC Controller/eSPI Controller (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
01:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader (rev 01)
02:00.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)
03:00.0 PCI bridge: Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] (rev 02)
04:00.0 PCI bridge: Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] (rev 02)
04:01.0 PCI bridge: Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] (rev 02)
04:02.0 PCI bridge: Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] (rev 02)
04:04.0 PCI bridge: Intel Corporation JHL6540 Thunderbolt 3 Bridge (C step) [Alpine Ridge 4C 2016] (rev 02)
39:00.0 USB controller: Intel Corporation JHL6540 Thunderbolt 3 USB Controller (C step) [Alpine Ridge 4C 2016] (rev 02)
6e:00.0 Non-Volatile memory controller: Toshiba Corporation Device 0116
Comment 12 Rafael J. Wysocki 2020-03-16 17:17:48 UTC
Please run

# echo disabled > /sys/bus/pci/devices/0000:00:1d.0/power/wakeup
# echo disabled > /sys/bus/pci/devices/0000:03:00.0/power/wakeup

suspend the system after that and see if it still resumes on USB/charger disconnect/connect.
Comment 13 Ondřej Caletka 2020-03-16 18:27:55 UTC
I did, no change. I've actually disabled all of them, still no change. I even went further and switched all the wakeup sources to disabled:

# find /sys/devices/ -name 'wakeup' -type f | xargs grep 'enabled'
<nothing>

But the laptop acts exactly the same.
Comment 14 Rafael J. Wysocki 2020-03-18 09:57:53 UTC
Created attachment 287967 [details]
Wakeup debug patch

That's kind of unusual.  It looks like the EC itself causes the system to resume and those wakeups were discarded previously.

Please retest with the attached debug patch applied (and the debug facilities from the previous comments enabled).
Comment 15 Ondřej Caletka 2020-03-18 15:59:24 UTC
Created attachment 287971 [details]
Dmesg suspend-wakeup cycle with debug patch
Comment 16 Rafael J. Wysocki 2020-03-18 22:10:04 UTC
No trace of the EC wakeup activity in the log.

Please run

$ grep -r '.*' /sys/firmware/acpi/interrupts/ | grep -v invalid

suspend the system, wake it up by plugging in/unplugging a USB device or the charger, run the above again and post the output of both runs.

The patch from comment #15 is not needed any more.
Comment 17 Ondřej Caletka 2020-03-19 08:21:24 UTC
Before suspend:

# grep -r '.*' /sys/firmware/acpi/interrupts/ | grep -v invalid
/sys/firmware/acpi/interrupts/ff_pwr_btn:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/ff_rt_clk:       1         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe66:      14  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/error:       0
/sys/firmware/acpi/interrupts/sci:   19749
/sys/firmware/acpi/interrupts/gpe6E:   19744  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe62:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe42:       1  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe69:       0         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe00:       0         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe_all:   19759
/sys/firmware/acpi/interrupts/gpe09:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/ff_gbl_lock:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/sci_not:      56
/sys/firmware/acpi/interrupts/gpe6F:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe6D:       0         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe61:       0  EN     enabled      unmasked

After wakeup by USB cable unplug:
 
# grep -r '.*' /sys/firmware/acpi/interrupts/ | grep -v invalid
/sys/firmware/acpi/interrupts/ff_pwr_btn:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/ff_rt_clk:       1         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe66:      27  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/error:       0
/sys/firmware/acpi/interrupts/sci:   30470
/sys/firmware/acpi/interrupts/gpe6E:   30623  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe62:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe42:       1  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe69:       0         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe00:       0         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe_all:   30651
/sys/firmware/acpi/interrupts/gpe09:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/ff_gbl_lock:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/sci_not:     158
/sys/firmware/acpi/interrupts/gpe6F:       0  EN     enabled      unmasked
/sys/firmware/acpi/interrupts/gpe6D:       0         disabled     unmasked
/sys/firmware/acpi/interrupts/gpe61:       0  EN     enabled      unmasked
Comment 18 Rafael J. Wysocki 2020-03-19 08:50:34 UTC
Please attach the output of acpidump from this system.
Comment 19 Ondřej Caletka 2020-03-19 11:15:11 UTC
Created attachment 287977 [details]
acpidump od XPS 13 9370

On stderr, acpidump complains:

Wrong checksum for FADT!
Comment 20 Rafael J. Wysocki 2020-03-20 13:23:00 UTC
Does the problem go away with the ec_no_wakeup acpi module attribute set to 1?

That is

# echo 1 > /sys/module/acpi/parameters/ec_no_wakeup
Comment 21 Ondřej Caletka 2020-03-20 13:37:54 UTC
(In reply to Rafael J. Wysocki from comment #20)
> Does the problem go away with the ec_no_wakeup acpi module attribute set to
> 1?
> 
> That is
> 
> # echo 1 > /sys/module/acpi/parameters/ec_no_wakeup

Yes! Now it works exactly like before 5.5.4.

Thank you!
Comment 22 Rafael J. Wysocki 2020-03-20 13:40:13 UTC
That is good to know, but I still would like to understand why the commit in question matters here if you don't mind.
Comment 23 Rafael J. Wysocki 2020-03-20 13:43:20 UTC
Created attachment 287985 [details]
Debug patch for __acpi_ec_flush_work()

Please apply this debug patch and see if it makes any difference (without setting the ec_no_wakeup parameter).
Comment 24 Ondřej Caletka 2020-03-20 13:52:19 UTC
Applied, no difference – USB disconnect still wakes the laptop up.
Comment 25 Rafael J. Wysocki 2020-03-20 13:58:35 UTC
Thanks!  That's puzzling, because that patch basically reverses the only substantial change made by the commit in question. :-)
Comment 26 Rafael J. Wysocki 2020-03-21 11:20:53 UTC
Created attachment 287993 [details]
acpi_s2idle_wake() debug patch

Another patch to test.

Please suspend the system with this one applied (and without ec_no_wakeup), plug/unplug a USB device or the charger to trigger a wakeup and attach the output of dmesg generated after system resume.
Comment 27 Ondřej Caletka 2020-03-21 13:40:07 UTC
Created attachment 287995 [details]
Dmesg suspend-wakeup cycle with wake loop patch
Comment 28 Ondřej Caletka 2020-03-21 13:43:07 UTC
Patch applied but as I see the "wakeup after sync" never happens.

On a side note, I have a feeling that the laptop sleeping with ec_no_wakeup parameter dries battery very quicky – I put in on sleep in the evening with about 55 percent battery and woke up in the morning with drained battery. But I will have to investigate more on that.
Comment 29 Rafael J. Wysocki 2020-03-23 15:18:39 UTC
Created attachment 288019 [details]
ACPI: PM: s2idle: Refine the active GPEs check in acpi_s2idle_wake()

Another patch to test, but note that I haven't had a chance to even test-compile it so far, so it may not build.

The idea is to exclude the EC GPE from the "all GPEs" check, so that the EC GPE will always be ignored unless the processing of it causes any genuine wakeup events to show up.

If you are brave enough, please apply it, run a suspend-resume cycle with a wakeup triggered by USB (or charger) plug/unplug and attach the output of dmesg generated after that.
Comment 30 Ondřej Caletka 2020-03-23 21:22:13 UTC
It indeed does not build for me:

drivers/acpi/ec.c: In function ‘acpi_ec_other_gpes_active’:
drivers/acpi/ec.c:2044:9: error: too many arguments to function ‘acpi_any_gpe_status_set’
 2044 |  return acpi_any_gpe_status_set(NULL, skip_gpe);
      |         ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/acpi/acpi.h:31,
                 from ./include/linux/acpi.h:22,
                 from drivers/acpi/ec.c:29:
./include/acpi/acpixf.h:755:37: note: declared here
  755 | ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_gpe_status_set(void))
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~
./include/acpi/acpixf.h:76:2: note: in definition of macro ‘ACPI_EXTERNAL_RETURN_UINT32’
   76 |  prototype;
      |  ^~~~~~~~~
./include/acpi/acpixf.h:755:1: note: in expansion of macro ‘ACPI_HW_DEPENDENT_RETURN_UINT32’
  755 | ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_gpe_status_set(void))
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've tried to fix the declaration in include/acpi/acpixf.h, but then it failed on:

drivers/acpi/acpica/hwgpe.c: In function ‘acpi_hw_check_all_gpes’:
drivers/acpi/acpica/hwgpe.c:604:30: error: passing argument 1 of ‘acpi_ev_walk_gpe_list’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  604 |  (void)acpi_ev_walk_gpe_list(acpi_hw_get_gpe_block_status, &context);
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              |
      |                              acpi_status (*)(struct acpi_gpe_xrupt_info *, struct acpi_gpe_block_info *, struct acpi_gpe_block_status_context *) {aka unsigned int (*)(struct acpi_gpe_xrupt_info *, struct acpi_gpe_block_info *, struct acpi_gpe_block_status_context *)}
In file included from drivers/acpi/acpica/hwgpe.c:12:
drivers/acpi/acpica/acevents.h:133:41: note: expected ‘acpi_gpe_callback’ {aka ‘unsigned int (*)(struct acpi_gpe_xrupt_info *, struct acpi_gpe_block_info *, void *)’} but argument is of type ‘acpi_status (*)(struct acpi_gpe_xrupt_info *, struct acpi_gpe_block_info *, struct acpi_gpe_block_status_context *)’ {aka ‘unsigned int (*)(struct acpi_gpe_xrupt_info *, struct acpi_gpe_block_info *, struct acpi_gpe_block_status_context *)’}
  133 | acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context);
      |                       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

I've given up any attempts to fix it more.
Comment 31 Rafael J. Wysocki 2020-03-24 13:20:18 UTC
Created attachment 288031 [details]
v2: ACPI: PM: s2idle: Refine the active GPEs check in acpi_s2idle_wake()

A new version of the last debug patch, built and tested locally.

Please apply and test as requested.
Comment 32 Ondřej Caletka 2020-03-24 15:33:49 UTC
Created attachment 288033 [details]
Dmesg with refine active GPE check patch

So after applying this patch, the system does not wake up to USB unplug anymore.
Comment 33 Rafael J. Wysocki 2020-03-24 15:49:35 UTC
Great and thanks for your patience!

I'll post patches based on the one from comment #31 to address this issue.
Comment 34 Ondřej Caletka 2020-03-24 16:19:02 UTC
Thank You!
Comment 35 Rafael J. Wysocki 2020-03-24 18:35:10 UTC
The git branch at

 git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
 acpi-s2idle-fixup

should be equivalent to 5.6-rc7 with the patch from comment #31 applied, so please test this one if you can for confirmation.
Comment 36 Ondřej Caletka 2020-03-25 07:37:58 UTC
Tested successfully. The only thing that bothers me a little bit is a big ammount of these lines in dmesg even when all run time debugging is turned off:

acpi_s2idle_wake: EC GPE inactive
acpi_hw_get_gpe_block_status: skipping 0x40 from 0x40
Comment 37 Rafael J. Wysocki 2020-03-25 10:43:48 UTC
(In reply to Ondřej Caletka from comment #36)
> Tested successfully.

Awesome, thanks!

> The only thing that bothers me a little bit is a big
> ammount of these lines in dmesg even when all run time debugging is turned
> off:
> 
> acpi_s2idle_wake: EC GPE inactive
> acpi_hw_get_gpe_block_status: skipping 0x40 from 0x40

Those come from the top-most debug commit that is not going in, so no worries.
Comment 38 Rafael J. Wysocki 2020-03-25 11:12:34 UTC
Patches submitted as:

https://patchwork.kernel.org/patch/11457493/
https://patchwork.kernel.org/patch/11457485/
Comment 39 Blaz P. 2020-04-26 09:21:13 UTC
Hi.

In kernels prior to 5.6.4 computer would freeze (needs to be shutdown with power key) after wakeup from suspend.
Kernel release 5.6.4 cointains this two commits which fixes the issue

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.6.4&id=fe02c4d27cdbf06e2582b62d3c0708cf3575f923

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.6.4&id=4c0bc69e3a486f41430b717034e74cfd97c49d68

In 5.6.5 problem appears again and I suspect these two commits
https://patchwork.kernel.org/patch/11457493/
https://patchwork.kernel.org/patch/11457485/

Is it possible that any of these two commits broke "ACPI: PM: Add acpi_[un]register_wakeup_handler()" fix?

Note You need to log in before you can comment on or make changes to this bug.