[PATCH] nvme-pci: Avoid the deepest sleep state on Wester Digital SSD

From: Saúl Valdelvira
Date: Fri Jan 17 2025 - 11:47:50 EST


The Western Digital PC SN520 NVMe SSD has a firmware issue that causes
it to hang when APST is enabled. This bug freezes the computer and
forces the user to cold-reboot.

Add a quirk for this model to avoid the deepest sleep states.

Signed-off-by: Saúl Valdelvira <saul@xxxxxxxx>
---
Hello, my name is Saúl.
Here's a patch that works arround a firmware issue I've been
experiencing for years in the aforementioned SSD card model.

Long story short:
4 years ago I bought a new laptop, and for some reason I was unable to
install Linux on it. Everytime I booted Linux, the computer hanged after
a few seconds.

I've been working arround this issue by setting the following kernel
parameter: nvme_core.default_ps_max_latency_us=14000

Adding the NVME_QUIRK_NO_DEEPEST_PS flag fixed the issue completely.

This [1] page from Dell's web mentions a firmware update for this SSD
with number 20240012 that seems to address the issue.
The problem is that, as far as i know, Western Digital doesn't offer
official firmware updates for Linux. At least, I haven't been able to
update it.

Here's some info about my SSD
- Model: WDC PC SN520 SDAPNUW-512G-1014
- Vendor: Western Digital
- Firmware Revision: 20110000

Hope you find this patch usefull.

[1] https://www.dell.com/support/home/en-uk/drivers/driversdetails?driverid=ffk91&lwp=rt
---

drivers/nvme/host/pci.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index e2634f437f33..20a94e479caf 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -3760,6 +3760,8 @@ static const struct pci_device_id nvme_id_table[] = {
NVME_QUIRK_SHARED_TAGS |
NVME_QUIRK_SKIP_CID_GEN |
NVME_QUIRK_IDENTIFY_CNS },
+ { PCI_DEVICE(0x15b7, 0x5003), /* WDC PC SN520 SDAPNUW-512G-1014 */
+ .driver_data = NVME_QUIRK_NO_DEEPEST_PS },
{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
{ 0, }
};
--
2.48.1