All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prike Liang <Prike.Liang@amd.com>
To: <kbusch@kernel.org>, <axboe@fb.com>, <hch@lst.de>,
	<sagi@grimberg.me>, <linux-nvme@lists.infradead.org>
Cc: <Alexander.Deucher@amd.com>, <Shyam-sundar.S-k@amd.com>,
	<Mario.Limonciello@amd.com>, Prike Liang <Prike.Liang@amd.com>
Subject: [PATCH] nvme-pci: set some AMD PCIe downstream storage device to D3 for s2idle
Date: Tue, 25 May 2021 10:48:59 +0800	[thread overview]
Message-ID: <1621910939-24831-1-git-send-email-Prike.Liang@amd.com> (raw)

In the NVMe controller default suspend mode use APST do the power state
suspend and resume and the NVMe remains in D0 during s2idle entry.Then the
NVMe device will be shutdown by firmware in the s0ix entry and will not
restore the third-party NVMe device power context in the firmware s0ix
resume. Finally,the NVMe will lost the power state during s2idle resume
and result in request queue timeout. So far,this issue only found on the
Renoir/Lucienne/Cezanne series and can be addressed by shutdown the NVMe
device in the s2idle entry.

Link:https://lore.kernel.org/stable/20210416155653.GA31818@redsun51.ssa.fujisawa.hgst.com/T/

Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Prike Liang <Prike.Liang@amd.com>
---
 drivers/nvme/host/pci.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 6bad4d4..49cd24e 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -26,6 +26,9 @@
 #include <linux/io-64-nonatomic-hi-lo.h>
 #include <linux/sed-opal.h>
 #include <linux/pci-p2pdma.h>
+#ifdef CONFIG_X86
+#include <asm/cpu_device_id.h>
+#endif
 
 #include "trace.h"
 #include "nvme.h"
@@ -2828,6 +2831,16 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev)
 }
 
 #ifdef CONFIG_ACPI
+
+#ifdef CONFIG_X86
+static const struct x86_cpu_id storage_d3_cpu_ids[] = {
+	X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 80, NULL), /*Cezanne*/
+	X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /*Renoir*/
+	X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL),/*Lucienne*/
+	{}
+};
+#endif
+
 static bool nvme_acpi_storage_d3(struct pci_dev *dev)
 {
 	struct acpi_device *adev;
@@ -2836,6 +2849,13 @@ static bool nvme_acpi_storage_d3(struct pci_dev *dev)
 	acpi_status status;
 	u8 val;
 
+#ifdef CONFIG_X86
+	/*
+	 *  Set the NVMe on the target platform to D3 directly by kernel power management.
+	 */
+	if (x86_match_cpu(storage_d3_cpu_ids) && pm_suspend_default_s2idle())
+		return true;
+#endif
 	/*
 	 * Look for _DSD property specifying that the storage device on the port
 	 * must use D3 to support deep platform power savings during
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

             reply	other threads:[~2021-05-25  3:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  2:48 Prike Liang [this message]
2021-05-25  6:21 ` [PATCH] nvme-pci: set some AMD PCIe downstream storage device to D3 for s2idle Christoph Hellwig
2021-05-25 12:11   ` Liang, Prike
2021-05-25 12:15     ` Christoph Hellwig
2021-05-25 13:39   ` Deucher, Alexander
2021-05-25 13:54     ` Hans de Goede
2021-05-25 14:06       ` Limonciello, Mario
2021-05-25 14:16         ` Christoph Hellwig
2021-05-25 15:18           ` Limonciello, Mario
2021-05-25 17:45             ` Keith Busch
2021-05-25 18:27               ` Limonciello, Mario
2021-05-25 19:55                 ` Keith Busch
2021-05-25 20:02                 ` Chaitanya Kulkarni
2021-05-26  8:52             ` Hans de Goede
2021-05-26 13:02               ` Christoph Hellwig
2021-05-26 14:45               ` Keith Busch
2021-05-26 14:55                 ` Rafael J. Wysocki
2021-05-26 17:02                   ` Limonciello, Mario
2021-05-26 17:27                     ` Rafael J. Wysocki
2021-05-26 17:32                       ` Limonciello, Mario
2021-05-26 17:42                       ` Limonciello, Mario
2021-05-25 19:59         ` Keith Busch
2021-05-25 20:09           ` Limonciello, Mario
2021-05-25 20:24             ` Keith Busch
2021-05-25 21:51               ` Limonciello, Mario
2021-05-25 14:09       ` Deucher, Alexander

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=1621910939-24831-1-git-send-email-Prike.Liang@amd.com \
    --to=prike.liang@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.