t2linux / T2-Debian-and-Ubuntu-Kernel

Ubuntu Kernel for T2 Macs.
148 stars 16 forks source link

s2idle sleep mode does not work and prevent computer to completely shutdown #99

Open ydzhou opened 1 year ago

ydzhou commented 1 year ago

Hi

When I use s2idle sleep mode, I run into an issue with my usb controller and I think those errors prevent my computer to completely shutdown or to sleep again

And here is the message during shutdown, then my computer stuck there.

Reached target Power-Off
xhci_hcd 0000:08:00.0 host halt failed, -19

lsusb output

Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 0930:6544 Toshiba Corp. TransMemory-Mini / Kingston DataTraveler 2.0 Stick
Bus 001 Device 006: ID 05ac:8511 Apple, Inc. FaceTime HD Camera (Built-in)
Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

0000:08:00.0 is managing Bus 003 and 004

ydzhou commented 1 year ago

dmesg for suspend/resume

[  338.400900] xhci_hcd 0000:08:00.0: Controller not ready at resume -19
[  338.400963] xhci_hcd 0000:08:00.0: PCI post-resume error -19!
[  338.400978] xhci_hcd 0000:08:00.0: HC died; cleaning up
[  338.400989] xhci_hcd 0000:08:00.0: PM: dpm_run_callback(): pci_pm_resume+0x0/0xf0 returns -19
[  338.400994] xhci_hcd 0000:08:00.0: PM: failed to resume: error -19
AdityaGarg8 commented 1 year ago

Cc @Redecorating

Redecorating commented 1 year ago

what mac model is this? has it ever worked in the past (if so, do you know when or what kernel versions)? can you reproduce the issue on the official, not-t2, ubuntu kernel?

Redecorating commented 1 year ago

also, is normal, not s2idle suspend fine? or maybe if you don't load the xhci_hcd or don't plug in any usb devices, see if it works then?

ydzhou commented 1 year ago

The mac is 2019 Macbook Air. This is my first time to try t2linux, so it never work in the past. Yes, I can reproduce in non t2 ubuntu kernel. Yes, I also tried to not plugin any usb thing, still running into the this issue. xhci_hcd is a built-in module. I cannot unload.... Yeah s2idle does not work, but deep mode suspend works.

BTW, are you able to reproduce s2idle issue on your side?

ydzhou commented 1 year ago

My kernel is 6.2 (latest t2linux ubuntu kernel)

Redecorating commented 1 year ago

The mac is 2019 Macbook Air.

This is my first time to try t2linux, so it never work in the past.

Yes, I can reproduce in non t2 ubuntu kernel.

you might be able to file an upstream bug with ubuntu then.

Yes, I also tried to not plugin any usb thing, still running into the this issue.

xhci_hcd is a built-in module. I cannot unload....

ah right

Yeah s2idle does not work, but deep mode suspend works.

BTW, are you able to reproduce s2idle issue on your side?

I haven't tested that, I'm not sure when I'll get time.

ydzhou commented 1 year ago

Can you do me a favor and try a simple test? I wanna verify if this is my device issue or this is upstream kernel bug...

echo 's2idle' > /sys/power/mem_sleep
systemctl suspend

Then wake up

dmesg | grep xhci
stereo4nick commented 4 months ago

Hi there! I have 2020 MBA updated to sonoma. Installed Ubuntu 6.9.8-3-t2-jammy and experienced issue with not working suspend/hibernate. I know about same issue on other distros like debian/Arch.

Recently find out it appeared new workaround based on service which shut down brcmfmac/apple-bce modules before suspend and start them after resume. I tried that with no luck (see https://github.com/t2linux/T2-Debian-and-Ubuntu-Kernel/issues/53#issuecomment-2221615015)

Is there exists some workaround for ubuntu or maybe the issue will be addressed in future? AdityaGarg8 said that he is not working for ubuntu.

ps. here is my last attempt to run deepSleep (https://github.com/t2linux/T2-Debian-and-Ubuntu-Kernel/issues/53#issuecomment-2170545969)

AdityaGarg8 commented 4 months ago

Hi there! I have 2020 MBA updated to sonoma. Installed Ubuntu 6.9.8-3-t2-jammy and experienced issue with not working suspend/hibernate. I know about same issue on other distros like debian/Arch.

Recently find out it appeared new workaround based on service which shut down brcmfmac/apple-bce modules before suspend and start them after resume. I tried that with no luck (see #53 (comment))

Is there exists some workaround for ubuntu or maybe the issue will be addressed in future? AdityaGarg8 said that he is not working for ubuntu.

ps. here is my last attempt to run deepSleep (#53 (comment))

I'm test compiling the Xanmod kernel. Let's see if it works there.

AdityaGarg8 commented 4 months ago

Good news. Suspend worked on Xanmod kernels with the workaround!

stereo4nick commented 4 months ago

Good news. Suspend worked on Xanmod kernels with the workaround!

AWESOME! Thanx! So excited to update)

AdityaGarg8 commented 4 months ago

Good news. Suspend worked on Xanmod kernels with the workaround!

I've released the Xanmod kernels, but suspend is still not that stable as it should be. You can now try them

stereo4nick commented 4 months ago

Good news. Suspend worked on Xanmod kernels with the workaround!

I've released the Xanmod kernels, but suspend is still not that stable as it should be. You can now try them

AdityaGarg8 thank you! Updated my ubuntu to 6.9.8-4 but got same behavior - system looks like going to sleep but unable to wakeup. I'll try to check my sleepmode later. Also I'm doubt about current suspend-fix-t2.service because with original ExecStart/ExecStop I got error after hit cmd sudo systemctl enable suspend-fix-t2.service Can you please share your workaround fix service?

AdityaGarg8 commented 4 months ago

Good news. Suspend worked on Xanmod kernels with the workaround!

I've released the Xanmod kernels, but suspend is still not that stable as it should be. You can now try them

AdityaGarg8 thank you! Updated my ubuntu to 6.9.8-4 but got same behavior - system looks like going to sleep but unable to wakeup. I'll try to check my sleepmode later. Also I'm doubt about current suspend-fix-t2.service because with original ExecStart/ExecStop I got error after hit cmd sudo systemctl enable suspend-fix-t2.service Can you please share your workaround fix service?

I've been following this:

https://wiki.t2linux.org/guides/postinstall/#suspend-workaround

And yes, I am also often encountering the same issue you told. I'm trying tweaking the kernel config a bit to make it more stable.

AdityaGarg8 commented 4 months ago

Also make sure you install xanmod

sudo apt update
sudo apt install linux-t2-xanmod
AdityaGarg8 commented 4 months ago

The service won't work on normal kernels.

stereo4nick commented 4 months ago

got it, thanx I thought you swaped kernel in t2 tag

stereo4nick commented 4 months ago

Also make sure you install xanmod

sudo apt update
sudo apt install linux-t2-xanmod

Installed xanmod and checked suspending. System now suspending and resuming correctly with the workaround but I experienced with not worked touchpad and keyboard. Even after enabling fix-service keyboard and touchpad stop to work, noticed that backlit opposite start to work)

stereo4nick commented 3 months ago

Hi @AdityaGarg8 Few days ago updated my ubuntu with xanmod and did some researches.

  1. Here is uname of my MBA2020: Linux mba 6.10.2-x64v3-t2-jammy-xanmod1 #xanmod1 SMP PREEMPT_DYNAMIC Mon Jul 29 02:07:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

  2. Keyboard backlit always stop to work after reloading apple-bce. Here is journalctl after run sudo service start suspend-fix-t2.service backlit.off.log

  3. From time to time the workaround is working, but sometimes is not. I noticed that it's always fail on resume if suspend-fix-t2.service just enabled. But if I run service with cmd from previous (from 1 in above) before suspend then KBD/WiFi will work after resume. Here is logs. suspend.fail.log suspend.ok.log suspend.ok.with.lid.log

All test was with uncommented rows with brcmfmac_wcc and brcmfmac in /etc/systemd/system/suspend-fix-t2.service

Should I create new issue in github.com/t2linux/T2-Ubuntu ?

AdityaGarg8 commented 3 months ago

Hi @AdityaGarg8 Few days ago updated my ubuntu with xanmod and did some researches.

  1. Here is uname of my MBA2020: Linux mba 6.10.2-x64v3-t2-jammy-xanmod1 #xanmod1 SMP PREEMPT_DYNAMIC Mon Jul 29 02:07:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
  2. Keyboard backlit always stop to work after reloading apple-bce. Here is journalctl after run sudo service start suspend-fix-t2.service backlit.off.log
  3. From time to time the workaround is working, but sometimes is not. I noticed that it's always fail on resume if suspend-fix-t2.service just enabled. But if I run service with cmd from previous Update build.sh #1 before suspend then KBD/WiFi will work after resume. Here is logs. suspend.fail.log suspend.ok.log suspend.ok.with.lid.log

All test was with uncommented rows with brcmfmac_wcc and brcmfmac in /etc/systemd/system/suspend-fix-t2.service

Should I create new issue in github.com/t2linux/T2-Ubuntu ?

Someone got suspend working by adding acpi_osi=!Darwin to the kernel parameters and removed this script.

stereo4nick commented 3 months ago

Hi @AdityaGarg8 Few days ago updated my ubuntu with xanmod and did some researches.

  1. Here is uname of my MBA2020: Linux mba 6.10.2-x64v3-t2-jammy-xanmod1 #xanmod1 SMP PREEMPT_DYNAMIC Mon Jul 29 02:07:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
  2. Keyboard backlit always stop to work after reloading apple-bce. Here is journalctl after run sudo service start suspend-fix-t2.service backlit.off.log
  3. From time to time the workaround is working, but sometimes is not. I noticed that it's always fail on resume if suspend-fix-t2.service just enabled. But if I run service with cmd from previous Update build.sh #1 before suspend then KBD/WiFi will work after resume. Here is logs. suspend.fail.log suspend.ok.log suspend.ok.with.lid.log

All test was with uncommented rows with brcmfmac_wcc and brcmfmac in /etc/systemd/system/suspend-fix-t2.service Should I create new issue in github.com/t2linux/T2-Ubuntu ?

Someone got suspend working by adding acpi_osi=!Darwin to the kernel parameters and removed this script.

acpi_osi=!Darwin in grub?

AdityaGarg8 commented 3 months ago

Yes grub

stereo4nick commented 3 months ago

Yes grub

I just checked it.

GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi=!Darwin quiet splash" sudo update-grub reboot

also disabled suspend-fix-t2.service

aaaaand got system resume after few seconds noticed same error in log which I saw while testing the fail attempts with the workaround:

Jul 31 20:40:14 mba gnome-shell[1312]: JS ERROR: Failed to initialize fprintd service: Gio.IOErrorEnum: 
GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available
                                       asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:114:23
Jul 31 20:40:14 mba systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.

here is log: try.to.sleep.log

then changed kernel to Linux mba 6.6.43-1-t2-jammy and got same result log: try.to.sleep.t2.lts.log

I had some success when testing the patch and now i believe it can be made to work somehow really hate mocos

AdityaGarg8 commented 3 months ago

Yes grub

I just checked it.

GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi=!Darwin quiet splash" sudo update-grub reboot

also disabled suspend-fix-t2.service

aaaaand got system resume after few seconds noticed same error in log which I saw while testing the fail attempts with the workaround:

Jul 31 20:40:14 mba gnome-shell[1312]: JS ERROR: Failed to initialize fprintd service: Gio.IOErrorEnum: 
GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available
                                       asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:114:23
Jul 31 20:40:14 mba systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.

here is log: try.to.sleep.log

then changed kernel to Linux mba 6.6.43-1-t2-jammy and got same result log: try.to.sleep.t2.lts.log

I had some success when testing the patch and now i believe it can be made to work somehow really hate mocos

Nice to know you got it working. I'll fiddle with this when I get time.

stereo4nick commented 3 months ago

Yes grub

I just checked it. GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi=!Darwin quiet splash" sudo update-grub reboot also disabled suspend-fix-t2.service aaaaand got system resume after few seconds noticed same error in log which I saw while testing the fail attempts with the workaround:

Jul 31 20:40:14 mba gnome-shell[1312]: JS ERROR: Failed to initialize fprintd service: Gio.IOErrorEnum: 
GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available
                                       asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:114:23
Jul 31 20:40:14 mba systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.

here is log: try.to.sleep.log then changed kernel to Linux mba 6.6.43-1-t2-jammy and got same result log: try.to.sleep.t2.lts.log I had some success when testing the patch and now i believe it can be made to work somehow really hate mocos

Nice to know you got it working. I'll fiddle with this when I get time.

yep, just for clarity, it's barely working - only with xanmod + workaround, without backlit and resume is not stabil but it gave me hope thanks