From: Bjorn Helgaas <helgaas@kernel.org>
To: Mario Limonciello <superm1@kernel.org>
Cc: mario.limonciello@amd.com, bhelgaas@google.com,
rafael.j.wysocki@intel.com, huang.ying.caritas@gmail.com,
stern@rowland.harvard.edu, linux-pci@vger.kernel.org
Subject: Re: [PATCH v2] PCI: Explicitly put devices into D0 when initializing
Date: Mon, 5 May 2025 18:06:32 -0500 [thread overview]
Message-ID: <20250505230632.GA1007257@bhelgaas> (raw)
In-Reply-To: <20250424043232.1848107-1-superm1@kernel.org>
On Wed, Apr 23, 2025 at 11:31:32PM -0500, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> AMD BIOS team has root caused an issue that NVME storage failed to come
> back from suspend to a lack of a call to _REG when NVME device was probed.
>
> commit 112a7f9c8edbf ("PCI/ACPI: Call _REG when transitioning D-states")
> added support for calling _REG when transitioning D-states, but this only
> works if the device actually "transitions" D-states.
>
> commit 967577b062417 ("PCI/PM: Keep runtime PM enabled for unbound PCI
> devices") added support for runtime PM on PCI devices, but never actually
> 'explicitly' sets the device to D0.
>
> To make sure that devices are in D0 and that platform methods such as
> _REG are called, explicitly set all devices into D0 during initialization.
>
> Fixes: 967577b062417 ("PCI/PM: Keep runtime PM enabled for unbound PCI devices")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Applied to pci/pm for v6.16, thanks!
> ---
> v2:
> * Move runtime PM calls after setting to D0
> * Use pci_pm_power_up_and_verify_state()
> ---
> drivers/pci/pci-driver.c | 6 ------
> drivers/pci/pci.c | 13 ++++++++++---
> drivers/pci/pci.h | 1 +
> 3 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index c8bd71a739f72..082918ce03d8a 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -555,12 +555,6 @@ static void pci_pm_default_resume(struct pci_dev *pci_dev)
> pci_enable_wake(pci_dev, PCI_D0, false);
> }
>
> -static void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev)
> -{
> - pci_power_up(pci_dev);
> - pci_update_current_state(pci_dev, PCI_D0);
> -}
> -
> static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
> {
> pci_pm_power_up_and_verify_state(pci_dev);
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e77d5b53c0cec..8d125998b30b7 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3192,6 +3192,12 @@ void pci_d3cold_disable(struct pci_dev *dev)
> }
> EXPORT_SYMBOL_GPL(pci_d3cold_disable);
>
> +void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev)
> +{
> + pci_power_up(pci_dev);
> + pci_update_current_state(pci_dev, PCI_D0);
> +}
> +
> /**
> * pci_pm_init - Initialize PM functions of given PCI device
> * @dev: PCI device to handle.
> @@ -3202,9 +3208,6 @@ void pci_pm_init(struct pci_dev *dev)
> u16 status;
> u16 pmc;
>
> - pm_runtime_forbid(&dev->dev);
> - pm_runtime_set_active(&dev->dev);
> - pm_runtime_enable(&dev->dev);
> device_enable_async_suspend(&dev->dev);
> dev->wakeup_prepared = false;
>
> @@ -3266,6 +3269,10 @@ 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;
> + pci_pm_power_up_and_verify_state(dev);
> + pm_runtime_forbid(&dev->dev);
> + pm_runtime_set_active(&dev->dev);
> + pm_runtime_enable(&dev->dev);
> }
>
> static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop)
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index b81e99cd4b62a..49165b739138b 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -148,6 +148,7 @@ void pci_dev_adjust_pme(struct pci_dev *dev);
> void pci_dev_complete_resume(struct pci_dev *pci_dev);
> void pci_config_pm_runtime_get(struct pci_dev *dev);
> void pci_config_pm_runtime_put(struct pci_dev *dev);
> +void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev);
> void pci_pm_init(struct pci_dev *dev);
> void pci_ea_init(struct pci_dev *dev);
> void pci_msi_init(struct pci_dev *dev);
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-05-05 23:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 4:31 [PATCH v2] PCI: Explicitly put devices into D0 when initializing Mario Limonciello
2025-04-24 15:07 ` Wysocki, Rafael J
2025-04-24 18:20 ` Mario Limonciello
2025-04-27 12:54 ` Denis Benato
2025-05-05 19:20 ` Perry, David
2025-05-05 20:01 ` Mario Limonciello
2025-05-05 23:06 ` Bjorn Helgaas [this message]
2025-06-11 14:14 ` Nicolas Dichtel
2025-06-11 14:56 ` Mario Limonciello
2025-06-11 16:05 ` Alex Williamson
2025-06-11 12:52 ` [PATCH v2] PCI: Explicitly put devices into D0 when initializing - Bug report Cabiddu, Giovanni
2025-06-11 13:50 ` Mario Limonciello
2025-06-11 14:30 ` Cabiddu, Giovanni
2025-06-11 16:00 ` Alex Williamson
2025-06-11 16:13 ` Cabiddu, Giovanni
2025-06-11 20:45 ` Mario Limonciello
2025-06-11 22:07 ` Giovanni Cabiddu
2025-06-19 9:11 ` Alexey Kardashevskiy
[not found] <BY5PR19MB3922D2994064085132D8FEBD9A822@BY5PR19MB3922.namprd19.prod.outlook.com>
2025-05-01 14:14 ` [PATCH v2] PCI: Explicitly put devices into D0 when initializing Shen, Yijun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250505230632.GA1007257@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=huang.ying.caritas@gmail.com \
--cc=linux-pci@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=rafael.j.wysocki@intel.com \
--cc=stern@rowland.harvard.edu \
--cc=superm1@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox