nvme: Fix getting PCI vendor id of the NVMe block device
authorBin Meng <bmeng.cn@gmail.com>
Tue, 22 Aug 2017 15:15:07 +0000 (08:15 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 28 Aug 2017 11:17:10 +0000 (07:17 -0400)
The codes currently try to read PCI vendor id of the NVMe block
device by dm_pci_read_config16() with its parameter set as its
root complex controller (ndev->pdev) instead of itself. This is
seriously wrong. We can read the vendor id by passing the correct
udevice parameter to the dm_pci_read_config16() API, however there
is a shortcut by reading the cached vendor id from the PCI device's
struct pci_child_platdata.

While we are here fixing this bug, apparently the quirk stuff handle
codes in nvme_get_info_from_identify() never takes effect since its
logic has never been true at all. Remove these codes completely.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
drivers/nvme/nvme.c
drivers/nvme/nvme.h

index 151fe92479ab8196d7f9119f627ac0ea60991272..2ac0870ae6b72dc7e71abc50a25930164d697141 100644 (file)
@@ -547,7 +547,6 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 
 static int nvme_get_info_from_identify(struct nvme_dev *dev)
 {
-       u16 vendor, device;
        struct nvme_id_ctrl buf, *ctrl = &buf;
        int ret;
        int shift = NVME_CAP_MPSMIN(nvme_readq(&dev->bar->cap)) + 12;
@@ -585,22 +584,6 @@ static int nvme_get_info_from_identify(struct nvme_dev *dev)
                dev->max_transfer_shift = 20;
        }
 
-       /* Apply quirk stuff */
-       dm_pci_read_config16(dev->pdev, PCI_VENDOR_ID, &vendor);
-       dm_pci_read_config16(dev->pdev, PCI_DEVICE_ID, &device);
-       if ((vendor == PCI_VENDOR_ID_INTEL) &&
-           (device == 0x0953) && ctrl->vs[3]) {
-               unsigned int max_transfer_shift;
-               dev->stripe_size = (ctrl->vs[3] + shift);
-               max_transfer_shift = (ctrl->vs[3] + 18);
-               if (dev->max_transfer_shift) {
-                       dev->max_transfer_shift = min(max_transfer_shift,
-                                                     dev->max_transfer_shift);
-               } else {
-                       dev->max_transfer_shift = max_transfer_shift;
-               }
-       }
-
        return 0;
 }
 
@@ -629,8 +612,8 @@ static int nvme_blk_probe(struct udevice *udev)
        struct blk_desc *desc = dev_get_uclass_platdata(udev);
        struct nvme_ns *ns = dev_get_priv(udev);
        u8 flbas;
-       u16 vendor;
        struct nvme_id_ns buf, *id = &buf;
+       struct pci_child_platdata *pplat;
 
        memset(ns, 0, sizeof(*ns));
        ns->dev = ndev;
@@ -649,8 +632,8 @@ static int nvme_blk_probe(struct udevice *udev)
        desc->log2blksz = ns->lba_shift;
        desc->blksz = 1 << ns->lba_shift;
        desc->bdev = udev;
-       dm_pci_read_config16(ndev->pdev, PCI_VENDOR_ID, &vendor);
-       sprintf(desc->vendor, "0x%.4x", vendor);
+       pplat = dev_get_parent_platdata(udev->parent);
+       sprintf(desc->vendor, "0x%.4x", pplat->vendor);
        memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
        memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
        part_init(desc);
@@ -791,7 +774,6 @@ static int nvme_probe(struct udevice *udev)
        struct nvme_dev *ndev = dev_get_priv(udev);
        u64 cap;
 
-       ndev->pdev = pci_get_controller(udev);
        ndev->instance = trailing_strtol(udev->name);
 
        INIT_LIST_HEAD(&ndev->namespaces);
index 267884e249807766c5fcf0ae691bcd5d36e22c09..cd411be83d550287dbdcfb25eba931f81d7b413a 100644 (file)
@@ -608,7 +608,6 @@ struct nvme_dev {
        struct list_head node;
        struct nvme_queue **queues;
        u32 __iomem *dbs;
-       struct udevice *pdev;
        int instance;
        unsigned queue_count;
        unsigned online_queues;