Like the title says, my NVMe drive just disappears when I leave the computer idle for hours with Plex running in the background.
I found this through dmesg:

[83195.194810] nvme nvme0: controller is down; will reset: CSTS=0xffffffff, PCI_STATUS=0xffff
[83195.234863] nvme 0000:01:00.0: can't change power state from D3hot to D0 (config space inaccessible)
[83195.234970] nvme nvme0: Removing after probe failure status: -19
[83195.638475] nvme nvme0: failed to set APST feature (-19)
[83195.644540] Buffer I/O error on dev nvme0n1p1, logical block 121667584, lost sync page write
[83195.644544] JBD2: Error -5 detected when updating journal superblock for nvme0n1p1-8.
[83195.644545] Aborting journal on device nvme0n1p1-8.
[83195.644546] Buffer I/O error on dev nvme0n1p1, logical block 121667584, lost sync page write
[83195.644547] JBD2: Error -5 detected when updating journal superblock for nvme0n1p1-8.

Works fine on Windows, I ran benchmarks using CrystalDiskMark and numbers are solid. No firmware updates available. Drive is a WD Black SN750.

Any ideas?

Thank you. So is this the correct command to use to write the file?

echo 'nvme_core.default_ps_max_latency_us=0' | sudo tee /etc/kernel/cmdline.d/40_nvme_core.conf

That will disable APST completely. You can try a larger value to see if it is just a particular low power state that is misbehaving.

I'm getting a "No such file or directory" error when executing the command.

    lavadrop The error here is quite explicit. It means at least one of the directory levels you're trying to write to doesn't exist. You can just do:

    sudo mkdir -p /etc/kernel/cmdline.d

    to ensure the directories exist before re-running your command.