AsahiLinux / linux

Linux kernel source tree
Other
2.36k stars 91 forks source link

sleep mode battery improvement #262

Open eslerm opened 10 months ago

eslerm commented 10 months ago

Asahi draws ~2% battery life per hour of sleep on a M2 (https://github.com/AsahiLinux/asahi-installer/issues/252). On macOS, this power draw is nearly 0% per hour.

This is an important feature, since putting an Asahi device into sleep mode over night requires ~20% battery and doing so often will greatly shorten the lifespan of a battery.

popey commented 10 months ago

On my m1 air running latest Ubuntu Asahi I did a test. Previously I had noticed significant drain while lid closed in my bag.

Yesterday:

Today:

So it's a bit more thirsty than macOS for sure.

eslerm commented 10 months ago

I've noticed that if charge is at 100%, it will show no or little discharge during sleep for the first hour. I'm not sure why. If anyone is testing this, please run the test for multiple hours.

RossComputerGuy commented 5 months ago

I don't have exact numbers but sleep battery drain could definitely be improved on M1 Pro. I daily drive this system and it would be great to just put the system to sleep instead of shutting it down.

jmastr commented 3 months ago

Don't know if related but I noticed that user process only gets freezed when coming BACK from suspend. Please look at the timestamps. Suspending at 20:29:38, waited 50 minutes, coming back from suspend at 21:19:59:

...
Aug 23 20:29:38 apple-macbook-pro kernel: PM: suspend entry (s2idle)
Aug 23 20:29:38 apple-macbook-pro kernel: Filesystems sync: 0.007 seconds
Aug 23 21:19:59 apple-macbook-pro kernel: Freezing user space processes
Aug 23 21:19:59 apple-macbook-pro kernel: Freezing user space processes completed (elapsed 0.001 seconds)
Aug 23 21:19:59 apple-macbook-pro kernel: OOM killer disabled.
Aug 23 21:19:59 apple-macbook-pro kernel: Freezing remaining freezable tasks
Aug 23 21:19:59 apple-macbook-pro kernel: Freezing remaining freezable tasks completed (elapsed 0.000 seconds)
Aug 23 21:19:59 apple-macbook-pro kernel: printk: Suspending console(s) (use no_console_suspend to debug)
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: BrightnessLCD.cpp:803: [AFK]nitsToDBV: iDAC out of range
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:10490: set_run_mode_safe: deferring: 4 -> 1
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:10395: virtual IOMFBStatus IOMFB::UPPipeDCP_H13P::ready_for_run_mode_change(IOMFB::AppleRegisterStream *): initiating >
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: UPTSQManager.cpp:150: IOMFBStatus IOMFB::UPTSQManager::power_down_M3(IOMFB::AppleRegisterStream *, UPTSQManager::ModeChangeWaiter *): re>
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: UPTSQManager.cpp:162: IOMFBStatus IOMFB::UPTSQManager::power_down_M3(IOMFB::AppleRegisterStream *, UPTSQManager::ModeChangeWaiter *): di>
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: ck_PCC2DBlm_v5.cpp:3300: Quiescing callback
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:10468: set_run_mode_safe: no need to defer: 1 -> 0
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: eoInterfaceIOAV.cpp:433: IOMFB: VideoInterfaceIOAV::did_power_off: m_power_ctrl->setPower( 0 )
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: eoInterfaceIOAV.cpp:146: IOMFB: IOAVVideoInterface terminated
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: oInterfaceIOAV.cpp:1094: void VideoInterfaceIOAV::unplug_gated(IOAVVideoInterface *): display HPD removed
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: nifiedPipeline.cpp:1356: set_device_enabled_gated: current state: 1, requested state: 0
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: nifiedPipeline.cpp:1356: set_device_enabled_gated: current state: 0, requested state: 1
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:10468: set_run_mode_safe: no need to defer: 0 -> 1
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: ock_Tunables_v1.cpp:651: IOMFB: Writing tunables with target 1
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: ck_Config_H13P.cpp:1771: program_frame_size: pixel_clock 804560000, vid0 402280000, 00019247 000000a3
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: M3Hal_v1.cpp:197: IOMFB: load LED M3 IMem : size 0x7b88
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: M3Hal_v1.cpp:197: IOMFB: load LED M3 DMem : size 0x102e0
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: ock_PCC2DLTM_v4.cpp:324: IOMFBStatus IOMFB::UPBlock_PCC2DLTM_v4::set_mcpu_power(IOMFB::AppleRegisterStream *, bool) Loading M3 Hal
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: M3Hal_v1.cpp:197: IOMFB: load LTM M3 IMem : size 0x73b4
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: M3Hal_v1.cpp:197: IOMFB: load LTM M3 DMem : size 0xd194
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: ck_PCC2DBlm_v5.cpp:4938: [set_lts_buffer] buffer 0x1f001690000 Add_lo = 0x1690000, Add_hi = 0x1f0, size 0x2500 stride 0x100
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:10468: set_run_mode_safe: no need to defer: 1 -> 2
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: eoInterfaceIOAV.cpp:237: bool VideoInterfaceIOAV::open_ioav_gated(): IOAVVideoInterface open failed
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: eoInterfaceIOAV.cpp:296: IOMFB: VideoInterfaceIOAV::power_on: m_power_ctrl->setPower( 1 )
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: AppleDCPDPTX.cpp:355: [AFK]powering nub 0x863f88
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: AppleDCPDPTX.cpp:355: [AFK]powering nub 0x864108
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:10468: set_run_mode_safe: no need to defer: 2 -> 1
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:10468: set_run_mode_safe: no need to defer: 1 -> 0
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: eoInterfaceIOAV.cpp:433: IOMFB: VideoInterfaceIOAV::did_power_off: m_power_ctrl->setPower( 0 )
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: RTKit: syslog message: nifiedPipeline.cpp:1356: set_device_enabled_gated: current state: 1, requested state: 0
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 38bc00000.dcp: dcp_poweroff() done
Aug 23 21:19:59 apple-macbook-pro kernel: apple-dcp 289c00000.dcp: dcp_dptx_disconnect(port=0)
Aug 23 21:19:59 apple-macbook-pro kernel: nvme-apple 393cc0000.nvme: RTKit: syslog message: cmd.c:8084: NVMe shutdown start seg->lba: 0, seg->size: 0
Aug 23 21:19:59 apple-macbook-pro kernel: nvme-apple 393cc0000.nvme: RTKit: syslog message: cmd.c:8112: seg->lba 0 saveCtx 1 took 119 ms - clog 4288565
...
jacksongoode commented 3 months ago

Don't know if related but I noticed that user process only gets freezed when coming BACK from suspend.

Huh wouldn't be surprised if that's one root cause?

flightmansam commented 4 weeks ago

Is anyone working on this at the moment? I would be happy to contribute to bounty to get this done.

ethanuppal commented 3 days ago

Any updates?

flightmansam commented 4 hours ago

I would still be more than happy to help fund development of this feature or help out in any other way possible.

sioodmy commented 56 minutes ago

I would still be more than happy to help fund development of this feature or help out in any other way possible.

can relate

it makes me wanna switch back to macos for a while