]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
nvme-pci: Support shared tags across queues for Apple 2018 controllers
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 7 Aug 2019 07:51:22 +0000 (17:51 +1000)
committerSagi Grimberg <sagi@grimberg.me>
Thu, 29 Aug 2019 19:55:02 +0000 (12:55 -0700)
Another issue with the Apple T2 based 2018 controllers seem to be
that they blow up (and shut the machine down) if there's a tag
collision between the IO queue and the Admin queue.

My suspicion is that they use our tags for their internal tracking
and don't mix them with the queue id. They also seem to not like
when tags go beyond the IO queue depth, ie 128 tags.

This adds a quirk that marks tags 0..31 of the IO queue reserved

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index 21eb48d3385d52805a5f7c9db0244872ba5f448c..624c3ea2134c43826627c33d4b943a31386f45d3 100644 (file)
@@ -104,6 +104,11 @@ enum nvme_quirks {
         * Use non-standard 128 bytes SQEs.
         */
        NVME_QUIRK_128_BYTES_SQES               = (1 << 11),
+
+       /*
+        * Prevent tag overlap between queues
+        */
+       NVME_QUIRK_SHARED_TAGS                  = (1 << 12),
 };
 
 /*
index effb793419099059c1644d679682d738e4ebe0f4..77bcda68fe1a3a8baf5470c7652c755923d9fff8 100644 (file)
@@ -2106,6 +2106,14 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
        unsigned long size;
 
        nr_io_queues = max_io_queues();
+
+       /*
+        * If tags are shared with admin queue (Apple bug), then
+        * make sure we only use one IO queue.
+        */
+       if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS)
+               nr_io_queues = 1;
+
        result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues);
        if (result < 0)
                return result;
@@ -2276,6 +2284,14 @@ static int nvme_dev_add(struct nvme_dev *dev)
                dev->tagset.flags = BLK_MQ_F_SHOULD_MERGE;
                dev->tagset.driver_data = dev;
 
+               /*
+                * Some Apple controllers requires tags to be unique
+                * across admin and IO queue, so reserve the first 32
+                * tags of the IO queue.
+                */
+               if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS)
+                       dev->tagset.reserved_tags = NVME_AQ_DEPTH;
+
                ret = blk_mq_alloc_tag_set(&dev->tagset);
                if (ret) {
                        dev_warn(dev->ctrl.device,
@@ -2356,6 +2372,18 @@ static int nvme_pci_enable(struct nvme_dev *dev)
                         "set queue depth=%u\n", dev->q_depth);
        }
 
+       /*
+        * Controllers with the shared tags quirk need the IO queue to be
+        * big enough so that we get 32 tags for the admin queue
+        */
+       if ((dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS) &&
+           (dev->q_depth < (NVME_AQ_DEPTH + 2))) {
+               dev->q_depth = NVME_AQ_DEPTH + 2;
+               dev_warn(dev->ctrl.device, "IO queue depth clamped to %d\n",
+                        dev->q_depth);
+       }
+
+
        nvme_map_cmb(dev);
 
        pci_enable_pcie_error_reporting(pdev);
@@ -3058,7 +3086,8 @@ static const struct pci_device_id nvme_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2003) },
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005),
                .driver_data = NVME_QUIRK_SINGLE_VECTOR |
-                               NVME_QUIRK_128_BYTES_SQES },
+                               NVME_QUIRK_128_BYTES_SQES |
+                               NVME_QUIRK_SHARED_TAGS },
        { 0, }
 };
 MODULE_DEVICE_TABLE(pci, nvme_id_table);