If FADT indicates FADT_POWER_S0_IDLE_CAPABLE, print "S0ix" instead
authorderaadt <deraadt@openbsd.org>
Sun, 18 Aug 2024 02:53:08 +0000 (02:53 +0000)
committerderaadt <deraadt@openbsd.org>
Sun, 18 Aug 2024 02:53:08 +0000 (02:53 +0000)
of "S0" on the acpi: sleep states line.  (In my view, this flag-bit
announces that the hardware vendor + bios vendor + microsoft have agreed
this machine has enough "features" that S0 suspend is about as good or
better than S3, for various criteria).
ok kettenis mlarkin

sys/dev/acpi/acpi.c

index de66b0a..5da2524 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.437 2024/08/10 23:28:17 deraadt Exp $ */
+/* $OpenBSD: acpi.c,v 1.438 2024/08/18 02:53:08 deraadt Exp $ */
 /*
  * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
  * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -2502,16 +2502,19 @@ acpi_init_states(struct acpi_softc *sc)
                snprintf(name, sizeof(name), "_S%d_", i);
                sc->sc_sleeptype[i].slp_typa = -1;
                sc->sc_sleeptype[i].slp_typb = -1;
-               if (aml_evalname(sc, sc->sc_root, name, 0, NULL, &res) == 0) {
-                       if (res.type == AML_OBJTYPE_PACKAGE) {
-                               sc->sc_sleeptype[i].slp_typa =
-                                   aml_val2int(res.v_package[0]);
-                               sc->sc_sleeptype[i].slp_typb =
-                                   aml_val2int(res.v_package[1]);
-                               printf(" S%d", i);
-                       }
+               if (aml_evalname(sc, sc->sc_root, name, 0, NULL, &res) != 0)
+                       continue;
+               if (res.type != AML_OBJTYPE_PACKAGE) {
                        aml_freevalue(&res);
+                       continue;
                }
+               sc->sc_sleeptype[i].slp_typa = aml_val2int(res.v_package[0]);
+               sc->sc_sleeptype[i].slp_typb = aml_val2int(res.v_package[1]);
+               aml_freevalue(&res);
+
+               printf(" S%d", i);
+               if (i == 0 && (sc->sc_fadt->flags & FADT_POWER_S0_IDLE_CAPABLE))
+                       printf("ix");
        }
 }