Re: ACPI: (redux) Early acpiec initialization diff

2010-07-25 Thread Dawe
On Fri, 23 Jul 2010 23:53:50 -0600 (MDT)
Jordan Hargrave  wrote:

> Redux: this new version will apply with -current
> 
> This patch will allow acpiec to initialize earlier if a ECDT table is
> found.  This fixes a lockup if booting on some Thinkpads while docked.
>  
> You can tell if your system supports ECDT by scanning the ACPI tables
> line in dmesg.  There should be a line like this:
> acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT ASF! SSDT 
> SSDT SSDT SSDT
>  
> ECDT will be one of the entries if the early initialization is supported.
>  
> If scanning dmesg, acpiec0 will now also initialize earlier (near acpitimer
> and acpimadt) instead of after acpiprt. 
> 

I can't test with a docking station, otherwise it seems to work.
But this is already in the current snapshot, I think.
I patched my kernel anyway and yes, acpiec0 initializes earlier than
with older kernels.

OpenBSD 4.8-beta (GENERIC.MP) #1: Sun Jul 25 20:46:25 CEST 2010
r...@padtree.my.domain:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 1998045184 (1905MB)
avail mem = 1931018240 (1841MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.6 @ 0xe0010 (78 entries)
bios0: vendor LENOVO version "6IET65WW (1.25 )" date 06/07/2010
bios0: LENOVO 25184QG
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP SSDT ECDT APIC MCFG HPET ASF! SLIC BOOT SSDT TCPA SSDT 
SSDT SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) UART(S3) IGBE(S4) EXP1(S4) EXP2(S4) 
EXP3(S4) EXP4(S4) EXP5(S4) EHC1(S3) EHC2(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiec0 at acpi0
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5 CPU M 430 @ 2.27GHz, 2261.43 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,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,NXE,LONG
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: apic clock running at 133MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM) i5 CPU M 430 @ 2.27GHz, 2261.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,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,NXE,LONG
cpu1: 256KB 64b/line 8-way L2 cache
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i5 CPU M 430 @ 2.27GHz, 2261.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,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,NXE,LONG
cpu2: 256KB 64b/line 8-way L2 cache
cpu3 at mainbus0: apid 5 (application processor)
cpu3: Intel(R) Core(TM) i5 CPU M 430 @ 2.27GHz, 2261.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,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,NXE,LONG
cpu3: 256KB 64b/line 8-way L2 cache
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG_)
acpiprt2 at acpi0: bus 2 (EXP1)
acpiprt3 at acpi0: bus 3 (EXP2)
acpiprt4 at acpi0: bus -1 (EXP3)
acpiprt5 at acpi0: bus 5 (EXP4)
acpiprt6 at acpi0: bus 13 (EXP5)
acpicpu0 at acpi0: C3, C1, PSS
acpicpu1 at acpi0: C3, C1, PSS
acpicpu2 at acpi0: C3, C1, PSS
acpicpu3 at acpi0: C3, C1, PSS
acpipwrres0 at acpi0: PUBS
acpitz0 at acpi0: critical temperature 100 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 not present
acpibat1 at acpi0: BAT1 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
cpu0: Enhanced SpeedStep 2261 MHz: speeds: 2267, 2266, 2133, 1999, 1866, 1733, 
1599, 1466, 1333, 1199 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 vendor "Intel", unknown product 0x0044 rev 0x02
vga1 at pci0 dev 2 function 0 "Intel Mobile HD graphics" rev 0x02
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
intagp0 at vga1
agp0 at intagp0: aperture at 0xd000, size 0x1000
inteldrm0 at vga1: apic 1 int 16 (irq 11)
drm0 at inteldrm0
"Intel 3400 MEI" rev 0x06 at pci0 dev 22 function 0 not configured
em0 at pci0 dev 25 function 0 "Intel 82577LM" rev 0x06: apic 1 int 20 (irq 11), 
address 00:26:2d:fb:c7:02
ehci0 at pci0 dev 26 function 0 "Intel 3400 USB" rev 0x06: apic 1 int 23 (irq 
11)
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 3400 HD Audio" rev 0x06: apic 1 int 17 
(irq 11)
azalia0: codecs: Conexant/0x5069, Intel/0x2804, using Conexant/0x5069
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 3400 PCIE" rev 0x06: apic 1 int 20 (irq 
11)
pci1 at ppb0 bus 2
ppb1 at pci0 dev 28 function 1 "Intel 3400 PCIE" rev 

Re: ACPI: (redux) Early acpiec initialization diff

2010-07-24 Thread roberth
On Fri, 23 Jul 2010 23:53:50 -0600 (MDT)
Jordan Hargrave  wrote:

> Redux: this new version will apply with -current
> 
> This patch will allow acpiec to initialize earlier if a ECDT table is
> found.  This fixes a lockup if booting on some Thinkpads while docked.
>  
> You can tell if your system supports ECDT by scanning the ACPI tables
> line in dmesg.  There should be a line like this:
> acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT ASF!
> acpi0: SSDT SSDT SSDT SSDT
>  
> ECDT will be one of the entries if the early initialization is
> supported. 
> If scanning dmesg, acpiec0 will now also initialize earlier (near
> acpitimer and acpimadt) instead of after acpiprt. 

Thinkpad X200, amd64.mp,
bios0: vendor LENOVO version "6DET61WW (3.11 )" date 11/10/2009
bios0: LENOVO 74542GU

No docking station.
Nothing changed.

acpi0: tables DSDT FACP SSDT ECDT APIC MCFG HPET SLIC BOOT ASF! SSDT TCPA SSDT 
SSDT SSDT

acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus -1 (EXP2)
acpiprt5 at acpi0: bus 5 (EXP3)
acpiec0 at acpi0



ACPI: (redux) Early acpiec initialization diff

2010-07-23 Thread Jordan Hargrave
Redux: this new version will apply with -current

This patch will allow acpiec to initialize earlier if a ECDT table is
found.  This fixes a lockup if booting on some Thinkpads while docked.
 
You can tell if your system supports ECDT by scanning the ACPI tables
line in dmesg.  There should be a line like this:
acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT ASF! SSDT SSDT 
SSDT SSDT
 
ECDT will be one of the entries if the early initialization is supported.
 
If scanning dmesg, acpiec0 will now also initialize earlier (near acpitimer
and acpimadt) instead of after acpiprt. 

Index: acpi.c
===
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.187
diff -u -p -u -p -b -r1.187 acpi.c
--- acpi.c  22 Jul 2010 14:19:47 -  1.187
+++ acpi.c  24 Jul 2010 05:52:03 -
@@ -2123,6 +2123,10 @@ acpi_foundec(struct aml_node *node, void
if (strcmp(dev, ACPI_DEV_ECD))
return 0;
 
+   /* Check if we're already attached */
+   if (sc->sc_ec && sc->sc_ec->sc_devnode == node->parent)
+   return 0;
+
memset(&aaa, 0, sizeof(aaa));
aaa.aaa_iot = sc->sc_iot;
aaa.aaa_memt = sc->sc_memt;
Index: acpiec.c
===
RCS file: /cvs/src/sys/dev/acpi/acpiec.c,v
retrieving revision 1.34
diff -u -p -u -p -b -r1.34 acpiec.c
--- acpiec.c23 Jul 2010 20:21:58 -  1.34
+++ acpiec.c24 Jul 2010 05:52:04 -
@@ -245,6 +245,11 @@ acpiec_match(struct device *parent, void
 {
struct acpi_attach_args *aa = aux;
struct cfdata   *cf = match;
+   struct acpi_ecdt*ecdt = aa->aaa_table;
+
+   /* Check for early ECDT table attach */
+   if (ecdt && !memcmp(ecdt->hdr.signature, ECDT_SIG, sizeof(ECDT_SIG) - 
1))
+   return (1);
 
/* sanity */
return (acpi_matchhids(aa, acpiec_hids, cf->cf_driver->cd_name));
@@ -384,6 +389,25 @@ acpiec_getcrs(struct acpiec_softc *sc, s
char*buf;
int size, ret;
int64_t gpe;
+   struct acpi_ecdt*ecdt = aa->aaa_table;
+   extern struct aml_node   aml_root;
+
+   /* Check if this is ECDT initialization */
+   if (ecdt) {
+   /* Get GPE, Data and Control segments */
+   sc->sc_gpe = ecdt->gpe_bit;
+
+   ctype = ecdt->ec_control.address_space_id;
+   ec_sc = ecdt->ec_control.address;
+
+   dtype = ecdt->ec_data.address_space_id;
+   ec_data = ecdt->ec_data.address;
+
+   /* Get devnode from header */
+   sc->sc_devnode = aml_searchname(&aml_root, ecdt->ec_id);
+
+   goto ecdtdone;
+   }
 
if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "_GPE", 0, NULL, 
&gpe)) {
dnprintf(10, "%s: no _GPE\n", DEVNAME(sc));
@@ -439,6 +463,7 @@ acpiec_getcrs(struct acpiec_softc *sc, s
aml_freevalue(&res);
 
/* XXX: todo - validate _CRS checksum? */
+ecdtdone:
 
dnprintf(10, "%s: Data: 0x%x, S/C: 0x%x\n",
DEVNAME(sc), ec_data, ec_sc);