From 50b7f1f524ca1e3b2e94cb06dbb10dad88e3a0f8 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sun, 2 Jun 2024 11:08:41 +0000 Subject: [PATCH] Power down PCI devices in S0 as well. Needed for suspend-to-idle. ok mglocker@ --- sys/dev/acpi/acpi.c | 10 +++++++++- sys/dev/acpi/amltypes.h | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 71c30b59a5b..09c4b56d3d4 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -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 * Copyright (c) 2005 Jordan Hargrave @@ -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); diff --git a/sys/dev/acpi/amltypes.h b/sys/dev/acpi/amltypes.h index 974a252f7c9..4c72f2517a6 100644 --- a/sys/dev/acpi/amltypes.h +++ b/sys/dev/acpi/amltypes.h @@ -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 * @@ -358,6 +358,7 @@ struct acpi_pci { int dev; int fun; + int _s0w; int _s3d; int _s3w; int _s4d; -- 2.20.1