Re: Add acpipci(4) on amd64

2018-10-24 Thread Jeremie Courreges-Anglas
On Mon, Oct 22 2018, Mark Kettenis  wrote:
> Diff below adds an acpipci(4) driver on amd64.  For now the main
> purpose of this driver is to make the PCI-specific _OSC calls to
> advertise the functionality we support.  Most notably this advertises
> support for PCIE native hotplug as we have some indications that this
> will help Thunderbolt 3 support on some machines.
>
> I'd like to see this tested on a wide range of amd64 hardware, but
> especially on laptops.  Please reply with a diff of your dmesg before
> and after.  Make sure you run make config before building a new kernel.

KVM 2.8 vm, fwiw.
tl;dr "+acpipci0 at acpi0 PCI0: _OSC failed"

--- old Wed Oct 24 13:34:31 2018
+++ new Wed Oct 24 13:34:44 2018
@@ -1,4 +1,4 @@
-OpenBSD 6.4-current (GENERIC.MP) #0: Wed Oct 24 09:45:19 CEST 2018
+OpenBSD 6.4-current (GENERIC.MP) #1: Wed Oct 24 13:31:30 CEST 2018
 j...@russell.wxcvbn.org:/sys/arch/amd64/compile/GENERIC.MP
 real mem = 8573018112 (8175MB)
 avail mem = 8303935488 (7919MB)
@@ -15,16 +15,16 @@
 acpitimer0 at acpi0: 3579545 Hz, 24 bits
 acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
 cpu0 at mainbus0: apid 0 (boot processor)
-cpu0: Intel Core Processor (Broadwell), 3408.50 MHz, 06-3d-02
+cpu0: Intel Core Processor (Broadwell), 3408.56 MHz, 06-3d-02
 cpu0: 
FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,HV,NXE,RDTSCP,LONG,LAHF,3DNOWP,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,RDSEED,ADX,SMAP,XSAVEOPT,MELTDOWN
 cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 
16-way L2 cache
 cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
 cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
 cpu0: smt 0, core 0, package 0
 mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
-cpu0: apic clock running at 1000MHz
+cpu0: apic clock running at 999MHz
 cpu1 at mainbus0: apid 1 (application processor)
-cpu1: Intel Core Processor (Broadwell), 3408.05 MHz, 06-3d-02
+cpu1: Intel Core Processor (Broadwell), 3408.04 MHz, 06-3d-02
 cpu1: 
FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,HV,NXE,RDTSCP,LONG,LAHF,3DNOWP,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,RDSEED,ADX,SMAP,XSAVEOPT,MELTDOWN
 cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 
16-way L2 cache
 cpu1: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
@@ -35,6 +35,7 @@
 acpicpu0 at acpi0: C1(@1 halt!)
 acpicpu1 at acpi0: C1(@1 halt!)
 "ACPI0006" at acpi0 not configured
+acpipci0 at acpi0 PCI0: _OSC failed
 acpicmos0 at acpi0
 "PNP0A06" at acpi0 not configured
 "PNP0A06" at acpi0 not configured
@@ -85,5 +86,3 @@
 scsibus4 at softraid0: 256 targets
 root on sd0a (871b81ad3a5d5c9e.a) swap on sd0b dump on sd0b
 fd0 at fdc0 drive 1: density unknown
-syncing disks... done
-rebooting...


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: Add acpipci(4) on amd64

2018-10-24 Thread Paul de Weerd
Hi Mark,

On Mon, Oct 22, 2018 at 09:45:06PM +0200, Mark Kettenis wrote:
| I'd like to see this tested on a wide range of amd64 hardware, but
| especially on laptops.  Please reply with a diff of your dmesg before
| and after.  Make sure you run make config before building a new kernel.

Thanks for your work!  Not much difference on my GPD Win (pocket)
computer.  Diff and full dmesg below.

Note that there's a kernel page fault when running bwfm attach hooks;
this happens frequently, I avoid it by booting a kernel with bwfm
disabled.

Cheers,

Paul

--- /home/weerd/taco.20181019.dmesg Wed Oct 24 08:52:07 2018
+++ /home/weerd/taco.20181024.dmesg Wed Oct 24 08:52:07 2018
@@ -1,7 +1,7 @@
-OpenBSD 6.4-current (GENERIC.MP) #370: Fri Oct 19 13:09:31 MDT 2018
-dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
+OpenBSD 6.4-current (GENERIC.MP) #7: Wed Oct 24 07:42:29 CEST 2018
+we...@pom.alm.weirdnet.nl:/usr/src/sys/arch/amd64/compile/GENERIC.MP
 real mem = 4182315008 (3988MB)
-avail mem = 4046282752 (3858MB)
+avail mem = 4046286848 (3858MB)
 mpath0 at root
 scsibus0 at mpath0: 256 targets
 mainbus0 at root
@@ -15,7 +15,7 @@
 acpitimer0 at acpi0: 3579545 Hz, 24 bits
 acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
 cpu0 at mainbus0: apid 0 (boot processor)
-cpu0: Intel(R) Atom(TM) x7-Z8700 CPU @ 1.60GHz, 1600.26 MHz, 06-4c-03
+cpu0: Intel(R) Atom(TM) x7-Z8700 CPU @ 1.60GHz, 1600.25 MHz, 06-4c-03
 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,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN
 cpu0: 1MB 64b/line 16-way L2 cache
 cpu0: smt 0, core 0, package 0
@@ -28,12 +28,12 @@
 cpu1: 1MB 64b/line 16-way L2 cache
 cpu1: smt 0, core 1, package 0
 cpu2 at mainbus0: apid 4 (application processor)
-cpu2: Intel(R) Atom(TM) x7-Z8700 CPU @ 1.60GHz, 1599.95 MHz, 06-4c-03
+cpu2: Intel(R) Atom(TM) x7-Z8700 CPU @ 1.60GHz, 1599.96 MHz, 06-4c-03
 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,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN
 cpu2: 1MB 64b/line 16-way L2 cache
 cpu2: smt 0, core 2, package 0
 cpu3 at mainbus0: apid 6 (application processor)
-cpu3: Intel(R) Atom(TM) x7-Z8700 CPU @ 1.60GHz, 1599.95 MHz, 06-4c-03
+cpu3: Intel(R) Atom(TM) x7-Z8700 CPU @ 1.60GHz, 1599.96 MHz, 06-4c-03
 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,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,RDRAND,NXE,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT,MELTDOWN
 cpu3: 1MB 64b/line 16-way L2 cache
 cpu3: smt 0, core 3, package 0
@@ -96,6 +96,7 @@
 "INT33FE" at iic0 addr 0x54 not configured
 chvgpio2 at acpi0: GPO0 uid 1 addr 0xfed8/0x8000 irq 49, 56 pins
 chvgpio3 at acpi0: GPO2 uid 3 addr 0xfed9/0x8000 irq 50, 24 pins
+acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001
 sdhc0 at acpi0 SDHA addr 0xa1a3a000/0x1000 irq 45
 sdhc0: SDHC 3.0, 200 MHz base clock
 sdmmc0 at sdhc0: 8-bit, sd high-speed, mmc high-speed, dma
@@ -197,15 +198,15 @@
 vmm0 at mainbus0: VMX/EPT (using slow L1TF mitigation)
 efifb at mainbus0 not configured
 sdmmc1: can't enable card
-scsibus1 at sdmmc0: 2 targets, initiator 0
-sd0 at scsibus1 targ 1 lun 0:  SCSI2 0/direct removable
-sd0: 59640MB, 512 bytes/sector, 122142720 sectors
+scsibus1 at sdmmc2: 2 targets, initiator 0
+sd0 at scsibus1 targ 1 lun 0:  SCSI2 0/direct removable
+sd0: 61071MB, 512 bytes/sector, 125073408 sectors
+scsibus2 at sdmmc0: 2 targets, initiator 0
+sd1 at scsibus2 targ 1 lun 0:  SCSI2 0/direct removable
+sd1: 59640MB, 512 bytes/sector, 122142720 sectors
 uhidev0 at uhub0 port 2 configuration 1 interface 0 "HK-XBOXKB-US-A0-10-00 USB 
KEYBOARD" rev 1.10/1.00 addr 2
 uhidev0: iclass 3/1
 ukbd0 at uhidev0: 8 variable keys, 6 key codes
-scsibus2 at sdmmc2: 2 targets, initiator 0
-sd1 at scsibus2 targ 1 lun 0:  SCSI2 0/direct removable
-sd1: 61071MB, 512 bytes/sector, 125073408 sectors
 wskbd0 at ukbd0: console keyboard, using wsdisplay0
 uhidev1 at uhub0 port 2 configuration 1 interface 1 "HK-XBOXKB-US-A0-10-00 USB 
KEYBOARD" rev 1.10/1.00 addr 2
 uhidev1: iclass 3/0, 9 report ids
@@ -224,14 +225,17 @@
 ukbd1 at uhidev3: 8 variable keys, 6 key codes
 wskbd1 at ukbd1 mux 1
 wskbd1: connecting to wsdisplay0
-ure0 at uhub0 port 9 configuration 1 interface 0 "Realtek USB 10/100/1000 LAN" 
rev 3.00/30.00 addr 4
-ure0: ver 5c20, address 00:e0:97:00:65:53
-rgephy0 at ure0 phy 0: RTL8251 PHY, rev. 0
 vscsi0 at root
 scsibus3 at vscsi0: 256 targets
 softraid0 at root
 scsibus4 at softraid0: 256 

Re: Add acpipci(4) on amd64

2018-10-23 Thread Jan Klemkow
Hi Mark,

On Tue, Oct 23, 2018 at 07:32:16PM +0200, Mark Kettenis wrote:
> > Date: Tue, 23 Oct 2018 18:40:42 +0200
> > From: Jan Klemkow 
> > On Mon, Oct 22, 2018 at 09:45:06PM +0200, Mark Kettenis wrote:
> > > Diff below adds an acpipci(4) driver on amd64.  For now the main
> > > purpose of this driver is to make the PCI-specific _OSC calls to
> > > advertise the functionality we support.  Most notably this advertises
> > > support for PCIE native hotplug as we have some indications that this
> > > will help Thunderbolt 3 support on some machines.
> > > 
> > > I'd like to see this tested on a wide range of amd64 hardware, but
> > > especially on laptops.  Please reply with a diff of your dmesg before
> > > and after.  Make sure you run make config before building a new kernel.
> > 
> > Tested with ThinkPad X1 Carbon 6th Gen under OpenBSD/amd64-current.  It
> > is tested with Thunderbold 3 enabled in BIOS.
> 
> Bingo!
> 
> Just to be sure, both dmesg's were made with the same BIOS
> configuration and no devices connected to Thunderbolt 3 at boot?

Yes, same BIOS option and no devices attached for both dmesgs .  But, I
have changed the BIOS option them.  When "Thunderbolt 3" is enabled and
the machine resumes from suspend (S3), than the acpi0 kernel thread
takes 80-90% CPU usage till reboot.

Tomorrow, I will see if could get a thunderbolt device for testing.

FYI, with "Thunderbolt 3" disabled the dmesg looks like the ThinkPad X1
Carbon 5th Gen. dmesgs from the other testers.

See below for a full dmesg listing with your diff and "Thunderbolt 3"
enabled.

Thanks,
Jan

--- dmesg.boot_before_hack  Tue Oct 23 15:24:35 2018
+++ dmesg.boot_after_hack   Tue Oct 23 15:24:58 2018
@@ -1,4 +1,4 @@
-OpenBSD 6.4-current (GENERIC.MP) #22: Tue Oct 23 15:04:51 CEST 2018
+OpenBSD 6.4-current (GENERIC.MP) #23: Tue Oct 23 15:16:49 CEST 2018
 you...@fabien.klemkow.net:/sys/arch/amd64/compile/GENERIC.MP
 real mem = 8451149824 (8059MB)
 avail mem = 8185741312 (7806MB)
@@ -24,7 +24,7 @@
 cpu0: apic clock running at 24MHz
 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-7300U CPU @ 2.60GHz, 1155.00 MHz, 06-8e-09
+cpu1: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1156.38 MHz, 06-8e-09
 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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
 cpu1: 256KB 64b/line 8-way L2 cache
 cpu1: smt 0, core 1, package 0
@@ -73,6 +73,7 @@
 acpicpu3 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
 acpipwrres0 at acpi0: PUBS, resource for XHC_
 acpitz0 at acpi0: critical temperature is 128 degC
+acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001
 acpithinkpad0 at acpi0
 acpiac0 at acpi0: AC unit online
 acpibat0 at acpi0: BAT0 model "01AV430" serial   585 type LiP oem "SMP"


Full dmegs listing:


OpenBSD 6.4-current (GENERIC.MP) #23: Tue Oct 23 15:16:49 CEST 2018
you...@fabien.klemkow.net:/sys/arch/amd64/compile/GENERIC.MP
real mem = 8451149824 (8059MB)
avail mem = 8185741312 (7806MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xca63b000 (63 entries)
bios0: vendor LENOVO version "N23ET55W (1.30 )" date 08/31/2018
bios0: LENOVO 20KHS08H00
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT SSDT TPM2 UEFI SSDT SSDT HPET APIC MCFG ECDT SSDT 
SSDT BOOT BATB SSDT SSDT SSDT LPIT WSMT SSDT SSDT SSDT DBGP DBG2 POAT DMAR NHLT 
ASF! FPDT UEFI
acpi0: wakeup devices GLAN(S4) XHC_(S3) XDCI(S4) HDAS(S4) RP01(S4) PXSX(S4) 
RP02(S4) PXSX(S4) PXSX(S4) RP04(S4) PXSX(S4) RP05(S4) PXSX(S4) RP06(S4) 
PXSX(S4) RP07(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 2399 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1397.33 MHz, 06-8e-09
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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
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 

Re: Add acpipci(4) on amd64

2018-10-23 Thread Mark Kettenis
> Date: Tue, 23 Oct 2018 18:40:42 +0200
> From: Jan Klemkow 
> 
> Hi Mark,
> 
> On Mon, Oct 22, 2018 at 09:45:06PM +0200, Mark Kettenis wrote:
> > Diff below adds an acpipci(4) driver on amd64.  For now the main
> > purpose of this driver is to make the PCI-specific _OSC calls to
> > advertise the functionality we support.  Most notably this advertises
> > support for PCIE native hotplug as we have some indications that this
> > will help Thunderbolt 3 support on some machines.
> > 
> > I'd like to see this tested on a wide range of amd64 hardware, but
> > especially on laptops.  Please reply with a diff of your dmesg before
> > and after.  Make sure you run make config before building a new kernel.
> 
> Tested with ThinkPad X1 Carbon 6th Gen under OpenBSD/amd64-current.  It
> is tested with Thunderbold 3 enabled in BIOS.

Bingo!

Just to be sure, both dmesg's were made with the same BIOS
configuration and no devices connected to Thunderbolt 3 at boot?

> --- dmesg.boot_before_nohack  Tue Oct 23 18:00:39 2018
> +++ dmesg.boot_after_nohack   Tue Oct 23 16:43:35 2018
> @@ -1,7 +1,7 @@
> -OpenBSD 6.4-current (GENERIC.MP) #22: Tue Oct 23 15:04:51 CEST 2018
> +OpenBSD 6.4-current (GENERIC.MP) #23: Tue Oct 23 15:16:49 CEST 2018
>  you...@fabien.klemkow.net:/sys/arch/amd64/compile/GENERIC.MP
>  real mem = 8451149824 (8059MB)
> -avail mem = 8185745408 (7806MB)
> +avail mem = 8185741312 (7806MB)
>  mpath0 at root
>  scsibus0 at mpath0: 256 targets
>  mainbus0 at root
> @@ -16,7 +16,7 @@
>  acpihpet0 at acpi0: 2399 Hz
>  acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
>  cpu0 at mainbus0: apid 0 (boot processor)
> -cpu0: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1394.63 MHz, 06-8e-09
> +cpu0: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1397.33 MHz, 06-8e-09
>  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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
>  cpu0: 256KB 64b/line 8-way L2 cache
>  cpu0: smt 0, core 0, package 0
> @@ -24,7 +24,7 @@
>  cpu0: apic clock running at 23MHz
>  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-7300U CPU @ 2.60GHz, 1158.97 MHz, 06-8e-09
> +cpu1: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1144.60 MHz, 06-8e-09
>  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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
>  cpu1: 256KB 64b/line 8-way L2 cache
>  cpu1: smt 0, core 1, package 0
> @@ -74,6 +74,7 @@
>  acpipwrres0 at acpi0: PUBS, resource for XHC_
>  acpipwrres1 at acpi0: PXP_, resource for RP09
>  acpitz0 at acpi0: critical temperature is 128 degC
> +acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001
>  acpithinkpad0 at acpi0
>  acpiac0 at acpi0: AC unit online
>  acpibat0 at acpi0: BAT0 model "01AV430" serial   585 type LiP oem "SMP"
> @@ -91,7 +92,7 @@
>  "USBC000" at acpi0 not configured
>  acpivideo0 at acpi0: GFX0
>  acpivout at acpivideo0 not configured
> -cpu0: Enhanced SpeedStep 1394 MHz: speeds: 2601, 2600, 2500, 2400, 2200, 
> 2000, 1900, 1700, 1500, 1400, 1200, 1100, 800, 700, 600, 400 MHz
> +cpu0: Enhanced SpeedStep 1397 MHz: speeds: 2601, 2600, 2500, 2400, 2200, 
> 2000, 1900, 1700, 1500, 1400, 1200, 1100, 800, 700, 600, 400 MHz
>  pci0 at mainbus0 bus 0
>  pchb0 at pci0 dev 0 function 0 "Intel Core 7G Host" rev 0x02
>  inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 620" rev 0x02
> @@ -122,6 +123,20 @@
>  sd0: 244198MB, 512 bytes/sector, 500118192 sectors
>  ppb2 at pci0 dev 29 function 0 "Intel 100 Series PCIE" rev 0xf1: msi
>  pci3 at ppb2 bus 5
> +ppb3 at pci3 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02
> +pci4 at ppb3 bus 6
> +ppb4 at pci4 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi
> +pci5 at ppb4 bus 7
> +"Intel JHL6540 Thunderbolt" rev 0x02 at pci5 dev 0 function 0 not configured
> +ppb5 at pci4 dev 1 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi
> +pci6 at ppb5 bus 8
> +ppb6 at pci4 dev 2 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi
> +pci7 at ppb6 bus 59
> +xhci1 at pci7 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi, 
> xHCI 1.16
> +usb1 at xhci1: USB revision 3.0
> +uhub1 at usb1 configuration 1 interface 

Re: Add acpipci(4) on amd64

2018-10-23 Thread Jan Klemkow
Hi Mark,

On Mon, Oct 22, 2018 at 09:45:06PM +0200, Mark Kettenis wrote:
> Diff below adds an acpipci(4) driver on amd64.  For now the main
> purpose of this driver is to make the PCI-specific _OSC calls to
> advertise the functionality we support.  Most notably this advertises
> support for PCIE native hotplug as we have some indications that this
> will help Thunderbolt 3 support on some machines.
> 
> I'd like to see this tested on a wide range of amd64 hardware, but
> especially on laptops.  Please reply with a diff of your dmesg before
> and after.  Make sure you run make config before building a new kernel.

Tested with ThinkPad X1 Carbon 6th Gen under OpenBSD/amd64-current.  It
is tested with Thunderbold 3 enabled in BIOS.

Bye,
Jan

--- dmesg.boot_before_nohackTue Oct 23 18:00:39 2018
+++ dmesg.boot_after_nohack Tue Oct 23 16:43:35 2018
@@ -1,7 +1,7 @@
-OpenBSD 6.4-current (GENERIC.MP) #22: Tue Oct 23 15:04:51 CEST 2018
+OpenBSD 6.4-current (GENERIC.MP) #23: Tue Oct 23 15:16:49 CEST 2018
 you...@fabien.klemkow.net:/sys/arch/amd64/compile/GENERIC.MP
 real mem = 8451149824 (8059MB)
-avail mem = 8185745408 (7806MB)
+avail mem = 8185741312 (7806MB)
 mpath0 at root
 scsibus0 at mpath0: 256 targets
 mainbus0 at root
@@ -16,7 +16,7 @@
 acpihpet0 at acpi0: 2399 Hz
 acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
 cpu0 at mainbus0: apid 0 (boot processor)
-cpu0: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1394.63 MHz, 06-8e-09
+cpu0: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1397.33 MHz, 06-8e-09
 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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
 cpu0: 256KB 64b/line 8-way L2 cache
 cpu0: smt 0, core 0, package 0
@@ -24,7 +24,7 @@
 cpu0: apic clock running at 23MHz
 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-7300U CPU @ 2.60GHz, 1158.97 MHz, 06-8e-09
+cpu1: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz, 1144.60 MHz, 06-8e-09
 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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
 cpu1: 256KB 64b/line 8-way L2 cache
 cpu1: smt 0, core 1, package 0
@@ -74,6 +74,7 @@
 acpipwrres0 at acpi0: PUBS, resource for XHC_
 acpipwrres1 at acpi0: PXP_, resource for RP09
 acpitz0 at acpi0: critical temperature is 128 degC
+acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001
 acpithinkpad0 at acpi0
 acpiac0 at acpi0: AC unit online
 acpibat0 at acpi0: BAT0 model "01AV430" serial   585 type LiP oem "SMP"
@@ -91,7 +92,7 @@
 "USBC000" at acpi0 not configured
 acpivideo0 at acpi0: GFX0
 acpivout at acpivideo0 not configured
-cpu0: Enhanced SpeedStep 1394 MHz: speeds: 2601, 2600, 2500, 2400, 2200, 2000, 
1900, 1700, 1500, 1400, 1200, 1100, 800, 700, 600, 400 MHz
+cpu0: Enhanced SpeedStep 1397 MHz: speeds: 2601, 2600, 2500, 2400, 2200, 2000, 
1900, 1700, 1500, 1400, 1200, 1100, 800, 700, 600, 400 MHz
 pci0 at mainbus0 bus 0
 pchb0 at pci0 dev 0 function 0 "Intel Core 7G Host" rev 0x02
 inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 620" rev 0x02
@@ -122,6 +123,20 @@
 sd0: 244198MB, 512 bytes/sector, 500118192 sectors
 ppb2 at pci0 dev 29 function 0 "Intel 100 Series PCIE" rev 0xf1: msi
 pci3 at ppb2 bus 5
+ppb3 at pci3 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02
+pci4 at ppb3 bus 6
+ppb4 at pci4 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi
+pci5 at ppb4 bus 7
+"Intel JHL6540 Thunderbolt" rev 0x02 at pci5 dev 0 function 0 not configured
+ppb5 at pci4 dev 1 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi
+pci6 at ppb5 bus 8
+ppb6 at pci4 dev 2 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi
+pci7 at ppb6 bus 59
+xhci1 at pci7 dev 0 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi, xHCI 
1.16
+usb1 at xhci1: USB revision 3.0
+uhub1 at usb1 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 
addr 1
+ppb7 at pci4 dev 4 function 0 "Intel JHL6540 Thunderbolt" rev 0x02: msi
+pci8 at ppb7 bus 60
 pcib0 at pci0 dev 31 function 0 "Intel 200 Series LPC" rev 0x21
 "Intel 100 Series PMC" rev 0x21 at pci0 dev 31 function 2 not configured
 azalia0 at pci0 dev 31 function 3 "Intel 200 Series HD Audio" rev 

Re: Add acpipci(4) on amd64

2018-10-23 Thread Mike Larkin
On Mon, Oct 22, 2018 at 09:45:06PM +0200, Mark Kettenis wrote:
> Diff below adds an acpipci(4) driver on amd64.  For now the main
> purpose of this driver is to make the PCI-specific _OSC calls to
> advertise the functionality we support.  Most notably this advertises
> support for PCIE native hotplug as we have some indications that this
> will help Thunderbolt 3 support on some machines.
> 
> I'd like to see this tested on a wide range of amd64 hardware, but
> especially on laptops.  Please reply with a diff of your dmesg before
> and after.  Make sure you run make config before building a new kernel.
> 
> Thanks,
> 
> Mark

acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001


... was added to dmesg on my x230. Everything appears to work.

-ml



Re: Add acpipci(4) on amd64

2018-10-23 Thread Eric Augé
Hello

I just adapted the patch for 6.4 stable (for small failed hunks) and
recompiled/rebooted the kernel.
Thinkpad X1 Carbon 5th Gen, same changes in dmesg as phessler :
...
+acpipci0 at acpi0 PCI0: 0x0010 0x0011 0x
...
(let me know if you want both as they're the same as his laptop output)

tried usb-c yubikey and usb-c harddrive, nothing happens, no new
devices, no power to the device

HTH,
Eric.
On Tue, Oct 23, 2018 at 1:11 PM Peter Hessler  wrote:
>
> On 2018 Oct 22 (Mon) at 21:45:06 +0200 (+0200), Mark Kettenis wrote:
> :Diff below adds an acpipci(4) driver on amd64.  For now the main
> :purpose of this driver is to make the PCI-specific _OSC calls to
> :advertise the functionality we support.  Most notably this advertises
> :support for PCIE native hotplug as we have some indications that this
> :will help Thunderbolt 3 support on some machines.
> :
> :I'd like to see this tested on a wide range of amd64 hardware, but
> :especially on laptops.  Please reply with a diff of your dmesg before
> :and after.  Make sure you run make config before building a new kernel.
> :
> :Thanks,
> :
> :Mark
> :
>
> Tested on Thinkpad X1 Carbon 5th Gen.  No explosions yet, but I don't
> have any usb-c devices to try against it.
>
> Diff is:
>
> --- dmesg.boot  Tue Oct 23 12:57:31 2018
> +++ dmesg.acpipci   Tue Oct 23 12:57:30 2018
> @@ -1,7 +1,7 @@
> -OpenBSD 6.4-current (GENERIC.MP) #0: Tue Oct 23 10:18:36 CEST 2018
> +OpenBSD 6.4-current (GENERIC.MP) #1: Tue Oct 23 12:14:06 CEST 2018
>  phess...@gwen.theapt.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>  real mem = 8446648320 (8055MB)
> -avail mem = 8181391360 (7802MB)
> +avail mem = 8181379072 (7802MB)
>  mpath0 at root
>  scsibus0 at mpath0: 256 targets
>  mainbus0 at root
> @@ -16,7 +16,7 @@ acpitimer0 at acpi0: 3579545 Hz, 24 bits
>  acpihpet0 at acpi0: 2399 Hz
>  acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
>  cpu0 at mainbus0: apid 0 (boot processor)
> -cpu0: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 1197.70 MHz, 06-4e-03
> +cpu0: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 1197.52 MHz, 06-4e-03
>  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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
>  cpu0: 256KB 64b/line 8-way L2 cache
>  cpu0: smt 0, core 0, package 0
> @@ -24,7 +24,7 @@ mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixe
>  cpu0: apic clock running at 23MHz
>  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-6300U CPU @ 2.40GHz, 963.35 MHz, 06-4e-03
> +cpu1: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 971.76 MHz, 06-4e-03
>  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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
>  cpu1: 256KB 64b/line 8-way L2 cache
>  cpu1: smt 0, core 1, package 0
> @@ -75,8 +75,9 @@ acpipwrres0 at acpi0: PUBS, resource for XHC_
>  acpipwrres1 at acpi0: WRST
>  acpipwrres2 at acpi0: WRST
>  acpitz0 at acpi0: critical temperature is 128 degC
> +acpipci0 at acpi0 PCI0: 0x0010 0x0011 0x
>  acpithinkpad0 at acpi0
> -acpiac0 at acpi0: AC unit offline
> +acpiac0 at acpi0: AC unit online
>  acpibat0 at acpi0: BAT0 model "01AV430" serial  1267 type LiP oem "SMP"
>  acpicmos0 at acpi0
>  "ALPS" at acpi0 not configured
>
>
> Full dmesg is:
>
> OpenBSD 6.4-current (GENERIC.MP) #1: Tue Oct 23 12:14:06 CEST 2018
> phess...@gwen.theapt.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> real mem = 8446648320 (8055MB)
> avail mem = 8181379072 (7802MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xca6bb000 (62 entries)
> bios0: vendor LENOVO version "N1MET49W (1.34 )" date 07/02/2018
> bios0: LENOVO 20K4002VGE
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S3 S4 S5
> acpi0: tables DSDT FACP SSDT TPM2 UEFI SSDT SSDT HPET APIC MCFG ECDT SSDT 
> BOOT BATB SLIC SSDT SSDT SSDT WSMT SSDT SSDT DBGP DBG2 MSDM DMAR ASF! FPDT 
> UEFI
> acpi0: wakeup devices GLAN(S4) XHC_(S3) XDCI(S4) HDAS(S4) RP01(S4) RP02(S4) 
> RP04(S4) RP05(S4) RP06(S4) RP07(S4) RP08(S4) RP09(S4) RP10(S4) RP11(S4) 
> RP12(S4) RP13(S4) [...]
> acpitimer0 at acpi0: 3579545 Hz, 

Re: Add acpipci(4) on amd64

2018-10-23 Thread Peter Hessler
On 2018 Oct 22 (Mon) at 21:45:06 +0200 (+0200), Mark Kettenis wrote:
:Diff below adds an acpipci(4) driver on amd64.  For now the main
:purpose of this driver is to make the PCI-specific _OSC calls to
:advertise the functionality we support.  Most notably this advertises
:support for PCIE native hotplug as we have some indications that this
:will help Thunderbolt 3 support on some machines.
:
:I'd like to see this tested on a wide range of amd64 hardware, but
:especially on laptops.  Please reply with a diff of your dmesg before
:and after.  Make sure you run make config before building a new kernel.
:
:Thanks,
:
:Mark
:

Tested on Thinkpad X1 Carbon 5th Gen.  No explosions yet, but I don't
have any usb-c devices to try against it.

Diff is:

--- dmesg.boot  Tue Oct 23 12:57:31 2018
+++ dmesg.acpipci   Tue Oct 23 12:57:30 2018
@@ -1,7 +1,7 @@
-OpenBSD 6.4-current (GENERIC.MP) #0: Tue Oct 23 10:18:36 CEST 2018
+OpenBSD 6.4-current (GENERIC.MP) #1: Tue Oct 23 12:14:06 CEST 2018
 phess...@gwen.theapt.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
 real mem = 8446648320 (8055MB)
-avail mem = 8181391360 (7802MB)
+avail mem = 8181379072 (7802MB)
 mpath0 at root
 scsibus0 at mpath0: 256 targets
 mainbus0 at root
@@ -16,7 +16,7 @@ acpitimer0 at acpi0: 3579545 Hz, 24 bits
 acpihpet0 at acpi0: 2399 Hz
 acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
 cpu0 at mainbus0: apid 0 (boot processor)
-cpu0: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 1197.70 MHz, 06-4e-03
+cpu0: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 1197.52 MHz, 06-4e-03
 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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
 cpu0: 256KB 64b/line 8-way L2 cache
 cpu0: smt 0, core 0, package 0
@@ -24,7 +24,7 @@ mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixe
 cpu0: apic clock running at 23MHz
 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-6300U CPU @ 2.40GHz, 963.35 MHz, 06-4e-03
+cpu1: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 971.76 MHz, 06-4e-03
 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,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
 cpu1: 256KB 64b/line 8-way L2 cache
 cpu1: smt 0, core 1, package 0
@@ -75,8 +75,9 @@ acpipwrres0 at acpi0: PUBS, resource for XHC_
 acpipwrres1 at acpi0: WRST
 acpipwrres2 at acpi0: WRST
 acpitz0 at acpi0: critical temperature is 128 degC
+acpipci0 at acpi0 PCI0: 0x0010 0x0011 0x
 acpithinkpad0 at acpi0
-acpiac0 at acpi0: AC unit offline
+acpiac0 at acpi0: AC unit online
 acpibat0 at acpi0: BAT0 model "01AV430" serial  1267 type LiP oem "SMP"
 acpicmos0 at acpi0
 "ALPS" at acpi0 not configured


Full dmesg is:

OpenBSD 6.4-current (GENERIC.MP) #1: Tue Oct 23 12:14:06 CEST 2018
phess...@gwen.theapt.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8446648320 (8055MB)
avail mem = 8181379072 (7802MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xca6bb000 (62 entries)
bios0: vendor LENOVO version "N1MET49W (1.34 )" date 07/02/2018
bios0: LENOVO 20K4002VGE
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT TPM2 UEFI SSDT SSDT HPET APIC MCFG ECDT SSDT BOOT 
BATB SLIC SSDT SSDT SSDT WSMT SSDT SSDT DBGP DBG2 MSDM DMAR ASF! FPDT UEFI
acpi0: wakeup devices GLAN(S4) XHC_(S3) XDCI(S4) HDAS(S4) RP01(S4) RP02(S4) 
RP04(S4) RP05(S4) RP06(S4) RP07(S4) RP08(S4) RP09(S4) RP10(S4) RP11(S4) 
RP12(S4) RP13(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 2399 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 1197.52 MHz, 06-4e-03
cpu0: 

Add acpipci(4) on amd64

2018-10-22 Thread Mark Kettenis
Diff below adds an acpipci(4) driver on amd64.  For now the main
purpose of this driver is to make the PCI-specific _OSC calls to
advertise the functionality we support.  Most notably this advertises
support for PCIE native hotplug as we have some indications that this
will help Thunderbolt 3 support on some machines.

I'd like to see this tested on a wide range of amd64 hardware, but
especially on laptops.  Please reply with a diff of your dmesg before
and after.  Make sure you run make config before building a new kernel.

Thanks,

Mark


Index: arch/amd64/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.463
diff -u -p -r1.463 GENERIC
--- arch/amd64/conf/GENERIC 31 Aug 2018 00:09:13 -  1.463
+++ arch/amd64/conf/GENERIC 22 Oct 2018 19:23:00 -
@@ -47,6 +47,7 @@ acpicpu*  at acpi?
 acpicmos*  at acpi?
 acpidock*  at acpi?
 acpiec*at acpi?
+acpipci*   at acpi?
 acpiprt*   at acpi?
 acpisbs*   at acpi?
 acpitz*at acpi?
Index: arch/amd64/conf/files.amd64
===
RCS file: /cvs/src/sys/arch/amd64/conf/files.amd64,v
retrieving revision 1.100
diff -u -p -r1.100 files.amd64
--- arch/amd64/conf/files.amd64 21 Aug 2018 18:06:12 -  1.100
+++ arch/amd64/conf/files.amd64 22 Oct 2018 19:23:00 -
@@ -236,6 +236,10 @@ attach acpi at bios
 file   arch/amd64/amd64/acpi_machdep.c acpi
 file   arch/amd64/amd64/acpi_wakecode.Sacpi & !small_kernel
 
+device acpipci
+attach acpipci at acpi
+file   arch/amd64/pci/acpipci.cacpipci
+
 #
 # VMM
 #
Index: arch/amd64/pci/acpipci.c
===
RCS file: arch/amd64/pci/acpipci.c
diff -N arch/amd64/pci/acpipci.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ arch/amd64/pci/acpipci.c22 Oct 2018 19:23:00 -
@@ -0,0 +1,133 @@
+/* $OpenBSD$   */
+/*
+ * Copyright (c) 2018 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/* 33DB4D5B-1FF7-401C-9657-7441C03DD766 */
+#define ACPI_PCI_UUID \
+  { 0x5b, 0x4d, 0xdb, 0x33, \
+0xf7, 0x1f, \
+0x1c, 0x40, \
+0x96, 0x57, \
+0x74, 0x41, 0xc0, 0x3d, 0xd7, 0x66 }
+
+/* Support field. */
+#define ACPI_PCI_PCIE_CONFIG   0x0001
+#define ACPI_PCI_ASPM  0x0002
+#define ACPI_PCI_CPMC  0x0004
+#define ACPI_PCI_SEGMENTS  0x0008
+#define ACPI_PCI_MSI   0x0010
+
+/* Control field. */
+#define ACPI_PCI_PCIE_HOTPLUG  0x0001
+
+struct acpipci_softc {
+   struct device   sc_dev;
+   struct acpi_softc *sc_acpi;
+   struct aml_node *sc_node;
+};
+
+intacpipci_match(struct device *, void *, void *);
+void   acpipci_attach(struct device *, struct device *, void *);
+
+struct cfattach acpipci_ca = {
+   sizeof(struct acpipci_softc), acpipci_match, acpipci_attach
+};
+
+struct cfdriver acpipci_cd = {
+   NULL, "acpipci", DV_DULL
+};
+
+const char *acpipci_hids[] = {
+   "PNP0A08",
+   "PNP0A03",
+   NULL
+};
+
+int
+acpipci_match(struct device *parent, void *match, void *aux)
+{
+   struct acpi_attach_args *aaa = aux;
+   struct cfdata *cf = match;
+
+   return acpi_matchhids(aaa, acpipci_hids, cf->cf_driver->cd_name);
+}
+
+void
+acpipci_attach(struct device *parent, struct device *self, void *aux)
+{
+   struct acpi_attach_args *aaa = aux;
+   struct acpipci_softc *sc = (struct acpipci_softc *)self;
+   struct aml_value args[4];
+   struct aml_value res;
+   static uint8_t uuid[16] = ACPI_PCI_UUID;
+   uint32_t buf[3];
+
+   sc->sc_acpi = (struct acpi_softc *)parent;
+   sc->sc_node = aaa->aaa_node;
+   printf(" %s", sc->sc_node->name);
+
+   memset(args, 0, sizeof(args));
+   args[0].type = AML_OBJTYPE_BUFFER;
+   args[0].v_buffer = uuid;
+   args[0].length = sizeof(uuid);
+   args[1].type = AML_OBJTYPE_INTEGER;
+   args[1].v_integer = 1;
+   args[2].type = AML_OBJTYPE_INTEGER;
+