]> git.itanic.dy.fi Git - linux-stable/commitdiff
nvme: introduce NVME_QUIRK_IGNORE_DEV_SUBNQN
authorJames Dingwall <james@dingwall.me.uk>
Tue, 8 Jan 2019 17:20:51 +0000 (10:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Feb 2019 09:29:05 +0000 (10:29 +0100)
[ Upstream commit 6299358d198a0635da2dd3c4b3ec37789e811e44 ]

If a device provides an NQN it is expected to be globally unique.
Unfortunately some firmware revisions for Intel 760p/Pro 7600p devices did
not satisfy this requirement.  In these circumstances if a system has >1
affected device then only one device is enabled.  If this quirk is enabled
then the device supplied subnqn is ignored and we fallback to generating
one as if the field was empty.  In this case we also suppress the version
check so we don't print a warning when the quirk is enabled.

Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: James Dingwall <james@dingwall.me.uk>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index 971ca6754959040e1fb799a9c1268dc6fb4ca867..5f9a5ef9396961543668951a99aed0fd15049b5f 100644 (file)
@@ -2084,14 +2084,16 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct
        size_t nqnlen;
        int off;
 
-       nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
-       if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
-               strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
-               return;
-       }
+       if(!(ctrl->quirks & NVME_QUIRK_IGNORE_DEV_SUBNQN)) {
+               nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
+               if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
+                       strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE);
+                       return;
+               }
 
-       if (ctrl->vs >= NVME_VS(1, 2, 1))
-               dev_warn(ctrl->device, "missing or invalid SUBNQN field.\n");
+               if (ctrl->vs >= NVME_VS(1, 2, 1))
+                       dev_warn(ctrl->device, "missing or invalid SUBNQN field.\n");
+       }
 
        /* Generate a "fake" NQN per Figure 254 in NVMe 1.3 + ECN 001 */
        off = snprintf(subsys->subnqn, NVMF_NQN_SIZE,
index 081cbdcce8803a8ddca91d21e63511846114ad7d..6ffa99a10a60b5acf8d08845b2d80b8395b5b45f 100644 (file)
@@ -90,6 +90,11 @@ enum nvme_quirks {
         * Set MEDIUM priority on SQ creation
         */
        NVME_QUIRK_MEDIUM_PRIO_SQ               = (1 << 7),
+
+       /*
+        * Ignore device provided subnqn.
+        */
+       NVME_QUIRK_IGNORE_DEV_SUBNQN            = (1 << 8),
 };
 
 /*
index 47597046c14f25f5597f65a4966ff4b1c0c71eae..c0d01048ce4dea2e1a58e5834c5e817eece29a82 100644 (file)
@@ -2700,6 +2700,8 @@ static const struct pci_device_id nvme_id_table[] = {
        { PCI_VDEVICE(INTEL, 0xf1a5),   /* Intel 600P/P3100 */
                .driver_data = NVME_QUIRK_NO_DEEPEST_PS |
                                NVME_QUIRK_MEDIUM_PRIO_SQ },
+       { PCI_VDEVICE(INTEL, 0xf1a6),   /* Intel 760p/Pro 7600p */
+               .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
        { PCI_VDEVICE(INTEL, 0x5845),   /* Qemu emulated controller */
                .driver_data = NVME_QUIRK_IDENTIFY_CNS, },
        { PCI_DEVICE(0x1bb1, 0x0100),   /* Seagate Nytro Flash Storage */