diff options
-rw-r--r-- | drivers/nvme/host/pci.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 0b3b4d9fd423..fbc71fac6f1e 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -84,6 +84,7 @@ struct nvme_dev { | |||
84 | struct dma_pool *prp_small_pool; | 84 | struct dma_pool *prp_small_pool; |
85 | unsigned online_queues; | 85 | unsigned online_queues; |
86 | unsigned max_qid; | 86 | unsigned max_qid; |
87 | unsigned int num_vecs; | ||
87 | int q_depth; | 88 | int q_depth; |
88 | u32 db_stride; | 89 | u32 db_stride; |
89 | void __iomem *bar; | 90 | void __iomem *bar; |
@@ -414,7 +415,8 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set) | |||
414 | { | 415 | { |
415 | struct nvme_dev *dev = set->driver_data; | 416 | struct nvme_dev *dev = set->driver_data; |
416 | 417 | ||
417 | return blk_mq_pci_map_queues(set, to_pci_dev(dev->dev), 0); | 418 | return blk_mq_pci_map_queues(set, to_pci_dev(dev->dev), |
419 | dev->num_vecs > 1 ? 1 /* admin queue */ : 0); | ||
418 | } | 420 | } |
419 | 421 | ||
420 | /** | 422 | /** |
@@ -1456,7 +1458,11 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) | |||
1456 | nvmeq->sq_cmds_io = dev->cmb + offset; | 1458 | nvmeq->sq_cmds_io = dev->cmb + offset; |
1457 | } | 1459 | } |
1458 | 1460 | ||
1459 | nvmeq->cq_vector = qid - 1; | 1461 | /* |
1462 | * A queue's vector matches the queue identifier unless the controller | ||
1463 | * has only one vector available. | ||
1464 | */ | ||
1465 | nvmeq->cq_vector = dev->num_vecs == 1 ? 0 : qid; | ||
1460 | result = adapter_alloc_cq(dev, qid, nvmeq); | 1466 | result = adapter_alloc_cq(dev, qid, nvmeq); |
1461 | if (result < 0) | 1467 | if (result < 0) |
1462 | goto release_vector; | 1468 | goto release_vector; |
@@ -1910,6 +1916,10 @@ static int nvme_setup_io_queues(struct nvme_dev *dev) | |||
1910 | int result, nr_io_queues; | 1916 | int result, nr_io_queues; |
1911 | unsigned long size; | 1917 | unsigned long size; |
1912 | 1918 | ||
1919 | struct irq_affinity affd = { | ||
1920 | .pre_vectors = 1 | ||
1921 | }; | ||
1922 | |||
1913 | nr_io_queues = num_possible_cpus(); | 1923 | nr_io_queues = num_possible_cpus(); |
1914 | result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues); | 1924 | result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues); |
1915 | if (result < 0) | 1925 | if (result < 0) |
@@ -1945,11 +1955,12 @@ static int nvme_setup_io_queues(struct nvme_dev *dev) | |||
1945 | * setting up the full range we need. | 1955 | * setting up the full range we need. |
1946 | */ | 1956 | */ |
1947 | pci_free_irq_vectors(pdev); | 1957 | pci_free_irq_vectors(pdev); |
1948 | nr_io_queues = pci_alloc_irq_vectors(pdev, 1, nr_io_queues, | 1958 | result = pci_alloc_irq_vectors_affinity(pdev, 1, nr_io_queues + 1, |
1949 | PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY); | 1959 | PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY, &affd); |
1950 | if (nr_io_queues <= 0) | 1960 | if (result <= 0) |
1951 | return -EIO; | 1961 | return -EIO; |
1952 | dev->max_qid = nr_io_queues; | 1962 | dev->num_vecs = result; |
1963 | dev->max_qid = max(result - 1, 1); | ||
1953 | 1964 | ||
1954 | /* | 1965 | /* |
1955 | * Should investigate if there's a performance win from allocating | 1966 | * Should investigate if there's a performance win from allocating |