On Tue, Jul 30, 2013 at 12:06:30AM +0200, Mark Kettenis wrote:
> On amd64/i386 there is this nasty thing called SMM mode.  This allows
> BIOS writers to run code behind the back of the OS to do all sorts of
> crazy stuff like simulating a legacy PC keyboard controller on systems
> that don't have one, or spin up the fan in your laptop when it is
> about to melt.  On a lot of hardware it is therefore poking the same
> hardware registers that are also used by the ACPI code that's running
> in the OS.  Ever witnessed what happens if two kids want to play with
> the same toy?
> 
> So in order to prevent bad things from happening, ACPI defines a
> locking protocol to make sure the OS and the SMM BIOS code don't
> access the same hardware at the same time.  Currently OpenBSD doesn't
> do this locking properly.  The diff below changes this, enabling the
> locking protocol for access to registers that need it.  
> 
> I've successfully tested this diff on my x220 and on a absolutely
> lowest end hp laptop that I bought to do some radeondrm(4)
> development.  Seems to work fine on those machines.  So it's time to
> get this more widely tested.
> 
> Things to test are suspend/resume, whether the battery status is
> properly reported and updated, whether the acpitz(4) temperature
> sensors are still working, etc., etc.  So please run with it for a bit
> and report any breakage.
> 
> Thanks,
> 
> Mark
> 
> 
> P.S. This diff might help machines that where OpenBSD sometimes
>      reports crazy temperatures.  But needs to be tested on other
>      machines as well!.
> 

No functional change on my Dell XPS 13. After suspend/resume cycle my
hw.sensors.acpitz0.temp0 and hw.sensors.acpitz1.temp0 is still returning
values 20C lower then it does before the suspend.

sysctl hw.sensors before suspend:

hw.sensors.cpu0.temp0=57.00 degC
hw.sensors.cpu1.temp0=57.00 degC
hw.sensors.cpu2.temp0=57.00 degC
hw.sensors.cpu3.temp0=57.00 degC
hw.sensors.acpitz0.temp0=55.00 degC (zone temperature)
hw.sensors.acpitz1.temp0=55.00 degC (zone temperature)
hw.sensors.acpiac0.indicator0=Off (power supply)
hw.sensors.acpibat0.volt0=7.40 VDC (voltage)
hw.sensors.acpibat0.volt1=7.44 VDC (current voltage)
hw.sensors.acpibat0.current0=1.75 A (rate)
hw.sensors.acpibat0.amphour0=6.45 Ah (last full capacity)
hw.sensors.acpibat0.amphour1=0.64 Ah (warning capacity)
hw.sensors.acpibat0.amphour2=0.00 Ah (low capacity)
hw.sensors.acpibat0.amphour3=4.10 Ah (remaining capacity), OK
hw.sensors.acpibat0.raw0=1 (battery discharging), OK
hw.sensors.softraid0.drive0=online (sd1), OK

and after suspend:

hw.sensors.cpu0.temp0=52.00 degC
hw.sensors.cpu1.temp0=52.00 degC
hw.sensors.cpu2.temp0=52.00 degC
hw.sensors.cpu3.temp0=52.00 degC
hw.sensors.acpitz0.temp0=27.80 degC (zone temperature)
hw.sensors.acpitz1.temp0=29.80 degC (zone temperature)
hw.sensors.acpiac0.indicator0=Off (power supply)
hw.sensors.acpibat0.volt0=7.40 VDC (voltage)
hw.sensors.acpibat0.volt1=7.54 VDC (current voltage)
hw.sensors.acpibat0.current0=1.77 A (rate)
hw.sensors.acpibat0.amphour0=6.45 Ah (last full capacity)
hw.sensors.acpibat0.amphour1=0.64 Ah (warning capacity)
hw.sensors.acpibat0.amphour2=0.00 Ah (low capacity)
hw.sensors.acpibat0.amphour3=4.06 Ah (remaining capacity), OK
hw.sensors.acpibat0.raw0=1 (battery discharging), OK
hw.sensors.softraid0.drive0=online (sd1), OK

dmesg:

OpenBSD 5.4-current (GENERIC.MP) #1: Mon Jul 29 19:42:25 EDT 2013
    [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 3555700736 (3390MB)
avail mem = 3453317120 (3293MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xe1020 (70 entries)
bios0: vendor Dell Inc. version "A08" date 01/22/2013
bios0: Dell Inc. Dell System XPS L321X
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SLIC SSDT ASF! HPET APIC MCFG SSDT SSDT UEFI
UEFI POAT UEFI SSDT
acpi0: wakeup devices P0P1(S4) EHC1(S0) EHC2(S0) PXSX(S4) RP01(S4)
PXSX(S4) RP02(S4) PXSX(S4) RP04(S0) LID0(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz, 1995.74 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,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,LONG,LAHF,PERF,ITSC
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
cpu0: apic clock running at 99MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz, 1995.47 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,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,LONG,LAHF,PERF,ITSC
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 1, core 0, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz, 1995.47 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,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,LONG,LAHF,PERF,ITSC
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 1, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz, 1995.47 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,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,LONG,LAHF,PERF,ITSC
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 14 pa 0xfec00000, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xf8000000, bus 0-63
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (P0P1)
acpiprt2 at acpi0: bus 1 (RP01)
acpiprt3 at acpi0: bus 2 (RP02)
acpiprt4 at acpi0: bus 3 (RP04)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2, C1, PSS
acpicpu1 at acpi0: C3, C2, C1, PSS
acpicpu2 at acpi0: C3, C2, C1, PSS
acpicpu3 at acpi0: C3, C2, C1, PSS
acpitz0 at acpi0: critical temperature is 100 degC
acpitz1 at acpi0: critical temperature is 100 degC
acpibtn0 at acpi0: PWRB
acpibtn1 at acpi0: SLPB
acpibtn2 at acpi0: LID0
acpiac0 at acpi0: AC unit offline
acpibat0 at acpi0: BAT0 model "Dell" serial 1007 type LION oem "SIMPLO"
acpivideo0 at acpi0: GFX0
acpivout0 at acpivideo0: DD02
cpu0: Enhanced SpeedStep 1995 MHz: speeds: 1601, 1600, 1500, 1400, 1300,
1200, 1100, 1000, 900, 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel Core 2G Host" rev 0x09
vga1 at pci0 dev 2 function 0 "Intel HD Graphics 3000" rev 0x09
intagp0 at vga1
agp0 at intagp0: aperture at 0xe0000000, size 0x10000000
inteldrm0 at vga1
drm0 at inteldrm0
inteldrm0: 1366x768
wsdisplay0 at vga1 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel 6 Series MEI" rev 0x04 at pci0 dev 22 function 0 not configured
ehci0 at pci0 dev 26 function 0 "Intel 6 Series USB" rev 0x05: apic 14
int 16
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 "Intel 6 Series HD Audio" rev 0x05:
msi
azalia0: codecs: Realtek/0x0275, Intel/0x2805, using Realtek/0x0275
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 6 Series PCIE" rev 0xb5: msi
pci1 at ppb0 bus 1
ppb1 at pci0 dev 28 function 1 "Intel 6 Series PCIE" rev 0xb5: msi
pci2 at ppb1 bus 2
athn0 at pci2 dev 0 function 0 "Atheros AR9285" rev 0x01: apic 14 int 17
athn0: AR9285 rev 2 (1T1R), ROM rev 13, address 00:25:d3:d6:a8:17
ppb2 at pci0 dev 28 function 3 "Intel 6 Series PCIE" rev 0xb5: msi
pci3 at ppb2 bus 3
"Fresco Logic FL1009 xHCI" rev 0x02 at pci3 dev 0 function 0 not
configured
ehci1 at pci0 dev 29 function 0 "Intel 6 Series USB" rev 0x05: apic 14
int 23
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "Intel EHCI root hub" rev 2.00/1.00 addr 1
pcib0 at pci0 dev 31 function 0 "Intel QS67 LPC" rev 0x05
ahci0 at pci0 dev 31 function 2 "Intel 6 Series AHCI" rev 0x05: msi,
AHCI 1.3
scsibus0 at ahci0: 32 targets
sd0 at scsibus0 targ 0 lun 0: <ATA, SAMSUNG SSD PM83, CXM1> SCSI3
0/direct fixed naa.5002538043584d30
sd0: 122104MB, 512 bytes/sector, 250069680 sectors, thin
ichiic0 at pci0 dev 31 function 3 "Intel 6 Series SMBus" rev 0x05: apic
14 int 18
iic0 at ichiic0
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
mtrr: Pentium Pro MTRR support
uhub2 at uhub0 port 1 "Intel Rate Matching Hub" rev 2.00/0.00 addr 2
uvideo0 at uhub2 port 5 configuration 1 interface 0
"CN01RH71724871CHDCTWA00 Laptop_Integrated_Webcam_1.3M" rev 2.00/1b.03
addr 3
video0 at uvideo0
uhub3 at uhub1 port 1 "Intel Rate Matching Hub" rev 2.00/0.00 addr 2
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
scsibus2 at softraid0: 256 targets
sd1 at scsibus2 targ 1 lun 0: <OPENBSD, SR CRYPTO, 005> SCSI2 0/direct
fixed
sd1: 122103MB, 512 bytes/sector, 250067198 sectors
root on sd1a (f08412b5b4326d0b.a) swap on sd1b dump on sd1b

> 
> Index: dsdt.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
> retrieving revision 1.203
> diff -u -p -r1.203 dsdt.c
> --- dsdt.c    2 Jun 2013 17:21:38 -0000       1.203
> +++ dsdt.c    30 Jun 2013 18:43:51 -0000
> @@ -770,7 +770,7 @@ aml_lockfield(struct aml_scope *scope, s
>  
>       /* Spin to acquire lock */
>       while (!st) {
> -             st = 
> acpi_acquire_global_lock(&acpi_softc->sc_facs->global_lock);
> +             st = acpi_acquire_glk(&acpi_softc->sc_facs->global_lock);
>               /* XXX - yield/delay? */
>       }
>  
> @@ -790,7 +790,7 @@ aml_unlockfield(struct aml_scope *scope,
>               return;
>  
>       /* Release lock */
> -     st = acpi_release_global_lock(&acpi_softc->sc_facs->global_lock);
> +     st = acpi_release_glk(&acpi_softc->sc_facs->global_lock);
>       if (!st)
>               return;
>  
> 

-- 
James Turner

Reply via email to