]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nvme-pci: qdepth 1 quirk
authorKeith Busch <kbusch@kernel.org>
Wed, 11 Sep 2024 17:39:59 +0000 (10:39 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 Sep 2024 14:31:09 +0000 (16:31 +0200)
commit 83bdfcbdbe5d901c5fa432decf12e1725a840a56 upstream.

Another device has been reported to be unreliable if we have more than
one outstanding command. In this new case, data corruption may occur.
Since we have two devices now needing this quirky behavior, make a
generic quirk flag.

The same Apple quirk is clearly not "temporary", so update the comment
while moving it.

Link: https://lore.kernel.org/linux-nvme/191d810a4e3.fcc6066c765804.973611676137075390@collabora.com/
Reported-by: Robert Beckett <bob.beckett@collabora.com>
Reviewed-by: Christoph Hellwig hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Cc: "Gagniuc, Alexandru" <alexandru.gagniuc@hp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index da57947130cc7a65ae14b1e9a73bcbf9eeff1066..e01b1332d245a76c5bbd4d87a3809df6f21b1aad 100644 (file)
@@ -90,6 +90,11 @@ enum nvme_quirks {
         */
        NVME_QUIRK_NO_DEEPEST_PS                = (1 << 5),
 
+       /*
+        *  Problems seen with concurrent commands
+        */
+       NVME_QUIRK_QDEPTH_ONE                   = (1 << 6),
+
        /*
         * Set MEDIUM priority on SQ creation
         */
index c0533f3f64cbadb4c8e74776d020668bfaca79f3..7990c3f22ecf660a5c82825cf1d372dc180e34f7 100644 (file)
@@ -2563,15 +2563,8 @@ static int nvme_pci_enable(struct nvme_dev *dev)
        else
                dev->io_sqes = NVME_NVM_IOSQES;
 
-       /*
-        * Temporary fix for the Apple controller found in the MacBook8,1 and
-        * some MacBook7,1 to avoid controller resets and data loss.
-        */
-       if (pdev->vendor == PCI_VENDOR_ID_APPLE && pdev->device == 0x2001) {
+       if (dev->ctrl.quirks & NVME_QUIRK_QDEPTH_ONE) {
                dev->q_depth = 2;
-               dev_warn(dev->ctrl.device, "detected Apple NVMe controller, "
-                       "set queue depth=%u to work around controller resets\n",
-                       dev->q_depth);
        } else if (pdev->vendor == PCI_VENDOR_ID_SAMSUNG &&
                   (pdev->device == 0xa821 || pdev->device == 0xa822) &&
                   NVME_CAP_MQES(dev->ctrl.cap) == 0) {
@@ -3442,6 +3435,8 @@ static const struct pci_device_id nvme_id_table[] = {
                                NVME_QUIRK_BOGUS_NID, },
        { PCI_VDEVICE(REDHAT, 0x0010),  /* Qemu emulated controller */
                .driver_data = NVME_QUIRK_BOGUS_NID, },
+       { PCI_DEVICE(0x1217, 0x8760), /* O2 Micro 64GB Steam Deck */
+               .driver_data = NVME_QUIRK_QDEPTH_ONE },
        { PCI_DEVICE(0x126f, 0x2262),   /* Silicon Motion generic */
                .driver_data = NVME_QUIRK_NO_DEEPEST_PS |
                                NVME_QUIRK_BOGUS_NID, },
@@ -3576,7 +3571,12 @@ static const struct pci_device_id nvme_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0xcd02),
                .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, },
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001),
-               .driver_data = NVME_QUIRK_SINGLE_VECTOR },
+               /*
+                * Fix for the Apple controller found in the MacBook8,1 and
+                * some MacBook7,1 to avoid controller resets and data loss.
+                */
+               .driver_data = NVME_QUIRK_SINGLE_VECTOR |
+                               NVME_QUIRK_QDEPTH_ONE },
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2003) },
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005),
                .driver_data = NVME_QUIRK_SINGLE_VECTOR |