Power down PCI devices in S0 as well. Needed for suspend-to-idle.
authorkettenis <kettenis@openbsd.org>
Sun, 2 Jun 2024 11:08:41 +0000 (11:08 +0000)
committerkettenis <kettenis@openbsd.org>
Sun, 2 Jun 2024 11:08:41 +0000 (11:08 +0000)
ok mglocker@

sys/dev/acpi/acpi.c
sys/dev/acpi/amltypes.h

index 71c30b5..09c4b56 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.429 2024/05/29 12:21:33 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.430 2024/06/02 11:08:41 kettenis Exp $ */
 /*
  * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
  * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -611,6 +611,10 @@ acpi_getpci(struct aml_node *node, void *arg)
                aml_nodename(node));
 
        /* Collect device power state information. */
+       if (aml_evalinteger(sc, node, "_S0W", 0, NULL, &val) == 0)
+               pci->_s0w = val;
+       else
+               pci->_s0w = -1;
        if (aml_evalinteger(sc, node, "_S3D", 0, NULL, &val) == 0)
                pci->_s3d = val;
        else
@@ -721,6 +725,10 @@ acpi_pci_min_powerstate(pci_chipset_tag_t pc, pcitag_t tag)
        TAILQ_FOREACH(pdev, &acpi_pcidevs, next) {
                if (pdev->bus == bus && pdev->dev == dev && pdev->fun == fun) {
                        switch (acpi_softc->sc_state) {
+                       case ACPI_STATE_S0:
+                               defaultstate = PCI_PMCSR_STATE_D3;
+                               state = pdev->_s0w;
+                               break;
                        case ACPI_STATE_S3:
                                defaultstate = PCI_PMCSR_STATE_D3;
                                state = MAX(pdev->_s3d, pdev->_s3w);
index 974a252..4c72f25 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: amltypes.h,v 1.49 2022/09/12 17:42:31 kettenis Exp $ */
+/* $OpenBSD: amltypes.h,v 1.50 2024/06/02 11:08:41 kettenis Exp $ */
 /*
  * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
  *
@@ -358,6 +358,7 @@ struct acpi_pci {
        int                             dev;
        int                             fun;
 
+       int                             _s0w;
        int                             _s3d;
        int                             _s3w;
        int                             _s4d;