about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2022-08-26 01:09:22 +0200
committeraszlig <aszlig@nix.build>2022-08-26 13:56:25 +0200
commit6c5af862340d86855f00eb48afd1eb52ffd29ac3 (patch)
tree7d9d5863cabd573277113f398278353e229657f0 /modules
parent03c5372a947d522ea2d3ebb1c4e01f8cc99e3b15 (diff)
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 <aszlig@nix.build>
Diffstat (limited to 'modules')
-rw-r--r--modules/hardware/tuxedo-pulse1502/default.nix13
-rw-r--r--modules/hardware/tuxedo-pulse1502/nvme-suspend-quirk.patch47
-rw-r--r--modules/module-list.nix1
3 files changed, 61 insertions, 0 deletions
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