If you have an msi laptop/desktop with failing acpi please test this
diff.  Only amd64 at this time.

I know, I know it is as ugly as ugly gets I just want to validate the
idea first.

Index: arch/amd64/include/smbiosvar.h
===================================================================
RCS file: /cvs/src/sys/arch/amd64/include/smbiosvar.h,v
retrieving revision 1.7
diff -u -p -r1.7 smbiosvar.h
--- arch/amd64/include/smbiosvar.h      15 Nov 2007 17:14:00 -0000      1.7
+++ arch/amd64/include/smbiosvar.h      31 Jul 2010 17:14:59 -0000
@@ -176,6 +176,28 @@ struct smbios_board {
        u_int8_t        noc;            /* number of contained objects */
 } __packed;
 
+struct smbios_enclosure {
+       u_int8_t        vendor;         /* string */
+       u_int8_t        type;
+       u_int8_t        version;        /* string */
+       u_int8_t        serial;         /* string */
+       u_int8_t        asset_tag;      /* string */
+       /* 2.1+ */
+       u_int8_t        boot_state;
+       u_int8_t        psu_state;
+       u_int8_t        thermal_state;
+       u_int8_t        security_status;
+       /* 2.3+ */
+       u_int16_t       oem_defined;
+       u_int8_t        height;
+       u_int8_t        no_power_cords;
+       u_int8_t        no_contained_element;
+       u_int8_t        reclen_contained_element;
+       u_int8_t        contained_elements;
+       /* 2.7+ */
+       u_int8_t        sku;            /* string */
+} __packed;
+
 /*
  * SMBIOS Structure Type 4 "processor Information"
  * DMTF Specification DSP0134 v2.5 Section 3.3.5 p.g. 24
Index: dev/acpi/acpiec.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpiec.c,v
retrieving revision 1.40
diff -u -p -r1.40 acpiec.c
--- dev/acpi/acpiec.c   29 Jul 2010 18:32:26 -0000      1.40
+++ dev/acpi/acpiec.c   31 Jul 2010 21:49:14 -0000
@@ -23,6 +23,7 @@
 #include <sys/malloc.h>
 
 #include <machine/bus.h>
+#include <machine/smbiosvar.h>
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
@@ -32,6 +33,8 @@
 
 #include <sys/sensors.h>
 
+#include "bios.h"
+
 int            acpiec_match(struct device *, void *, void *);
 void           acpiec_attach(struct device *, struct device *, void *);
 
@@ -91,7 +94,7 @@ const char *acpiec_hids[] = { ACPI_DEV_E
 void
 acpiec_wait(struct acpiec_softc *sc, u_int8_t mask, u_int8_t val)
 {
-       static int acpiecnowait;
+       static int              acpiecnowait;
        u_int8_t                stat;
 
        dnprintf(40, "%s: EC wait_ns for: %b == %02x\n",
@@ -101,7 +104,10 @@ acpiec_wait(struct acpiec_softc *sc, u_i
        while (((stat = acpiec_status(sc)) & mask) != val) {
                if (stat & EC_STAT_SCI_EVT)
                        sc->sc_gotsci = 1;
-               if (cold || (stat & EC_STAT_BURST))
+
+               if (sc->sc_msi)
+                       delay(550);
+               else if (cold || (stat & EC_STAT_BURST))
                        delay(1);
                else
                        tsleep(&acpiecnowait, PWAIT, "acpiec", 1);
@@ -263,6 +269,54 @@ acpiec_attach(struct device *parent, str
 {
        struct acpiec_softc     *sc = (struct acpiec_softc *)self;
        struct acpi_attach_args *aa = aux;
+
+#if NBIOS > 0
+       char                    scratch[64];
+       struct smbtable         tbl;
+       struct smbios_struct_bios *sb;
+       struct smbios_sys       *sys;
+       struct smbios_enclosure *enc;
+       /* XXX move this into tables */
+
+       bzero(&tbl, sizeof tbl);
+       if (smbios_find_table(SMBIOS_TYPE_BIOS, &tbl)) {
+               sb = tbl.tblhdr;
+               if ((smbios_get_string(&tbl, sb->vendor, scratch,
+                   sizeof(scratch))) != NULL) {
+                       if (!strcmp(scratch, "Micro-Star")) {
+                               sc->sc_msi = 1;
+                               dnprintf(1, "%s: quirked BIOS vendor %s",
+                                   DEVNAME(sc), scratch);
+                       }
+               }
+       }
+
+       bzero(&tbl, sizeof tbl);
+       if (smbios_find_table(SMBIOS_TYPE_SYSTEM, &tbl)) {
+               sys = tbl.tblhdr;
+               if ((smbios_get_string(&tbl, sys->vendor, scratch,
+                   sizeof(scratch))) != NULL) {
+                       if (!strcmp(scratch, "Micro-Star")) {
+                               sc->sc_msi = 1;
+                               dnprintf(1, "%s: quirked SYSTEM vendor %s",
+                                   DEVNAME(sc), scratch);
+                       }
+               }
+       }
+
+       bzero(&tbl, sizeof tbl);
+       if (smbios_find_table(SMBIOS_TYPE_ENCLOSURE, &tbl)) {
+               enc = tbl.tblhdr;
+               if ((smbios_get_string(&tbl, enc->vendor, scratch,
+                   sizeof(scratch))) != NULL) {
+                       if (!strcmp(scratch, "MICRO-Star")) {
+                               sc->sc_msi = 1;
+                               dnprintf(1, "%s: quirked ENCLOSURE vendor %s",
+                                   DEVNAME(sc), scratch);
+                       }
+               }
+       }
+#endif
 
        sc->sc_acpi = (struct acpi_softc *)parent;
        sc->sc_devnode = aa->aaa_node;

Reply via email to