From nobody Wed Jun 17 05:10:51 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 D595A33ADA9; Mon, 27 Apr 2026 20:50:34 +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=1777323034; cv=none; b=FTKJZGhtl5Azb63NWy5caOLsyM8DvLoPWv9yRrpL8GENGhXs7CP1nq4dvE+TRBcbFw+Xlf2UqMAr+7qVOTP3CG89aPwR7VP1/E8NUJe9GfKnz5+Xd9MUv7oQx1160Jsgbk2EmarO7gDAkU9WY9OFOGW4JYCTiYVWCeIi8F8msBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777323034; c=relaxed/simple; bh=+Nec97Tui9c9Iet178LuyVfsDVIn5g6EVyth9hJ5hvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AOmwq/Hj3gOw6AikCDxeni0IR2YqJbR/xrj4SccDgqktGBhwabePR8xGCB2y4IRAXWppimnXbdZibSyo3U2uQnBnsnF00rzveYHGDZYmiYiZqpHA2yxQ6n1LofaQ6eZ/rRzJT43PaeyU9CQJ/xgmWcYCi49m0spJHh0OgUZtcgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sm1n4ziy; 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="Sm1n4ziy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51F4DC2BCB5; Mon, 27 Apr 2026 20:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777323034; bh=+Nec97Tui9c9Iet178LuyVfsDVIn5g6EVyth9hJ5hvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sm1n4ziyAPzZniBzAm5GdF/KWAc7Z/k6w1bTdPGrTfjosSnamXxEEAEGH0FdMg08E pkdTa6jwC5iPFqj3SADBTk6P/UAp+tT+sA0psE4U5Hhs5wwHalN63PapHGujmtFa/n mrnFa5UWx4cuPnh5KEhnr+t6/54LZI7bo6mm97QkdzPMdE7EBC+zyP+3vwx7Tzclry HUpXGR8hXek4sRPts+fSkphIhDMY+b1RVuofH1LyA51KHqhRTvkygnjUARmq15UR66 DExFGjDQ9iA1vnOTA2RIMvuxGu6lw9Yt9LA4D+FPy4HIysWMCjdzzZI8h2UZsH/ket DQbAsjG6U77ow== 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 , linux-pm@vger.kernel.org, "Mario Limonciello (AMD)" Subject: [PATCH v2 1/6] PCI: Stop setting cached power state to "unknown" on unbind Date: Mon, 27 Apr 2026 15:50:19 -0500 Message-ID: <20260427205024.254677-2-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260427205024.254677-1-superm1@kernel.org> References: <20260427205024.254677-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" From: Lukas Wunner When a PCI device is unbound from its driver, pci_device_remove() sets the cached power state in pci_dev->current_state to PCI_UNKNOWN. This was introduced by commit 2449e06a5696 ("PCI: reset pci device state to unknown state for resume") to invalidate the cached power state in case the system is subsequently put to sleep. For bound devices, the cached power state is set to PCI_UNKNOWN in pci_pm_suspend_noirq(), immediately before entering system sleep. Extend to unbound devices for consistency. This obviates the need to change the cached power state on unbind, so stop doing so. Signed-off-by: Lukas Wunner Reviewed-by: Mario Limonciello (AMD) Reviewed-by: Rafael J. Wysocki (Intel) --- drivers/pci/pci-driver.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index d10ece0889f0f..2bfefd8db5260 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -512,13 +512,6 @@ static void pci_device_remove(struct device *dev) /* Undo the runtime PM settings in local_pci_probe() */ pm_runtime_put_sync(dev); =20 - /* - * If the device is still on, set the power state as "unknown", - * since it might change by the next time we load the driver. - */ - if (pci_dev->current_state =3D=3D PCI_D0) - pci_dev->current_state =3D PCI_UNKNOWN; - /* * We would love to complain here if pci_dev->is_enabled is set, that * the driver should have called pci_disable_device(), but the @@ -893,7 +886,7 @@ static int pci_pm_suspend_noirq(struct device *dev) =20 if (!pm) { pci_save_state(pci_dev); - goto Fixup; + goto set_unknown; } =20 if (pm->suspend_noirq) { @@ -945,6 +938,7 @@ static int pci_pm_suspend_noirq(struct device *dev) goto Fixup; } =20 +set_unknown: pci_pm_set_unknown_state(pci_dev); =20 /* --=20 2.53.0 From nobody Wed Jun 17 05:10:51 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 C794A38F227; Mon, 27 Apr 2026 20:50:36 +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=1777323036; cv=none; b=VXIUNdtGjGXaaldg8Sv68FUiYrT4I2YlffHYhOpY1ZEgt6pGGdEnbz1jAIj7aTNuGtGJfvV7Gld4qqWY7D1K2XFZYPKCWdL7BSKDfJKSqaoGBRfIFcFk50b+0h8hXKw4GKv03+lRlIygD6nJ4VN4BqUTBcB61m15+EaGREtQhZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777323036; c=relaxed/simple; bh=UPXBiRd4SA5eur21yzpLr7D++JspS8VTBQMuLpFCYlQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=awkMjGrZvV3iajghUY38GxRB3jhKDdaaaENIgSg8PnrNcQ7SqvbLm2wag+Gm42rAKHzvJvTof3zKytJKO02rWGAAubzUk+hodq4E4OsEvRtFiY3NffOWWtGTt/GCOCKVTsmhP7eSIy8jIGt8YBZcLt73J9Z7qFuK4Cw1+vPBI5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I87S6JtS; 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="I87S6JtS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47A29C2BCB8; Mon, 27 Apr 2026 20:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777323035; bh=UPXBiRd4SA5eur21yzpLr7D++JspS8VTBQMuLpFCYlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I87S6JtS9kwHbfdWDF3DQr40oj+RFfnCWDfp5LDfGnYzJsvBR+o6U5L2QywyuHOMi h6ogMUGq5A3mUygVBonyG+PdRaWmGup7+u2q1M2wz9fdIvxyOfP+n/UJVc5eUgjN4k tRWaN0gI6ZaOF0dgJtvACF51VibBB16WIi6D66tR+7Vw2k1uLHBioJ5o2lsnXesQIt XNTfBoieoNweTvitLIX9mH4ENjI2OJ619cNO9tvHKiot3IFTyl32HELcpLrxD2mIyS 5mavBHFd6vZ3K0G6KImwa8LaRO7YkcpkiXapXfuUFkB4WsGSttiUuLC/TEM6Q12033 BfpjO3qo8ckXA== 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 , linux-pm@vger.kernel.org, "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH v2 2/6] PCI/PM: Disable device wakeups when halting or powering off system Date: Mon, 27 Apr 2026 15:50:20 -0500 Message-ID: <20260427205024.254677-3-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260427205024.254677-1-superm1@kernel.org> References: <20260427205024.254677-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.53.0 From nobody Wed Jun 17 05:10:51 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 8E68D3932DE; Mon, 27 Apr 2026 20:50:37 +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=1777323037; cv=none; b=Lq4TCbBNkTyIukgEFapxOMLBjduKPpgXNfN6qiusm1RLBVDQu8S100XdaqGFFu+oLQ/nsoDkVRWXZUPFaum9rEjS/BZQg5tWT/49+8yvU6eI4pMum4fhq4XWAnEi2+qGFtC4oI+a6Zl0azJqryUqCO56Jcq8iOroxphBOCMr4e0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777323037; c=relaxed/simple; bh=5Y464RxfkYaVjfPS8WDmHrw2cCY0IY0otufG9P72hYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RBHubJWBjiO32cZSZrfS6Ue6yyqSc798Rvi4oo/JXIsF0rFXNBTFPxgJ57TQNuRULGpp+1mQuN1b9wZVDsA2XWLgIqfx2r1wkdbFCxE7jQvd9MNmDYdf4igu8UF6lMmGKW54xBZXGQwBkBPwy7RG3xaiswFP8OXn05fxwvbpTVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fo/3HMmH; 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="Fo/3HMmH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59FB4C19425; Mon, 27 Apr 2026 20:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777323036; bh=5Y464RxfkYaVjfPS8WDmHrw2cCY0IY0otufG9P72hYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fo/3HMmH7nGH7qiUkAFsdLI21ttLngbBU3V/MW3X/4+Mpy9VMPbDTj+Ifx+gCLPQV ahEvJOprRPaKfO9MKumU0Q2vyFsWw+kZly0iGYsVNTKIIGDh+t/zjueJzIkZNpba0q wJqv1ywqIKq3fCrnvBjCzVS7ovLR2wU8rFXIdF+0KNpDfPHgm7X63YSyNVJJ3wuhTA PLYNNEriSL5Va6O6UE1sZcnKalKeRJzeKt/Z7nxSDb3pEU/TGAVEL3tDFE/W16ZDQW R3RpBCewYW8mL5PJEt3lXVDdq0GrpXNTmJ1mPuewtE5PBJHeTb4abIvM2L2G1oZcbW Th63kVwe9ef/g== 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 , linux-pm@vger.kernel.org, "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH v2 3/6] PCI/PM: Split out code from pci_pm_suspend_noirq() into helper Date: Mon, 27 Apr 2026 15:50:21 -0500 Message-ID: <20260427205024.254677-4-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260427205024.254677-1-superm1@kernel.org> References: <20260427205024.254677-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.53.0 From nobody Wed Jun 17 05:10:51 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 02CE3394498; Mon, 27 Apr 2026 20:50:38 +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=1777323039; cv=none; b=cq1YSMbOp6eXJo64KUvUW0S22nMMs2C4TrzY51LSfLRa6oQPsJ9iamt+Ig2jFjv7aWu+yeS8ksi+PzhG0TtJIV1aFQw7+xYlNxkMC6qH9HoRnl6gMsrr2atpkCWKAOQhHZYeCu54VP4m1IRU7gNkP+gnz3BfsMsgMDgSbf9MOQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777323039; c=relaxed/simple; bh=sPxWKehtBU3nSAf+5nl2keVUjdobnlSMeJkZWg4OaSQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sOVZKv6VusQmpGquZV72B0j92PaefL6e2M8niIH51cCeQHSbmh2mScYAoeqpBNjkCgWfUp3XGHqUV+RsspY5d8QO+LcKXiL33+4Q7yLL6N9ofns+l1g52rjAaUW+kHEOxzrKqgvIiyZlPsBdgp3JLb4x2L15BvQHWYD3Si0R3Qc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IcarLd6/; 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="IcarLd6/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67BA9C2BCF6; Mon, 27 Apr 2026 20:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777323037; bh=sPxWKehtBU3nSAf+5nl2keVUjdobnlSMeJkZWg4OaSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IcarLd6/nnG2tygmqd/sUdWwKPT++xf0ZGc9rdkq3frrAJ0KDUn/votKnSvknQkbU Ia4r9U6ou/L8a+y2tyuaBO6T1MMXk8K8TLvLXKXqA75Pla9i8GWafzDyaRb0sncGPy 7EBlpiAmUHObkUG8iUpu+mVQfEqAGwFt1C8B4k1RiWMdM3H/jITGUNVpVrPzUjB1Lu gMcBIGOSmQKQmRWUZQ2nt09MkLcLHqlyJVpBPKmIqtF8TYzMRnVPCYre8aufznug4k vWx4ooFYXX65JiMUWiWWrafZOUwHjjjDy5Ohgljpg22oqwBMQIWZF5ym8mHMqRikig n2vFaUuRjasPA== 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 , linux-pm@vger.kernel.org, "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH v2 4/6] PCI/PM: Run bridge power up actions as part of restore phase Date: Mon, 27 Apr 2026 15:50:22 -0500 Message-ID: <20260427205024.254677-5-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260427205024.254677-1-superm1@kernel.org> References: <20260427205024.254677-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.53.0 From nobody Wed Jun 17 05:10:51 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 5ACA238E5FE; Mon, 27 Apr 2026 20:50:38 +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=1777323038; cv=none; b=ccFOgXKEb+PIsA/F+3jatp6PsGsAOyq+GSMfbZNyuwq0miHBO9Qx3ARMgXiZ1tzQhtLW8id18YHSbn2iPtqdMktDQs22T/MHIDenJlkM49hPFEs33kAssCS5ap7NB520xjAohiIq6GE7tmGTkZc8y36PFX/8LtilWZBOd9COmWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777323038; c=relaxed/simple; bh=Mvuxmuva0kDNJ/mqs+2loiDl+jGybnJOzh2+SFptSyI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIxduReS7uVqsw9PPKZVhLbhEzB0HTwsJV3MTH/bw/9d2OauWdR3u6o5TsJmLXppUu0K/jHvEEU1C7f1t97WPnm8YAMHds3GAG1hc8qjcQfG9FVsNc8MUd7G9u8Xi7CLaxft1g3g489DsghcuISz+jMK5atyM7GVQ2HvLvvhrAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UPIK3IGY; 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="UPIK3IGY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73E10C2BCB5; Mon, 27 Apr 2026 20:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777323038; bh=Mvuxmuva0kDNJ/mqs+2loiDl+jGybnJOzh2+SFptSyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UPIK3IGYVtrFovBfacNIdpfayOVHrn5TKQ0L/cjBUkVUm90twM7hOxkO8JflwmFPA RiMD37yohHQK3sRv6DXriMLWV6tzNE8I8QTdmkIyFPJJ2SPPuRBlY9iypGDDMg0tUh ryfUo3WUXJrUUDZzaei5VJwa6i7pShejyNI7sh/9LdIEJxVhGBUOWfOjs/KA2FOl7C 0JMklnhkQklpx1BJK4fq9oCP51ZGZfRJ5yRHlTakp/raTLJwNS6YxlcnTBtDzt9rA6 VLoHM8sTCie+eB27qSSNKUTtCJ3EtEZpV64XCIefqtuLNP+DgGNYa0ranRhTorGKQb DUOvls6Rpb9TA== 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 , linux-pm@vger.kernel.org, "Mario Limonciello (AMD)" , Eric Naim Subject: [PATCH v2 5/6] PCI/PM: Use pci_power_manageable() in pci_pm_poweroff_noirq() Date: Mon, 27 Apr 2026 15:50:23 -0500 Message-ID: <20260427205024.254677-6-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260427205024.254677-1-superm1@kernel.org> References: <20260427205024.254677-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.53.0 From nobody Wed Jun 17 05:10:51 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 B03D1396572; Mon, 27 Apr 2026 20:50:41 +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=1777323041; cv=none; b=RgoeM1h+fNj5C7ea9QUtxlyKRrOwBxZuF+GsyfzYrBnuunqO03MljTkQMfA92UrwOBe6MuHfH4lRwX80iR7nCt7QAUoYqaEnb8EHTuCzKIjwkcoc832IYq/Py3zeCBlF39GyMJGeaFH7sRLEkGoaV7ddYmImuvef2jxS9kVbgxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777323041; c=relaxed/simple; bh=GL8H8BY8NRdrAifAmpTwvjzlZwOl3aZ/5ExlC2X7Y10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IaTTFrcy1yIhhnTXO1UZyLoiuRsOfiWTwd849vuw9qZazJGpwIx9n9+HnYKulmICP94IT4bJkF+3rbuMz6AuMuvSFzmI7/HU28ERFy9Q//dTWiODpbxIbqV7csNMklCSdMC+tg3Zfq51A8l/G4OeimyL6kBfv84LXb9JmJ5IBEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IRboP7d8; 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="IRboP7d8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80F03C19425; Mon, 27 Apr 2026 20:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777323039; bh=GL8H8BY8NRdrAifAmpTwvjzlZwOl3aZ/5ExlC2X7Y10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRboP7d8Yrhhg0Vg5CxvWgGagfQDDHkS9ZvYjSQQUeWS/wL/j6dV2GX5+XeYqOeBx 6FBJReX/fo5H6H9WIxCo5CE9dza5JfUcOYCb2hJWPBvm1LvmHOYO199zaAZzjBzcJ8 /xHlfm3rdQqDIDDf8Kty1+iei8mgsgTqzuwtMWLzGDR0Y83cCtgEu47ucJqCnKoGWd KaRnHfOCckc2xU/qW86o8n+zOPwbQOeMo7/wTERfv0V+/WFRNcssfOwWYC34/O4KgY WHX5XIh8MWnYHVj6sCyNiZsxlyYePu1jRuKMfTrHJrGOnNB8ftkykhne0fVgQxcIX7 KliHMShZPYGMA== 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 , linux-pm@vger.kernel.org, "Mario Limonciello (AMD)" , AceLan Kao , Kai-Heng Feng , Mark Pearson , Denis Benato , =?UTF-8?q?Merthan=20Karaka=C5=9F?= , Eric Naim Subject: [PATCH v2 6/6] PCI: Put PCIe bridges with downstream devices into D3 at hibernate Date: Mon, 27 Apr 2026 15:50:24 -0500 Message-ID: <20260427205024.254677-7-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260427205024.254677-1-superm1@kernel.org> References: <20260427205024.254677-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.53.0