* [PATCH] PCI: Set up runtime PM on devices that don't support PCI PM
@ 2025-06-11 22:28 Mario Limonciello
2025-06-11 22:47 ` Alex Williamson
0 siblings, 1 reply; 2+ messages in thread
From: Mario Limonciello @ 2025-06-11 22:28 UTC (permalink / raw)
To: mario.limonciello, bhelgaas, rafael
Cc: Alex Williamson, Giovanni Cabiddu, Nicolas Dichtel, linux-pci
From: Mario Limonciello <mario.limonciello@amd.com>
commit 4d4c10f763d7 ("PCI: Explicitly put devices into D0 when
initializing") intended to put PCI devices into D0, but in doing so
unintentionally changed runtime PM initialization not to occur on
devices that don't support PCI PM. This caused a regression in vfio-pci
due to an imbalance with it's use.
Adjust the logic in pci_pm_init() so that even if PCI PM isn't supported
runtime PM is still initialized.
Cc: Alex Williamson <alex.williamson@redhat.com>
Reported-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Closes: https://lore.kernel.org/linux-pci/20250424043232.1848107-1-superm1@kernel.org/T/#m7e8929d6421690dc8bd6dc639d86c2b4db27cbc4
Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Closes: https://lore.kernel.org/linux-pci/20250424043232.1848107-1-superm1@kernel.org/T/#m40d277dcdb9be64a1609a82412d1aa906263e201
Tested-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Fixes: 4d4c10f763d7 ("PCI: Explicitly put devices into D0 when initializing")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pci/pci.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 3dd44d1ad829b..c495c3c692f5f 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3221,15 +3221,17 @@ void pci_pm_init(struct pci_dev *dev)
/* find PCI PM capability in list */
pm = pci_find_capability(dev, PCI_CAP_ID_PM);
- if (!pm)
+ if (!pm) {
+ goto poweron;
return;
+ }
/* Check device's ability to generate PME# */
pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc);
if ((pmc & PCI_PM_CAP_VER_MASK) > 3) {
pci_err(dev, "unsupported PM cap regs version (%u)\n",
pmc & PCI_PM_CAP_VER_MASK);
- return;
+ goto poweron;
}
dev->pm_cap = pm;
@@ -3274,6 +3276,7 @@ void pci_pm_init(struct pci_dev *dev)
pci_read_config_word(dev, PCI_STATUS, &status);
if (status & PCI_STATUS_IMM_READY)
dev->imm_ready = 1;
+poweron:
pci_pm_power_up_and_verify_state(dev);
pm_runtime_forbid(&dev->dev);
pm_runtime_set_active(&dev->dev);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: Set up runtime PM on devices that don't support PCI PM
2025-06-11 22:28 [PATCH] PCI: Set up runtime PM on devices that don't support PCI PM Mario Limonciello
@ 2025-06-11 22:47 ` Alex Williamson
0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2025-06-11 22:47 UTC (permalink / raw)
To: Mario Limonciello
Cc: mario.limonciello, bhelgaas, rafael, Giovanni Cabiddu,
Nicolas Dichtel, linux-pci
On Wed, 11 Jun 2025 17:28:28 -0500
Mario Limonciello <superm1@kernel.org> wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> commit 4d4c10f763d7 ("PCI: Explicitly put devices into D0 when
> initializing") intended to put PCI devices into D0, but in doing so
> unintentionally changed runtime PM initialization not to occur on
> devices that don't support PCI PM. This caused a regression in vfio-pci
> due to an imbalance with it's use.
>
> Adjust the logic in pci_pm_init() so that even if PCI PM isn't supported
> runtime PM is still initialized.
>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Reported-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> Closes: https://lore.kernel.org/linux-pci/20250424043232.1848107-1-superm1@kernel.org/T/#m7e8929d6421690dc8bd6dc639d86c2b4db27cbc4
> Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> Closes: https://lore.kernel.org/linux-pci/20250424043232.1848107-1-superm1@kernel.org/T/#m40d277dcdb9be64a1609a82412d1aa906263e201
> Tested-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> Fixes: 4d4c10f763d7 ("PCI: Explicitly put devices into D0 when initializing")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/pci/pci.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 3dd44d1ad829b..c495c3c692f5f 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3221,15 +3221,17 @@ void pci_pm_init(struct pci_dev *dev)
>
> /* find PCI PM capability in list */
> pm = pci_find_capability(dev, PCI_CAP_ID_PM);
> - if (!pm)
> + if (!pm) {
> + goto poweron;
> return;
Unreachable return. Thanks,
Alex
> + }
> /* Check device's ability to generate PME# */
> pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc);
>
> if ((pmc & PCI_PM_CAP_VER_MASK) > 3) {
> pci_err(dev, "unsupported PM cap regs version (%u)\n",
> pmc & PCI_PM_CAP_VER_MASK);
> - return;
> + goto poweron;
> }
>
> dev->pm_cap = pm;
> @@ -3274,6 +3276,7 @@ void pci_pm_init(struct pci_dev *dev)
> pci_read_config_word(dev, PCI_STATUS, &status);
> if (status & PCI_STATUS_IMM_READY)
> dev->imm_ready = 1;
> +poweron:
> pci_pm_power_up_and_verify_state(dev);
> pm_runtime_forbid(&dev->dev);
> pm_runtime_set_active(&dev->dev);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-11 22:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 22:28 [PATCH] PCI: Set up runtime PM on devices that don't support PCI PM Mario Limonciello
2025-06-11 22:47 ` Alex Williamson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).