You are not logged in.

#1 2015-07-18 14:52:26

chookies
Member
Registered: 2015-07-17
Posts: 5

[MacbookPro 2013] Lid open/close not detected (sometimes)

I've installed Arch Linux on a late 2013 MacbookPro Retina 13" with almost no hassle. I'm running a relatively lightweight setup with Xmonad, so suspend on lid close is not configured through a desktop environment like Gnome. I installed acpid to achieve this, but then I noticed it suspended only the first few times after a cold boot (the screen remained on after that). So I ran `acpi_listen` and `journalctl -f` while closing and opening the lid and it seemed the system is not even detecting a lid close. When suspend on lid close did work, it was indeed logged by both acpi and journal.

Looking at the Arch forums, it seems that more people have issues with suspend on lid close, but I wasn't able to solve the problem with the solutions given.

I did disable xhc in /proc/acpi/wakeup like the Macbook wiki page said, here's the output:

Device	S-state	  Status   Sysfs node
P0P2	  S3	*disabled
EC	  S4	*disabled  platform:PNP0C09:00
HDEF	  S3	*disabled  pci:0000:00:1b.0
RP01	  S3	*disabled  pci:0000:00:1c.0
RP02	  S3	*disabled  pci:0000:00:1c.1
RP03	  S3	*disabled  pci:0000:00:1c.2
ARPT	  S4	*disabled  pci:0000:03:00.0
RP05	  S3	*disabled  pci:0000:00:1c.4
RP06	  S3	*disabled  pci:0000:00:1c.5
XHC1	  S3	*disabled  pci:0000:00:14.0
ADP1	  S4	*disabled  platform:ACPI0003:00
LID0	  S4	*enabled   platform:PNP0C0D:00

Here's the lid close hook in /etc/acpi/handler.sh:

#!/bin/bash
# Default acpi script that takes an entry for all actions

case "$1" in
    button/power)
        case "$2" in
            PBTN|PWRF)
                logger 'PowerButton pressed'
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB|SBTN)
                logger 'SleepButton pressed'
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        logger 'AC unpluged'
                        ;;
                    00000001)
                        logger 'AC pluged'
                        ;;
                esac
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)
                        logger 'Battery online'
                        ;;
                    00000001)
                        logger 'Battery offline'
                        ;;
                esac
                ;;
            CPU0)
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        case "$3" in
            close)
                logger 'LID closed'
		systemctl suspend
                ;;
            open)
                logger 'LID opened'
                ;;
            *)
                logger "ACPI action undefined: $3"
                ;;
    esac
    ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esac

# vim:set ts=4 sw=4 ft=sh et:

And here's my lsmod if it helps.

Module                  Size  Used by
btusb                  45056  0
btbcm                  16384  1 btusb
btintel                16384  1 btusb
bluetooth             458752  4 btbcm,btusb,btintel
hid_generic            16384  0
snd_hda_codec_hdmi     53248  1
joydev                 20480  0
mousedev               20480  0
hid_apple              16384  0
usbhid                 49152  0
hid                   110592  3 hid_generic,usbhid,hid_apple
bcm5974                20480  0
nvram                  16384  0
msr                    16384  0
intel_rapl             20480  0
wl                   6303744  0
iosf_mbi               16384  1 intel_rapl
x86_pkg_temp_thermal    16384  0
intel_powerclamp       16384  0
coretemp               16384  0
kvm_intel             155648  0
kvm                   442368  1 kvm_intel
iTCO_wdt               16384  0
iTCO_vendor_support    16384  1 iTCO_wdt
mac_hid                16384  0
evdev                  24576  23
crct10dif_pclmul       16384  0
crc32_pclmul           16384  0
crc32c_intel           24576  0
ghash_clmulni_intel    16384  0
snd_hda_codec_cirrus    20480  1
i915                 1044480  3
snd_hda_codec_generic    69632  1 snd_hda_codec_cirrus
drm_kms_helper        106496  1 i915
snd_hda_intel          28672  6
snd_hda_controller     28672  1 snd_hda_intel
aesni_intel           172032  0
snd_hda_codec          98304  5 snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_intel,snd_hda_controller,snd_hda_codec_cirrus
aes_x86_64             20480  1 aesni_intel
lrw                    16384  1 aesni_intel
gf128mul               16384  1 lrw
snd_hda_core           28672  4 snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_codec,snd_hda_controller
glue_helper            16384  1 aesni_intel
applesmc               20480  0
ablk_helper            16384  1 aesni_intel
led_class              16384  1 applesmc
snd_hwdep              16384  1 snd_hda_codec
input_polldev          16384  1 applesmc
cryptd                 20480  3 ghash_clmulni_intel,aesni_intel,ablk_helper
snd_pcm                90112  4 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel,snd_hda_controller
drm                   282624  4 i915,drm_kms_helper
cfg80211              483328  1 wl
thunderbolt            49152  0
snd_timer              28672  1 snd_pcm
snd                    69632  20 snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_hda_codec_generic,snd_hda_codec,snd_hda_intel,snd_hda_codec_cirrus
bdc_pci                16384  0
intel_gtt              20480  1 i915
rfkill                 24576  3 cfg80211,bluetooth
i2c_i801               20480  0
i2c_algo_bit           16384  1 i915
mei_me                 24576  0
pcspkr                 16384  0
mei                    77824  1 mei_me
i2c_core               49152  5 drm,i915,i2c_i801,drm_kms_helper,i2c_algo_bit
soundcore              16384  1 snd
lpc_ich                24576  0
shpchp                 36864  0
sbs                    16384  0
sbshc                  16384  1 sbs
video                  24576  1 i915
battery                20480  0
apple_bl               16384  0
ac                     16384  0
button                 16384  1 i915
processor              28672  0
sch_fq_codel           20480  2
ip_tables              28672  0
x_tables               28672  1 ip_tables
ext4                  516096  3
crc16                  16384  2 ext4,bluetooth
mbcache                20480  1 ext4
jbd2                   90112  1 ext4
sd_mod                 36864  4
uas                    24576  0
usb_storage            61440  1 uas
ahci                   36864  3
libahci                28672  1 ahci
libata                204800  2 ahci,libahci
scsi_mod              151552  4 uas,usb_storage,libata,sd_mod
xhci_pci               16384  0
xhci_hcd              155648  1 xhci_pci
usbcore               200704  7 uas,btusb,usb_storage,usbhid,bcm5974,xhci_hcd,xhci_pci
usb_common             16384  1 usbcore

Edit: here are the logs when lid close is detected (usually the first few times after boot)

journalctl -f

-- Logs begin at Mon 2015-03-30 21:03:43 CEST. --
Jul 18 17:38:02 who i3lock[6979]: pam_tally(i3lock:auth): Error opening /var/log/faillog for update
Jul 18 17:38:02 who i3lock[6979]: pam_tally(i3lock:auth): Error opening /var/log/faillog for read
Jul 18 17:38:04 who kernel: wl0: link up (wlp3s0)
Jul 18 17:38:06 who ntpd[6107]: new interface(s) found: waking up resolver
Jul 18 17:38:14 who systemd-logind[416]: Lid closed.
Jul 18 17:38:14 who root[7165]: LID closed
Jul 18 17:38:14 who systemd[1]: Starting i3lock...
Jul 18 17:38:14 who systemd[1]: Started i3lock.
Jul 18 17:38:14 who systemd[1]: Reached target Sleep.
Jul 18 17:38:14 who systemd[1]: Starting Sleep.
Jul 18 17:38:14 who systemd[1]: Starting Suspend...
Jul 18 17:38:14 who systemd-sleep[7170]: Suspending system...
Jul 18 17:38:18 who kernel: PM: Syncing filesystems ... done.
Jul 18 17:38:18 who kernel: PM: Preparing system for mem sleep
Jul 18 17:38:18 who kernel: Freezing user space processes ... (elapsed 0.001 seconds) done.
Jul 18 17:38:18 who kernel: Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
Jul 18 17:38:18 who kernel: PM: Entering mem sleep
Jul 18 17:38:18 who kernel: Suspending console(s) (use no_console_suspend to debug)
Jul 18 17:38:18 who kernel: sd 0:0:0:0: [sda] Synchronizing SCSI cache
Jul 18 17:38:18 who kernel: wl_suspend: PCI Suspend handler
Jul 18 17:38:18 who kernel: wl_suspend: Not WOWL capable
Jul 18 17:38:18 who kernel: wl0: link down (wlp3s0)
Jul 18 17:38:18 who kernel: cfg80211: Exceeded CRDA call max attempts. Not calling CRDA
Jul 18 17:38:18 who kernel: sd 0:0:0:0: [sda] Stopping disk
Jul 18 17:38:18 who kernel: PM: suspend of devices complete after 368.827 msecs
Jul 18 17:38:18 who kernel: PM: late suspend of devices complete after 20.006 msecs
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: suspending...
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: stopping RX ring 0
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: disabling interrupt at register 0x38200 bit 12 (0x1001 -> 0x1)
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: stopping TX ring 0
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: disabling interrupt at register 0x38200 bit 0 (0x1 -> 0x0)
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: control channel stopped
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: suspend finished
Jul 18 17:38:18 who kernel: PM: noirq suspend of devices complete after 120.257 msecs
Jul 18 17:38:18 who kernel: ACPI: Preparing to enter system sleep state S3
Jul 18 17:38:18 who kernel: ACPI : EC: EC stopped
Jul 18 17:38:18 who kernel: PM: Saving platform NVS memory
Jul 18 17:38:18 who kernel: Disabling non-boot CPUs ...
Jul 18 17:38:18 who kernel: intel_pstate CPU 1 exiting
Jul 18 17:38:18 who kernel: kvm: disabling virtualization on CPU1
Jul 18 17:38:18 who kernel: smpboot: CPU 1 is now offline
Jul 18 17:38:18 who kernel: intel_pstate CPU 2 exiting
Jul 18 17:38:18 who kernel: kvm: disabling virtualization on CPU2
Jul 18 17:38:18 who kernel: smpboot: CPU 2 is now offline
Jul 18 17:38:18 who kernel: intel_pstate CPU 3 exiting
Jul 18 17:38:18 who kernel: kvm: disabling virtualization on CPU3
Jul 18 17:38:18 who kernel: smpboot: CPU 3 is now offline
Jul 18 17:38:18 who kernel: ACPI: Low-level resume complete
Jul 18 17:38:18 who kernel: ACPI : EC: EC started
Jul 18 17:38:18 who kernel: PM: Restoring platform NVS memory
Jul 18 17:38:18 who kernel: Enabling non-boot CPUs ...
Jul 18 17:38:18 who kernel: x86: Booting SMP configuration:
Jul 18 17:38:18 who kernel: smpboot: Booting Node 0 Processor 1 APIC 0x2
Jul 18 17:38:18 who kernel: kvm: enabling virtualization on CPU1
Jul 18 17:38:18 who kernel:  cache: parent cpu1 should not be sleeping
Jul 18 17:38:18 who kernel: CPU1 is up
Jul 18 17:38:18 who kernel: smpboot: Booting Node 0 Processor 2 APIC 0x1
Jul 18 17:38:18 who kernel: kvm: enabling virtualization on CPU2
Jul 18 17:38:18 who kernel:  cache: parent cpu2 should not be sleeping
Jul 18 17:38:18 who kernel: CPU2 is up
Jul 18 17:38:18 who kernel: smpboot: Booting Node 0 Processor 3 APIC 0x3
Jul 18 17:38:18 who kernel: kvm: enabling virtualization on CPU3
Jul 18 17:38:18 who kernel:  cache: parent cpu3 should not be sleeping
Jul 18 17:38:18 who kernel: CPU3 is up
Jul 18 17:38:18 who kernel: ACPI: Waking up from system sleep state S3
Jul 18 17:38:18 who kernel: pcieport 0000:06:05.0: quirk: waiting for thunderbolt to reestablish PCI tunnels...
Jul 18 17:38:18 who kernel: pcieport 0000:06:04.0: quirk: waiting for thunderbolt to reestablish PCI tunnels...
Jul 18 17:38:18 who kernel: pcieport 0000:06:03.0: quirk: waiting for thunderbolt to reestablish PCI tunnels...
Jul 18 17:38:18 who kernel: pcieport 0000:06:06.0: quirk: waiting for thunderbolt to reestablish PCI tunnels...
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: resuming...
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: control channel starting...
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: starting TX ring 0
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: enabling interrupt at register 0x38200 bit 0 (0x0 -> 0x1)
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: starting RX ring 0
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: enabling interrupt at register 0x38200 bit 12 (0x1 -> 0x1001)
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: resetting switch at 0
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: 0: resuming switch
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: resume finished
Jul 18 17:38:18 who kernel: PM: noirq resume of devices complete after 25.599 msecs
Jul 18 17:38:18 who kernel: PM: early resume of devices complete after 6.451 msecs
Jul 18 17:38:18 who kernel: wl_resume: PCI Resume handler
Jul 18 17:38:18 who kernel: sd 0:0:0:0: [sda] Starting disk
Jul 18 17:38:18 who kernel: bcm5974: bad trackpad package, length: 8
Jul 18 17:38:18 who kernel: bcm5974: bad trackpad package, length: 8
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: resetting error on 0:b.
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: 0:b: hotplug: scanning
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: 0:b: hotplug: no switch found
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: resetting error on 0:c.
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: 0:c: hotplug: scanning
Jul 18 17:38:18 who kernel: thunderbolt 0000:07:00.0: 0:c: hotplug: no switch found
Jul 18 17:38:18 who kernel: pciehp 0000:06:00.0:pcie24: Device 0000:07:00.0 already exists at 0000:07:00, cannot hot-add
Jul 18 17:38:18 who kernel: pciehp 0000:06:00.0:pcie24: Cannot add device at 0000:07:00
Jul 18 17:38:18 who kernel: rtc_cmos 00:02: System wakeup disabled by ACPI
Jul 18 17:38:18 who kernel: wl0: link down (wlp3s0)
Jul 18 17:38:18 who kernel: cfg80211: Exceeded CRDA call max attempts. Not calling CRDA
Jul 18 17:38:18 who kernel: ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Jul 18 17:38:18 who kernel: ata1.00: unexpected _GTF length (8)
Jul 18 17:38:18 who kernel: ata1.00: unexpected _GTF length (8)
Jul 18 17:38:18 who kernel: ata1.00: configured for UDMA/133
Jul 18 17:38:18 who kernel: PM: resume of devices complete after 507.670 msecs
Jul 18 17:38:18 who kernel: PM: Finishing wakeup.
Jul 18 17:38:18 who kernel: Restarting tasks ... done.
Jul 18 17:38:18 who kernel: video LNXVIDEO:00: Restoring backlight state
Jul 18 17:38:18 who systemd-logind[416]: Lid opened.
Jul 18 17:38:18 who systemd-sleep[7170]: System resumed.
Jul 18 17:38:18 who systemd[1]: Started Suspend.
Jul 18 17:38:18 who systemd[1]: sleep.target: Unit not needed anymore. Stopping.
Jul 18 17:38:18 who systemd[1]: Stopped target Sleep.
Jul 18 17:38:18 who systemd[1]: Stopping Sleep.
Jul 18 17:38:18 who systemd[1]: Reached target Suspend.
Jul 18 17:38:18 who systemd[1]: suspend.target: Unit is bound to inactive unit systemd-suspend.service. Stopping, too.
Jul 18 17:38:18 who systemd[1]: Starting Suspend.
Jul 18 17:38:18 who systemd[1]: Stopped target Suspend.
Jul 18 17:38:18 who systemd[1]: Stopping Suspend.

acpi_listen

button/lid LID close
processor LNXCPU:00 00000081 00000000
button/lid LID open
processor LNXCPU:01 00000081 00000000
processor LNXCPU:02 00000081 00000000
processor LNXCPU:03 00000081 00000000
button/lid LID close
processor LNXCPU:00 00000081 00000000
button/lid LID open
processor LNXCPU:01 00000081 00000000
processor LNXCPU:02 00000081 00000000
processor LNXCPU:03 00000081 00000000

Last edited by chookies (2015-07-24 10:28:15)

Offline

#2 2015-07-18 15:50:58

chookies
Member
Registered: 2015-07-17
Posts: 5

Re: [MacbookPro 2013] Lid open/close not detected (sometimes)

Maybe this has something to do with it: when I execute `systemctl suspend`, my laptop goes into suspension (i3lock starts, screen goes blank), but immediately wakes up after.

Jul 18 17:48:59 who systemd[1]: Started Suspend.
Jul 18 17:48:59 who systemd[1]: sleep.target: Unit not needed anymore. Stopping.
Jul 18 17:48:59 who systemd[1]: Stopped target Sleep.
Jul 18 17:48:59 who systemd[1]: Stopping Sleep.
Jul 18 17:48:59 who systemd[1]: Reached target Suspend.
Jul 18 17:48:59 who systemd-logind[416]: Operation finished.
Jul 18 17:48:59 who systemd[1]: suspend.target: Unit is bound to inactive unit systemd-suspend.service. Stopping, too.
Jul 18 17:48:59 who systemd[1]: Starting Suspend.
Jul 18 17:48:59 who systemd[1]: Stopped target Suspend.
Jul 18 17:48:59 who systemd[1]: Stopping Suspend.
Jul 18 17:48:59 who root[10860]: ACPI group/action undefined: processor / LNXCPU:02
Jul 18 17:48:59 who root[10862]: ACPI group/action undefined: processor / LNXCPU:03

Last edited by chookies (2015-07-18 15:54:08)

Offline

#3 2015-07-24 07:17:52

chookies
Member
Registered: 2015-07-17
Posts: 5

Re: [MacbookPro 2013] Lid open/close not detected (sometimes)

I'm not entirely sure how, but it seems to work now.

Some things I did that might have fixed it:

Installed `acpid` and added `systemctl suspend` to /etc/acpi/handler.sh

Add `usbcore.autosuspend=-1` to /etc/default/grub (and rebooted):

GRUB_CMDLINE_LINUX_DEFAULT="quiet rootflags=data=writeback usbcore.autosuspend=-1"

(Source)

Installed `pm-utils` and `pm-quirks` (but not really done anything with it).

Added my user to the power group.

Last edited by chookies (2015-07-24 07:20:20)

Offline

#4 2015-07-24 10:28:03

chookies
Member
Registered: 2015-07-17
Posts: 5

Re: [MacbookPro 2013] Lid open/close not detected (sometimes)

I think I jinxed it, because it has happened again. Now the lid close isn't detected anymore. There seems to be some pattern though: when I wait for a while, it usually works again.

Offline

#5 2015-07-24 15:04:51

Jhaus
Member
Registered: 2015-03-05
Posts: 4

Re: [MacbookPro 2013] Lid open/close not detected (sometimes)

I was having this exact problem. i3lock, xlock, xscreensaver, i3, awesome, qtile, gnome3 -- it didn't matter. I think Either the lid switch was bouncing or USB was causing it to wake after sleep. I disabled them both, and just type `pm-suspend` when I want it to sleep (the nuclear option).

See what your system allows to wake with `cat /proc/acpi/wakeup`

These commands disable the lid and usb wakeups.

echo LID0 | sudo tee /proc/acpi/wakeup
echo XHC1 | sudo tee /proc/acpi/wakeup

I keep my notes on my macbook install here:
https://gist.github.com/jhaubrich/6558b … management

GL

Last edited by Jhaus (2015-07-24 15:05:44)

Offline

#6 2015-07-24 19:17:21

chookies
Member
Registered: 2015-07-17
Posts: 5

Re: [MacbookPro 2013] Lid open/close not detected (sometimes)

Thanks for your reply, JHaus.

That indeed works, but with LID0 disabled, the laptop doesn't wake when I open the lid. I prefer that behavior, so I'll leave that option on. I think the problem is in my case more related to lid detection than suspension.

Offline

#7 2015-08-13 12:52:48

gauteh
Member
Registered: 2008-03-17
Posts: 19
Website

Re: [MacbookPro 2013] Lid open/close not detected (sometimes)

Turning off the LID0 on wakeup helped, but it seems that after a while, sometimes the lid state is not updated. When this happen and I run:

 while true; do cat /proc/acpi/button/lid/LID0/state ; sleep 1; done

and I close the lid (no suspend) it always returns state: open. I can still suspend with systemctl suspend and wakeup pressing the power button.

Last edited by gauteh (2015-08-13 12:53:12)

Offline

Board footer

Powered by FluxBB