From nobody Wed Jun 17 07:20:40 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B04F93659F7; Mon, 27 Apr 2026 03:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262027; cv=none; b=P3lnWmXiwSoYs62YexCsQYVuu6tHvzP5g9zI0C7Xn1rLSIsq9w8ZjjS8MxQRGhcOOK2kkDs33VZTUCYfk820X533W7rKbc/bo7NjdEV9gANrw46Hokt6fF9iOowue0bx15pS206j0d72rw4n+YZ8l85yaEuexlNhLbB3fJKL5ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262027; c=relaxed/simple; bh=wzBG0w2sgd6l6ANTHLzOSqnr9bLkcENBQXCiLA4GCiE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VwDkI+HnLRqP73AaEOHleBJ8q3vwY+uHiQuO4rF6BK8fAj4A/qJQdl6KjVXFaenfVoqetR1gtXc4gY+Mzz3ex3JdDmVCxRH50TMuHBQembTwk/VBrnNHcFOievRg1Wq+IK2SDCkhD9tFxKQ8NirP3azhn2W1n6uMAcf34FdfFG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AjV3TWEg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AjV3TWEg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC947C2BCB7; Mon, 27 Apr 2026 03:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777262027; bh=wzBG0w2sgd6l6ANTHLzOSqnr9bLkcENBQXCiLA4GCiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AjV3TWEgFWFKkvt5KhYBneIWX5gsLvn97BcAIM/ez88yZ4ImhhjahBwjNPKXN3kdb s3IlkDweSidUY/fZ65F00KlIyJ4JMYmYbW0+xeSc83PMzq11pvKig2ZjsGV555AL2g 9yva1T8xPSO6Ql9WM91hSgjLXmhEka7g2N9UGYBxt2qy4qoVWdN6Y7FHG9Sjt3vWOZ Mhxd59gjRxt9VTE3z3MLfYCDOPm2kt5ajC2da4gYvVw0NMADX7w5V0RslZhoC5j5dy Ga6QRpbfq/WXNCijtcU0/ZwI56JOKVQ7Osns3V63qdRQXjRkGvOZOp2mvShF5oqpc3 hw3gJJXM8QuZQ== From: "Mario Limonciello (AMD)" To: Bjorn Helgaas , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM) Cc: linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list), "Rafael J . Wysocki" , Lukas Wunner , "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH 1/5] PCI/PM: Disable device wakeups when halting or powering off system Date: Sun, 26 Apr 2026 22:53:37 -0500 Message-ID: <20260427035341.1425576-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260427035341.1425576-1-superm1@kernel.org> References: <20260427035341.1425576-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" PCI devices can be configured as wakeup sources from low power states. However, when the system is powering off such wakeups are not expected and may lead to spurious behavior. ACPI r6.5, section 16.1.5 notes: "Hardware does allow a transition to S0 due to power button press or a Remote Start." This implies that wakeups from PCI devices should not be relied upon in these states. To align with this expectation and avoid unintended wakeups, disable device wakeup capability during these transitions. Tested-by: Eric Naim Signed-off-by: Mario Limonciello (AMD) --- drivers/pci/pci-driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 2bfefd8db5260..a43ee7bbfb3f5 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1166,6 +1166,9 @@ static int pci_pm_poweroff(struct device *dev) struct pci_dev *pci_dev =3D to_pci_dev(dev); const struct dev_pm_ops *pm =3D dev->driver ? dev->driver->pm : NULL; =20 + if (device_may_wakeup(dev) && system_state =3D=3D SYSTEM_POWER_OFF) + device_set_wakeup_enable(dev, false); + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend(dev, PMSG_HIBERNATE); =20 --=20 2.43.0 From nobody Wed Jun 17 07:20:40 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9511836BCED; Mon, 27 Apr 2026 03:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262028; cv=none; b=XAjUBbWixJsBDCtQcDx64goyrDY3xj+OmcT1C+FgJtB4v8Sjju1I3z1o7yHAAUgWirerTGtzefyjyb5zW/ew5ZiGlQnBSyxo4fEtQVA/+k6AsZXU1OmPegxAfhqtcJRY+7XDNCatTEb5x0pbq2oj3MuvykGRlUADwK+LsdbMfWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262028; c=relaxed/simple; bh=y9lTOCLHLo2JLs/Ccj8IJcEeaNjA1o66+3L4hubTkuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NESIFVUdkBUDRZXUjRuOQaEPirNyyfIHXWbuIt55vpesxwJ4lFqDHDnJKsDU/G6VwooCqjPwX/ePKsBL3DB5xWhMPhe0w4bxs4wpAlRu9xntHwBrwz5HCb5pZebF5Ckurw35IAhlrJQoSogy+V94Od4ErsDMZzMPrZi5A3c0Ml0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iIGg2Sut; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iIGg2Sut" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C255DC19425; Mon, 27 Apr 2026 03:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777262028; bh=y9lTOCLHLo2JLs/Ccj8IJcEeaNjA1o66+3L4hubTkuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iIGg2SutsfGar2eR0trwg7Chl+tDY5tPxtBkRB4jXu2GXcSSf7+mM+lxLKKf8YbvL OGSITi9ZCRh2MdAnGqtTaz2UMkT4YSNQ9UWSoP/oWJ5aETHdP5CK3BMTNabW9pdwYZ ikhGRgW0hqNZcuoSNIcF1ikb3+lHQfHJ0m4YvzzAOLHRR6q8RGPELFMdT2tmv30dBu mXRnnpcd6CbvBsJwIVpT41mu8RnQHOvhzu/4iLMlEnHsD0R95fjraXxhLLlDYd1k3K r1xOlnIaaiIis7ZaVBkrfEI1s0dCrd9LX/WcDCEjsNgIk8f3oOolHGco3WPj1cwgtn 03NKv422300Mw== From: "Mario Limonciello (AMD)" To: Bjorn Helgaas , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM) Cc: linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list), "Rafael J . Wysocki" , Lukas Wunner , "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH 2/5] PCI/PM: Split out code from pci_pm_suspend_noirq() into helper Date: Sun, 26 Apr 2026 22:53:38 -0500 Message-ID: <20260427035341.1425576-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260427035341.1425576-1-superm1@kernel.org> References: <20260427035341.1425576-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In order to unify suspend and hibernate codepaths without code duplication the common code should be in common helpers. Move it from pci_pm_suspend_noirq() into a helper. No intended functional changes. Tested-by: Eric Naim Signed-off-by: Mario Limonciello (AMD) --- drivers/pci/pci-driver.c | 86 +++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index a43ee7bbfb3f5..bfb521eb0eed7 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -788,6 +788,54 @@ static void pci_pm_complete(struct device *dev) =20 #endif /* !CONFIG_PM_SLEEP */ =20 +#if defined(CONFIG_SUSPEND) +/** + * pci_pm_suspend_noirq_common + * @pci_dev: pci device + * @skip_bus_pm: pointer to a boolean indicating whether to skip bus PM + * + * Prepare the device to go into a low power state by saving state and + * deciding whether to skip bus PM. + * + */ +static void pci_pm_suspend_noirq_common(struct pci_dev *pci_dev, bool *ski= p_bus_pm) +{ + if (!pci_dev->state_saved) { + pci_save_state(pci_dev); + + /* + * If the device is a bridge with a child in D0 below it, + * it needs to stay in D0, so check skip_bus_pm to avoid + * putting it into a low-power state in that case. + */ + if (!pci_dev->skip_bus_pm && pci_power_manageable(pci_dev)) + pci_prepare_to_sleep(pci_dev); + } + + pci_dbg(pci_dev, "PCI PM: Sleep power state: %s\n", + pci_power_name(pci_dev->current_state)); + + if (pci_dev->current_state =3D=3D PCI_D0) { + pci_dev->skip_bus_pm =3D true; + /* + * Per PCI PM r1.2, table 6-1, a bridge must be in D0 if any + * downstream device is in D0, so avoid changing the power state + * of the parent bridge by setting the skip_bus_pm flag for it. + */ + if (pci_dev->bus->self) + pci_dev->bus->self->skip_bus_pm =3D true; + } + + if (pci_dev->skip_bus_pm && pm_suspend_no_platform()) { + pci_dbg(pci_dev, "PCI PM: Skipped\n"); + *skip_bus_pm =3D true; + return; + } + + pci_pm_set_unknown_state(pci_dev); +} +#endif /* CONFIG_SUSPEND */ + #ifdef CONFIG_SUSPEND static void pcie_pme_root_status_cleanup(struct pci_dev *pci_dev) { @@ -877,6 +925,7 @@ static int pci_pm_suspend_noirq(struct device *dev) { struct pci_dev *pci_dev =3D to_pci_dev(dev); const struct dev_pm_ops *pm =3D dev->driver ? dev->driver->pm : NULL; + bool skip_bus_pm =3D false; =20 if (dev_pm_skip_suspend(dev)) return 0; @@ -886,7 +935,8 @@ static int pci_pm_suspend_noirq(struct device *dev) =20 if (!pm) { pci_save_state(pci_dev); - goto set_unknown; + pci_pm_set_unknown_state(pci_dev); + goto Ehci_workaround; } =20 if (pm->suspend_noirq) { @@ -907,40 +957,12 @@ static int pci_pm_suspend_noirq(struct device *dev) } } =20 - if (!pci_dev->state_saved) { - pci_save_state(pci_dev); - - /* - * If the device is a bridge with a child in D0 below it, - * it needs to stay in D0, so check skip_bus_pm to avoid - * putting it into a low-power state in that case. - */ - if (!pci_dev->skip_bus_pm && pci_power_manageable(pci_dev)) - pci_prepare_to_sleep(pci_dev); - } - - pci_dbg(pci_dev, "PCI PM: Suspend power state: %s\n", - pci_power_name(pci_dev->current_state)); + pci_pm_suspend_noirq_common(pci_dev, &skip_bus_pm); =20 - if (pci_dev->current_state =3D=3D PCI_D0) { - pci_dev->skip_bus_pm =3D true; - /* - * Per PCI PM r1.2, table 6-1, a bridge must be in D0 if any - * downstream device is in D0, so avoid changing the power state - * of the parent bridge by setting the skip_bus_pm flag for it. - */ - if (pci_dev->bus->self) - pci_dev->bus->self->skip_bus_pm =3D true; - } - - if (pci_dev->skip_bus_pm && pm_suspend_no_platform()) { - pci_dbg(pci_dev, "PCI PM: Skipped\n"); + if (skip_bus_pm) goto Fixup; - } - -set_unknown: - pci_pm_set_unknown_state(pci_dev); =20 +Ehci_workaround: /* * Some BIOSes from ASUS have a bug: If a USB EHCI host controller's * PCI COMMAND register isn't 0, the BIOS assumes that the controller --=20 2.43.0 From nobody Wed Jun 17 07:20:40 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82FC536F405; Mon, 27 Apr 2026 03:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262029; cv=none; b=LnuwxK6nXHzFiIF2XDbSfw+miJF1Q+D5h40Zf+ZcPdjCi5OAh7Krb1V0uif8NDgE8SVj9GNwlr+Uj1bdqYYo5P8Opm/RSDT6AhxsE+s56C2jgnSyUx2ie7SNFQH2/QhdpRRx87YJewOd9Dau4Twux7hgoo2rrp+FdJbLZ+FFsmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262029; c=relaxed/simple; bh=jsEb1yLjA2XTL0QV8lS7eXoA5i4gmq03FD7bi6mGHC0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bsAOzZVFOXHubFLVG0Hl3iQXLrLst+qRi8H7tJ/9NW7R7PD+QC+IYFNvdyx7/EJPFdzk61WHKdQnlekT7DWbr1BUJoXR4ivnmgApRBXBUQxz8GoRv+yZr2cvqYClx5QiDkE/cQ3dqzKWlJvA2iDYH0+ipSgdgoWwW0zwrMhGcvY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AW7RDIri; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AW7RDIri" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B29E1C2BCB8; Mon, 27 Apr 2026 03:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777262029; bh=jsEb1yLjA2XTL0QV8lS7eXoA5i4gmq03FD7bi6mGHC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AW7RDIri5j6c1te6kR0SWB2Mqdw70uESFJPnqpN44RskdAaXg1lnYqrJjU0qLMVY4 Sh0vNRv8DT7EQX9MLmNhF0Tm+z0N7Bckjcbb0nzdu2+P7w9rkwSZiyQTJh98R2rLpI azJDQTX2DdDLw38kfF5o3iu7X1glsEC5FG3C+/RaYdU3RM+1G3HPabfzTkixl2NS2d MviLr0RmTGHT+HuP7xKK6KYtTdAQsa9ZczHJ/2aLmbNmNadalEu2UIf1Q/Vt54PC7V vQBp4F2CyepWQJ7g+d40P2LrXdd+fUZzIAeQnL+qbGhUt+mkb56pIpn0hajG68oAkD 7miqXPnAfLzJA== From: "Mario Limonciello (AMD)" To: Bjorn Helgaas , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM) Cc: linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list), "Rafael J . Wysocki" , Lukas Wunner , "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH 3/5] PCI/PM: Run bridge power up actions as part of restore phase Date: Sun, 26 Apr 2026 22:53:39 -0500 Message-ID: <20260427035341.1425576-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260427035341.1425576-1-superm1@kernel.org> References: <20260427035341.1425576-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Suspend resume actions will check the state of the device and whether bus PM should be skipped. These same actions make sense during hibernation image restore. Apply them there as well. Tested-by: Eric Naim Signed-off-by: Mario Limonciello (AMD) --- drivers/pci/pci-driver.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index bfb521eb0eed7..793af4af2971b 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1273,10 +1273,15 @@ static int pci_pm_restore_noirq(struct device *dev) { struct pci_dev *pci_dev =3D to_pci_dev(dev); const struct dev_pm_ops *pm =3D dev->driver ? dev->driver->pm : NULL; + pci_power_t prev_state =3D pci_dev->current_state; + bool skip_bus_pm =3D pci_dev->skip_bus_pm; =20 pci_pm_default_resume_early(pci_dev); pci_fixup_device(pci_fixup_resume_early, pci_dev); =20 + if (!skip_bus_pm && prev_state =3D=3D PCI_D3cold) + pci_pm_bridge_power_up_actions(pci_dev); + if (pci_has_legacy_pm_support(pci_dev)) return 0; =20 --=20 2.43.0 From nobody Wed Jun 17 07:20:40 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F663371890; Mon, 27 Apr 2026 03:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262030; cv=none; b=GA9LgxBzW/sE5Y8e7K6hpu7YI6xLjQbomm+iSgrlJIkClB/G+Xq0vGmdY6PO2xF3lqq9TfYJBvncx3NlbsQptAZ8jabWAnGVNURm3hDmJiLvNm9fzrRWpXKGfMED6RJm8NIznNDbKhrFHwkC28AW0Z6pfYT9qQMNzDw+uj9HcOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262030; c=relaxed/simple; bh=3xNfFpNHx12AUoJYARfmg2BOBQiezqeRp4beGxmTQDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DFmCRDLWd/oMoBkt/yE9Dgq//+SKIL6vjWz8ogeecerWZKWWGs6Im3gMuL6P5XtjRtaNu4I82OaAYeMO8fpCdAnnNcB5l9V/wT/sPaGLYNNQ5F26LdG7sX4n2zsHkiWEXZUB4d4f6UJFpLefbpewKN3NqyeVWWova1GNlagBD0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uYYFoHJl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uYYFoHJl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3C01C2BCB7; Mon, 27 Apr 2026 03:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777262030; bh=3xNfFpNHx12AUoJYARfmg2BOBQiezqeRp4beGxmTQDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uYYFoHJlKnpRxsLCc5GDmZs7j31bPU5jxYFfPsd+2R2godQeeJFYuEi9UcG89K1Eh rjVgRBXLphnJzoTambIPSyEo0VLANodzj5zwBLn24yoW6twCf4GA7quxnszXwl7wm9 tQe7GtgCh6uhVy2yNr27YTGTr7m/KckmhTOCQNXBVDv6Mt31hadH5gBb46P5CwU5JD Mnidh+AvWbtnJU2uvFzb5AzMOwckwGC0/fjeCMp0sMlgr2jE0FUyb+cw8AEkNgfJPq ZleNF8jSlPZqf0J5hOwTiLAzTkhO/JDWT8upjvs8ENFNrU/v+5ooDA88InUT3GgguL b765HnnACCWDw== From: "Mario Limonciello (AMD)" To: Bjorn Helgaas , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM) Cc: linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list), "Rafael J . Wysocki" , Lukas Wunner , "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH 4/5] PCI/PM: Use pci_power_manageable() in pci_pm_poweroff_noirq() Date: Sun, 26 Apr 2026 22:53:40 -0500 Message-ID: <20260427035341.1425576-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260427035341.1425576-1-superm1@kernel.org> References: <20260427035341.1425576-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Devices with no subordinate should be put into D3 during hibernate, but devices that have bridge_d3 set should also be put to sleep during hibernate. Adjust the check in pci_pm_poweroff_noirq() to use pci_power_manageable() to cover those as well. Tested-by: Eric Naim Signed-off-by: Mario Limonciello (AMD) --- drivers/pci/pci-driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 793af4af2971b..3c82d818ee15b 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1254,7 +1254,7 @@ static int pci_pm_poweroff_noirq(struct device *dev) return error; } =20 - if (!pci_dev->state_saved && !pci_has_subordinate(pci_dev)) + if (!pci_dev->state_saved && pci_power_manageable(pci_dev)) pci_prepare_to_sleep(pci_dev); =20 /* --=20 2.43.0 From nobody Wed Jun 17 07:20:40 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7EB337D128; Mon, 27 Apr 2026 03:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262031; cv=none; b=phN/CcjVzNWKVAXOmdyfLcesmAnPsGyIzJQZLRkO+1vgIVdRcvAu+G84hwRPhtMVbJj/A/X1d1JgwFgFr8/dDU4bjBbnvrMyB7slBUm4ikGbcAWz9UvCOLboDVTGr9zDGhsGkN5KwzQb+QZlYMObvzvaDaLZHs0CqTED7vkPTyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777262031; c=relaxed/simple; bh=rDQRwElc9pcyQqxjF3uXG5jwNZhWPNxCd8O+CxwRzzQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=owNgliEg0oOhqpImyIzm1mGaIOmZBb41N3Yd0rhclDQYqr58bOc2YAs7fooNm8cC6hqlodSR8X3zmhDHCIiLmxwRzYT7sMdcR4b3DSj1IPNghQB4yMwOQo2+AS5m2PZeCzpwMZpx/GQZfPLijcYy+dO+I/DhHOY9+Ts6wKDMjAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KD2N8vtA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KD2N8vtA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9955CC19425; Mon, 27 Apr 2026 03:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777262031; bh=rDQRwElc9pcyQqxjF3uXG5jwNZhWPNxCd8O+CxwRzzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KD2N8vtAH4AcEyM0BXTiDJdVtfuPB/rqEFS/zuyJs5tUUpEs3276Ub67lom9NffX+ TtZyzxcd4EBRpRooIsa0YnbSlsFEwN4jiiDVzGVEQ37fNbTHoNs1iORDjOeP1AC+3H iEvngni64LRhH3IbbS37M9b4nYszAvn5de7K9y7Cy1P4B3f7NH/SwGaRgAnHQ0wKnk SDsmdDQq6Ll95pp+K+oVI1LCxQzhgEx+ivmy2MGITCCKNgtP8ao28RCNRPsUpbZdPb NJBuc2/hmTmN1Sd/cwS6nE0u3Sa17BfOsGv4l/I17gyIdJy///wxNqUu2H8ihB+OIs plRruHg2FzmtQ== From: "Mario Limonciello (AMD)" To: Bjorn Helgaas , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM) Cc: linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list), "Rafael J . Wysocki" , Lukas Wunner , "Mario Limonciello (AMD)" , AceLan Kao , Kai-Heng Feng , Mark Pearson , Denis Benato , =?UTF-8?q?Merthan=20Karaka=C5=9F?= , Eric Naim Subject: [PATCH 5/5] PCI: Put PCIe bridges with downstream devices into D3 at hibernate Date: Sun, 26 Apr 2026 22:53:41 -0500 Message-ID: <20260427035341.1425576-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260427035341.1425576-1-superm1@kernel.org> References: <20260427035341.1425576-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable During suspend, PCIe bridges with downstream devices are transitioned into a low power state (D3hot or D3cold) depending on platform capabilities. However, during hibernate, these bridges remain in D0, which can lead to unnecessary power consumption. Align the hibernate flow with suspend by updating pci_pm_poweroff_noirq() to use pci_pm_suspend_noirq_common(). This ensures that PCIe bridges with active downstream devices are properly transitioned to a low power state during hibernate. This change introduces a functional update: the hibernate path will now invoke pci_save_state(), and =E2=80=94 unless bus-level power management is skipped =E2=80=94 will transition the bridge into D3hot or D3cold as approp= riate. Cc: AceLan Kao Cc: Kai-Heng Feng Cc: Mark Pearson Cc: Denis Benato Cc: Merthan Karaka=C5=9F Tested-by: Eric Naim Signed-off-by: Mario Limonciello (AMD) --- drivers/pci/pci-driver.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 3c82d818ee15b..50eca518493b8 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -788,7 +788,7 @@ static void pci_pm_complete(struct device *dev) =20 #endif /* !CONFIG_PM_SLEEP */ =20 -#if defined(CONFIG_SUSPEND) +#if defined(CONFIG_SUSPEND) || defined(CONFIG_HIBERNATE_CALLBACKS) /** * pci_pm_suspend_noirq_common * @pci_dev: pci device @@ -834,7 +834,7 @@ static void pci_pm_suspend_noirq_common(struct pci_dev = *pci_dev, bool *skip_bus_ =20 pci_pm_set_unknown_state(pci_dev); } -#endif /* CONFIG_SUSPEND */ +#endif /* CONFIG_SUSPEND || CONFIG_HIBERNATE_CALLBACKS */ =20 #ifdef CONFIG_SUSPEND static void pcie_pme_root_status_cleanup(struct pci_dev *pci_dev) @@ -1191,6 +1191,8 @@ static int pci_pm_poweroff(struct device *dev) if (device_may_wakeup(dev) && system_state =3D=3D SYSTEM_POWER_OFF) device_set_wakeup_enable(dev, false); =20 + pci_dev->skip_bus_pm =3D false; + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend(dev, PMSG_HIBERNATE); =20 @@ -1233,6 +1235,7 @@ static int pci_pm_poweroff_noirq(struct device *dev) { struct pci_dev *pci_dev =3D to_pci_dev(dev); const struct dev_pm_ops *pm =3D dev->driver ? dev->driver->pm : NULL; + bool skip_bus_pm =3D false; =20 if (dev_pm_skip_suspend(dev)) return 0; @@ -1254,8 +1257,9 @@ static int pci_pm_poweroff_noirq(struct device *dev) return error; } =20 - if (!pci_dev->state_saved && pci_power_manageable(pci_dev)) - pci_prepare_to_sleep(pci_dev); + pci_pm_suspend_noirq_common(pci_dev, &skip_bus_pm); + if (skip_bus_pm) + goto Fixup; =20 /* * The reason for doing this here is the same as for the analogous code @@ -1264,6 +1268,7 @@ static int pci_pm_poweroff_noirq(struct device *dev) if (pci_dev->class =3D=3D PCI_CLASS_SERIAL_USB_EHCI) pci_write_config_word(pci_dev, PCI_COMMAND, 0); =20 +Fixup: pci_fixup_device(pci_fixup_suspend_late, pci_dev); =20 return 0; --=20 2.43.0