From 6c5af862340d86855f00eb48afd1eb52ffd29ac3 Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 26 Aug 2022 01:09:22 +0200 Subject: slylandro: Add quirk for disabling D3cold on NVMe After resume from suspend the NVMe does not wake up again when the device was put into D3cold. This is something that is worked around by TUXEDO Tomte[1] via udev rules. However, I personally don't like this approach and it can lead to race conditions when we're going into suspend before udev is initialised. Interestingly, the device does even go into NPSS via APST, but if changing to D3cold while APST is enabled, the device does not wake up again. Right now I just added a new quirk to disable D3cold during device probe for now, but we could maybe find a better workaround eg. by disabling APST before D3cold and re-enabling it again. Not sure whether this is feasible, but since I have limited time right now I can't dig more into this. [1]: https://github.com/tuxedocomputers/tuxedo-tomte/commit/2c8d71170868a2663705fbea6ac150eecb96e6ce Signed-off-by: aszlig --- modules/hardware/tuxedo-pulse1502/default.nix | 13 ++++++ .../tuxedo-pulse1502/nvme-suspend-quirk.patch | 47 ++++++++++++++++++++++ modules/module-list.nix | 1 + 3 files changed, 61 insertions(+) create mode 100644 modules/hardware/tuxedo-pulse1502/default.nix create mode 100644 modules/hardware/tuxedo-pulse1502/nvme-suspend-quirk.patch (limited to 'modules') diff --git a/modules/hardware/tuxedo-pulse1502/default.nix b/modules/hardware/tuxedo-pulse1502/default.nix new file mode 100644 index 00000000..89ea78c5 --- /dev/null +++ b/modules/hardware/tuxedo-pulse1502/default.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: + +{ + options.vuizvui.hardware.tuxedo.pulse15.gen2.enable = + lib.mkEnableOption "hardware support for the TUXEDO Pulse 15 - Gen2"; + + config = lib.mkIf config.vuizvui.hardware.tuxedo.pulse15.gen2.enable { + boot.kernelPatches = lib.singleton { + name = "nvme-disable-d3cold"; + patch = ./nvme-suspend-quirk.patch; + }; + }; +} diff --git a/modules/hardware/tuxedo-pulse1502/nvme-suspend-quirk.patch b/modules/hardware/tuxedo-pulse1502/nvme-suspend-quirk.patch new file mode 100644 index 00000000..b1983554 --- /dev/null +++ b/modules/hardware/tuxedo-pulse1502/nvme-suspend-quirk.patch @@ -0,0 +1,47 @@ +diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h +index 1bdf714dcd9e..4014a2e17c70 100644 +--- a/drivers/nvme/host/nvme.h ++++ b/drivers/nvme/host/nvme.h +@@ -149,6 +149,12 @@ enum nvme_quirks { + * Reports garbage in the namespace identifiers (eui64, nguid, uuid). + */ + NVME_QUIRK_BOGUS_NID = (1 << 18), ++ ++ /* ++ * Disables entering D3cold state for devices that might not wake up ++ * again afterwards. ++ */ ++ NVME_QUIRK_NO_D3_COLD = (1 << 19), + }; + + /* +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c +index 3a1c37f32f30..1cedc6d0ec5f 100644 +--- a/drivers/nvme/host/pci.c ++++ b/drivers/nvme/host/pci.c +@@ -3070,6 +3070,15 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev) + if ((dmi_match(DMI_BOARD_VENDOR, "LENOVO")) && + dmi_match(DMI_BOARD_NAME, "LNVNB161216")) + return NVME_QUIRK_SIMPLE_SUSPEND; ++ } else if (pdev->vendor == 0x144d && (pdev->device == 0xa80a || ++ pdev->device == 0xa808)) { ++ /* ++ * Some Samsung SSDs on TUXEDO Pulse 15 Gen2 do not seem to ++ * wake up from D3cold. ++ */ ++ if (dmi_match(DMI_BOARD_VENDOR, "NB02") && ++ dmi_match(DMI_BOARD_NAME, "PF5LUXG")) ++ return NVME_QUIRK_NO_D3_COLD; + } + + return 0; +@@ -3134,6 +3143,9 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) + quirks |= NVME_QUIRK_SIMPLE_SUSPEND; + } + ++ if (quirks & NVME_QUIRK_NO_D3_COLD) ++ pci_d3cold_disable(pdev); ++ + /* + * Double check that our mempool alloc size will cover the biggest + * command we support. diff --git a/modules/module-list.nix b/modules/module-list.nix index 39345699..b72e2e05 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -7,6 +7,7 @@ ./hardware/rtl8192cu ./hardware/t100ha ./hardware/thinkpad.nix + ./hardware/tuxedo-pulse1502 ./profiles/tvl.nix ./programs/gnupg ./programs/fish/fasd.nix -- cgit 1.4.1