Bug 476492

Summary: On Framework laptop, while lid is closed, system does not stay asleep if power cable is connected
Product: [Plasma] plasmashell Reporter: Jeremi Campagna <jeremi.campagna>
Component: Power management & brightnessAssignee: Plasma Bugs List <plasma-bugs>
Status: ASSIGNED ---    
Severity: normal CC: natalie_clarius, nate, nicolas.fella, postix
Priority: NOR    
Version: 6.2.4   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
URL: https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/31
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Jeremi Campagna 2023-11-03 00:07:01 UTC
SUMMARY
This issue might be specific to Framework laptops.
With lid close event set to hybrid sleep or sleep, the system will resume from sleep when AC power is connected during sleep, even while the lid is closed. The system will not go back to sleep. This is also an issue when it comes to charging with Framework laptops as the laptop will disconnect from AC power when hitting 100% and reconnect when the battery falls to around 98%. When this cycling happens, the system remains awake.


STEPS TO REPRODUCE
1. With a Framework Laptop 13 (AMD 7040 Series in my case), close the lid of the device and confirm it went to sleep
2. Connect the system to AC power
3. Listen for the charging chime or peek at the screen

OBSERVED RESULT
The system fails to go back to sleep and remains awake, even after 30 minutes while the AC-DC cycling occurs on full charge.

EXPECTED RESULT
The system should go back to sleep by itself after handling the DC to AC event.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11
Kernel Version: 6.5.9-arch2-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Memory: 30.5 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: Framework
Product Name: Laptop 13 (AMD Ryzen 7040Series)
System Version: A7

ADDITIONAL INFORMATION
The firmware behaviour of this laptop that can play a role in this issue has been confirmed intentional and expected behaviour by Framework : https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/31
Comment 1 Nate Graham 2023-11-03 21:28:29 UTC
If the firmware behavior is intentional on the part of the hardware, then I guess we'll need to handle these unusual conditions in our code. That's not ideal at all as it will then be broken for people not using Plasma. From that link, it looks like the system needs to wake up and then immediately go back to sleep again? Yuck. :)
Comment 2 Jeremi Campagna 2023-11-03 21:33:30 UTC
(In reply to Nate Graham from comment #1)
> If the firmware behavior is intentional on the part of the hardware, then I
> guess we'll need to handle these unusual conditions in our code. That's not
> ideal at all as it will then be broken for people not using Plasma. From
> that link, it looks like the system needs to wake up and then immediately go
> back to sleep again? Yuck. :)

Yes, I agree. There's further discussion and there could be something in the firmware that causes Linux systems to just wake up and stay awake. Though waking up the system when it gets on AC is intended behaviour. The AC-DC cycling is not to worry about, I haven't seen it happen again recently, must have been a singled out oddity.
Comment 3 Natalie Clarius 2023-11-15 21:01:02 UTC
Does the wakeup also happen when you set it to sleep while plugged and then unplug it?
Comment 4 Nicolas Fella 2023-11-15 21:04:31 UTC
I just learned that my (non-Framework) Laptop also does this when plugging *in* the AC, but not when unplugging
Comment 5 Jeremi Campagna 2023-11-15 21:19:45 UTC
(In reply to Natalie Clarius from comment #3)
> Does the wakeup also happen when you set it to sleep while plugged and then
> unplug it?

Yes. It happens more often that it wakes up when unplugging from AC. And then it fails to go back to sleep, more often than not.
I am having some odd sleep behaviours too. Sometimes, it will fail to sleep or hibernate when there has not been a change in AC-DC status.
Comment 6 Natalie Clarius 2023-11-15 21:21:48 UTC
(In reply to Jeremi Campagna from comment #5)

> more often than not

So sometimes it does go back to sleep? Immediately or after some period?
Comment 7 Jeremi Campagna 2023-11-15 22:58:39 UTC
(In reply to Natalie Clarius from comment #6)
> (In reply to Jeremi Campagna from comment #5)
> 
> > more often than not
> 
> So sometimes it does go back to sleep? Immediately or after some period?

If it does, it seems to be immediate. It's not exactly reliable.
Comment 8 Bug Janitor Service 2023-11-16 16:04:07 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/279