Re: Macbook Air7,2 (Early 2015) doesn't suspend on lid close

2016-09-20 Thread Mike Larkin
On Tue, Sep 20, 2016 at 08:40:21PM +0200, Joerg Jung wrote:
> On Sat, Sep 17, 2016 at 11:22:54PM -0700, Mike Larkin wrote:
> > On Sun, Sep 18, 2016 at 09:33:12AM +0530, Sunil Nimmagadda wrote:
> > > On Sat, Sep 17, 2016 at 05:27:16PM -0700, Mike Larkin wrote:
> > > > On Sat, Sep 17, 2016 at 10:10:32PM +0530, Sunil Nimmagadda wrote:
> > > > > Synopsis: Macbook Air7,2 (Early 2015) doesn't suspend on lid close
> > > > > Category: kernel/acpi
> > > > > Environment:
> > > > >   System  : OpenBSD 6.0
> > > > >   Details : OpenBSD 6.0-current (GENERIC.MP) #2461: Fri Sep 
> > > > > 16 20:27:42 MDT 2016
> > > > >
> > > > > dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> > > > > 
> > > > >   Architecture: OpenBSD.amd64
> > > > >   Machine : amd64
> > > > > Description:
> > > > >   Macbook Air7,2 fails to suspend on lid close. The screen, 
> > > > > keyboard
> > > > >   backlight and led on urtwn0 are still on after closing the lid.
> > > > > 
> > > > >   Also, kernel intermittently freezes at this line while 
> > > > > booting...
> > > > >   acpiec0 at acpi0 
> > > > > 
> > > > >   May be related, wsconsctl display.brightness=60 freezes and top 
> > > > > shows...
> > > > >   6877 root 10 0 272K 220K idle acpilk 0:00% wsconsctl
> > > > > 
> > > > 
> > > > Does regular 'zzz' work?
> > > > 
> > > > -ml
> > > 
> > > Hi,
> > > 
> > > No, zzz/ZZZ doesn't work.
> > > 
> > 
> > Did it work before?
> 
> I own the same device, and I AFAIR it was never working. 
> 
> ...and yes this might be related to wsconsctl and brightness via
> inteldrm.
>  
> > (this conversation is like pulling teeth or playing 20 questions).
> 
> I'm sorry.
> 
> Any news on this? Did Sunil replied in private or something?
> 
> I'm willing to help and test things, so if you guys come up with
> something, e.g. a patch/diff, whatever, or if you need some more
> info/dumps let me know, please. I also own some other MacBook (Air)
> models where I can test things.
> 
> Thanks,
> Regards,
> Joerg (jung@)

No reply, unless I accidentally missed it (which is entirely possible).

zzz and ZZZ and closing the lid work by queueing a sleep task via
acpi_addtask. Regardless of which method you used, you'll end up in
acpi_sleep_task.

>From there, we end up in acpi_sleep_state which does the following:

1. sanity checks - does the machine support the Sx state you are requesting?
(S3 in the case of zzz or lidsuspend, S4 in the case of ZZZ).

2. enable the SST_WAKING indicator if the machine has one (eg, start the 
blinking
moon LED on a thinkpad, or pulse the power LED on some other machines)

3. turns off the screen via wsdisplay_suspend

4. if S4 (ZZZ), flush the buffercache

5. quiesce all devices by walking the device tree, calling the device's
activate method with a QUIESCE parameter. This is done with interrupts still
enabled, to allow certain devices to "pre-suspend" any state they need.

6. stop any I/Os in flight (bufq_quiesce)

7. stop/park any APs (multiprocessor machines)

8. disable interrupts

9. suspend all devices (similar to step 5). Devices are expected to copy their
hardware state somewhere "safe" (like their softc)

10. call ACPI _PTS

11. enable the SST_SLEEPING indicator (eg, the solid moon LED on a thinkpad)

12. call ACPI _GTS

13. clear existing ACPI event status (eg, whack the state of the power button
status)

14. enable wakeup for devices that are listed as "wakeup capable" for the 
selected Sx mode

15. go to sleep


In debugging failure to suspend issues (the above sequence covers only up
to suspend, not resume), read through that and match up the code in acpi.c
where you think your machine is having problems.

Start putting printfs or other debugger output in various places, this is
usually possible until somewhat late in the sequence. You may need to
disable the wsdisplay_suspend call temporarily (to see any printfs you add),
but this can have adverse effects on various machines if suspending from
console or from X and may cause hangs later in the sequence that wouldn't
have otherwise been there, or failures to resume video properly. YMMV.

Once you've identified the step or steps causing problems, come back and
let us know, and we can dig further. This is about all I can suggest without
having access to the hardware.

-ml



Re: Macbook Air7,2 (Early 2015) doesn't suspend on lid close

2016-09-17 Thread Mike Larkin
On Sun, Sep 18, 2016 at 09:33:12AM +0530, Sunil Nimmagadda wrote:
> On Sat, Sep 17, 2016 at 05:27:16PM -0700, Mike Larkin wrote:
> > On Sat, Sep 17, 2016 at 10:10:32PM +0530, Sunil Nimmagadda wrote:
> > > Synopsis: Macbook Air7,2 (Early 2015) doesn't suspend on lid close
> > > Category: kernel/acpi
> > > Environment:
> > >   System  : OpenBSD 6.0
> > >   Details : OpenBSD 6.0-current (GENERIC.MP) #2461: Fri Sep 16 
> > > 20:27:42 MDT 2016
> > >
> > > dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> > > 
> > >   Architecture: OpenBSD.amd64
> > >   Machine : amd64
> > > Description:
> > >   Macbook Air7,2 fails to suspend on lid close. The screen, keyboard
> > >   backlight and led on urtwn0 are still on after closing the lid.
> > > 
> > >   Also, kernel intermittently freezes at this line while booting...
> > >   acpiec0 at acpi0 
> > > 
> > >   May be related, wsconsctl display.brightness=60 freezes and top shows...
> > >   6877 root 10 0 272K 220K idle acpilk 0:00% wsconsctl
> > > 
> > 
> > Does regular 'zzz' work?
> > 
> > -ml
> 
> Hi,
> 
> No, zzz/ZZZ doesn't work.
> 

Did it work before?

(this conversation is like pulling teeth or playing 20 questions).



Re: Macbook Air7,2 (Early 2015) doesn't suspend on lid close

2016-09-17 Thread Sunil Nimmagadda
On Sat, Sep 17, 2016 at 05:27:16PM -0700, Mike Larkin wrote:
> On Sat, Sep 17, 2016 at 10:10:32PM +0530, Sunil Nimmagadda wrote:
> > Synopsis: Macbook Air7,2 (Early 2015) doesn't suspend on lid close
> > Category: kernel/acpi
> > Environment:
> > System  : OpenBSD 6.0
> > Details : OpenBSD 6.0-current (GENERIC.MP) #2461: Fri Sep 16 
> > 20:27:42 MDT 2016
> >  
> > dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> > 
> > Architecture: OpenBSD.amd64
> > Machine : amd64
> > Description:
> > Macbook Air7,2 fails to suspend on lid close. The screen, keyboard
> > backlight and led on urtwn0 are still on after closing the lid.
> > 
> > Also, kernel intermittently freezes at this line while booting...
> > acpiec0 at acpi0 
> > 
> > May be related, wsconsctl display.brightness=60 freezes and top shows...
> > 6877 root 10 0 272K 220K idle acpilk 0:00% wsconsctl
> > 
> 
> Does regular 'zzz' work?
> 
> -ml

Hi,

No, zzz/ZZZ doesn't work.



Re: Macbook Air7,2 (Early 2015) doesn't suspend on lid close

2016-09-17 Thread Mike Larkin
On Sat, Sep 17, 2016 at 10:10:32PM +0530, Sunil Nimmagadda wrote:
> Synopsis: Macbook Air7,2 (Early 2015) doesn't suspend on lid close
> Category: kernel/acpi
> Environment:
>   System  : OpenBSD 6.0
>   Details : OpenBSD 6.0-current (GENERIC.MP) #2461: Fri Sep 16 
> 20:27:42 MDT 2016
>
> dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> 
>   Architecture: OpenBSD.amd64
>   Machine : amd64
> Description:
>   Macbook Air7,2 fails to suspend on lid close. The screen, keyboard
>   backlight and led on urtwn0 are still on after closing the lid.
> 
>   Also, kernel intermittently freezes at this line while booting...
>   acpiec0 at acpi0 
> 
>   May be related, wsconsctl display.brightness=60 freezes and top shows...
>   6877 root 10 0 272K 220K idle acpilk 0:00% wsconsctl
> 

Does regular 'zzz' work?

-ml

> OpenBSD 6.0-current (GENERIC.MP) #2461: Fri Sep 16 20:27:42 MDT 2016
> dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> RTC BIOS diagnostic error 
> ff
> real mem = 8469352448 (8077MB)
> avail mem = 8208166912 (7827MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.7 @ 0x8afad000 (32 entries)
> bios0: vendor Apple Inc. version "MBA71.88Z.0166.B12.1602221953" date 
> 02/22/2016
> bios0: Apple Inc. MacBookAir7,2
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S3 S4 S5
> acpi0: tables DSDT FACP HPET APIC SBST ECDT SSDT SSDT SSDT SSDT SSDT SSDT 
> SSDT SSDT MCFG DMAR
> acpi0: wakeup devices PEG0(S3) EC__(S3) HDEF(S3) RP01(S3) RP02(S3) RP03(S4) 
> ARPT(S4) RP05(S3) RP06(S3) SPIT(S3) XHC1(S3) ADP1(S3) LID0(S3)
> acpitimer0 at acpi0: 3579545 Hz, 24 bits
> acpihpet0 at acpi0: 14318179 Hz
> acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.23 MHz
> cpu0: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
> cpu0: 256KB 64b/line 8-way L2 cache
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
> cpu0: apic clock running at 99MHz
> cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
> cpu1 at mainbus0: apid 2 (application processor)
> cpu1: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.00 MHz
> cpu1: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
> cpu1: 256KB 64b/line 8-way L2 cache
> cpu1: smt 0, core 1, package 0
> cpu2 at mainbus0: apid 1 (application processor)
> cpu2: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.00 MHz
> cpu2: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
> cpu2: 256KB 64b/line 8-way L2 cache
> cpu2: smt 1, core 0, package 0
> cpu3 at mainbus0: apid 3 (application processor)
> cpu3: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.00 MHz
> cpu3: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
> cpu3: 256KB 64b/line 8-way L2 cache
> cpu3: smt 1, core 1, package 0
> ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 40 pins
> acpiec0 at acpi0
> acpimcfg0 at acpi0 addr 0xe000, bus 0-155
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpiprt1 at acpi0: bus -1 (PEG0)
> acpiprt2 at acpi0: bus 1 (RP01)
> acpiprt3 at acpi0: bus 2 (RP02)
> acpiprt4 at acpi0: bus 3 (RP03)
> acpiprt5 at acpi0: bus 5 (RP05)
> acpiprt6 at acpi0: bus 4 (RP06)
> acpicpu0 at acpi0: C3(200@530 mwait.1@0x60)

Macbook Air7,2 (Early 2015) doesn't suspend on lid close

2016-09-17 Thread Sunil Nimmagadda
Synopsis: Macbook Air7,2 (Early 2015) doesn't suspend on lid close
Category: kernel/acpi
Environment:
System  : OpenBSD 6.0
Details : OpenBSD 6.0-current (GENERIC.MP) #2461: Fri Sep 16 
20:27:42 MDT 2016
 
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP

Architecture: OpenBSD.amd64
Machine : amd64
Description:
Macbook Air7,2 fails to suspend on lid close. The screen, keyboard
backlight and led on urtwn0 are still on after closing the lid.

Also, kernel intermittently freezes at this line while booting...
acpiec0 at acpi0 

May be related, wsconsctl display.brightness=60 freezes and top shows...
6877 root 10 0 272K 220K idle acpilk 0:00% wsconsctl

OpenBSD 6.0-current (GENERIC.MP) #2461: Fri Sep 16 20:27:42 MDT 2016
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
RTC BIOS diagnostic error 
ff
real mem = 8469352448 (8077MB)
avail mem = 8208166912 (7827MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0x8afad000 (32 entries)
bios0: vendor Apple Inc. version "MBA71.88Z.0166.B12.1602221953" date 02/22/2016
bios0: Apple Inc. MacBookAir7,2
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP HPET APIC SBST ECDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT 
SSDT MCFG DMAR
acpi0: wakeup devices PEG0(S3) EC__(S3) HDEF(S3) RP01(S3) RP02(S3) RP03(S4) 
ARPT(S4) RP05(S3) RP06(S3) SPIT(S3) XHC1(S3) ADP1(S3) LID0(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.23 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.00 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 1 (application processor)
cpu2: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.00 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 1, core 0, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz, 1500.00 MHz
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,PT,SENSOR,ARAT
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 40 pins
acpiec0 at acpi0
acpimcfg0 at acpi0 addr 0xe000, bus 0-155
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG0)
acpiprt2 at acpi0: bus 1 (RP01)
acpiprt3 at acpi0: bus 2 (RP02)
acpiprt4 at acpi0: bus 3 (RP03)
acpiprt5 at acpi0: bus 5 (RP05)
acpiprt6 at acpi0: bus 4 (RP06)
acpicpu0 at acpi0: C3(200@530 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: C3(200@530 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu2 at acpi0: C3(200@530 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu3 at acpi0: C3(200@530 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
"APP0001" at acpi0 not configured
acpials0 at acpi0: ALS0
"ACPI0002" at acpi0 not configured
"APP000D" at acpi0