]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
nvme: add explicit quirk handling
authorChristoph Hellwig <hch@lst.de>
Mon, 19 Dec 2016 20:27:49 +0000 (12:27 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 1 Jun 2017 20:40:38 +0000 (13:40 -0700)
Add an enum for all workarounds not in the spec and identify the affected
controllers at probe time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 106198edb74cdf3fe1aefa6ad1e199b58ab7c4cb)

Orabug: 25130845
Conflicts:
drivers/nvme/host/pci.c

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index 8906447555f6308346d943e9421972420600ea9b..518eba29682b0e8414d669843df24c0850e84ce9 100644 (file)
@@ -32,6 +32,18 @@ enum {
        NVME_NS_LIGHTNVM        = 1,
 };
 
+/*
+ * List of workarounds for devices that required behavior not specified in
+ * the standard.
+ */
+enum nvme_quirks {
+       /*
+        * Prefers I/O aligned to a stripe size specified in a vendor
+        * specific Identify field.
+        */
+       NVME_QUIRK_STRIPE_SIZE                  = (1 << 0),
+};
+
 struct nvme_ctrl {
        const struct nvme_ctrl_ops *ops;
        struct request_queue *admin_q;
@@ -46,6 +58,7 @@ struct nvme_ctrl {
        u16 abort_limit;
        u8 event_limit;
        u8 vwc;
+       unsigned long quirks;
 };
 
 /*
index f6aa2e4d4e10b1c788a6e3613c3adeb3c614f564..e05d9bb40b4a8b00325a0bf75450737fea69472d 100644 (file)
@@ -2126,7 +2126,6 @@ static void nvme_dev_scan(struct work_struct *work)
  */
 static int nvme_dev_add(struct nvme_dev *dev)
 {
-       struct pci_dev *pdev = to_pci_dev(dev->dev);
        int res;
        struct nvme_id_ctrl *ctrl;
        int shift = NVME_CAP_MPSMIN(lo_hi_readq(dev->bar + NVME_REG_CAP)) + 12;
@@ -2148,8 +2147,7 @@ static int nvme_dev_add(struct nvme_dev *dev)
        else
                dev->max_hw_sectors = UINT_MAX;
 
-       if ((pdev->vendor == PCI_VENDOR_ID_INTEL) &&
-                       (pdev->device == 0x0953) && ctrl->vs[3]) {
+       if ((dev->ctrl.quirks & NVME_QUIRK_STRIPE_SIZE) && ctrl->vs[3]) {
                unsigned int max_hw_sectors;
 
                dev->stripe_size = 1 << (ctrl->vs[3] + shift);
@@ -2851,6 +2849,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        dev->ctrl.ops = &nvme_pci_ctrl_ops;
        dev->ctrl.dev = dev->dev;
+       dev->ctrl.quirks = id->driver_data;
 
        result = nvme_set_instance(dev);
        if (result)
@@ -2978,6 +2977,8 @@ static const struct pci_error_handlers nvme_err_handler = {
 #define PCI_CLASS_STORAGE_EXPRESS      0x010802
 
 static const struct pci_device_id nvme_id_table[] = {
+       { PCI_VDEVICE(INTEL, 0x0953),
+               .driver_data = NVME_QUIRK_STRIPE_SIZE, },
        { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001) },
        { 0, }