Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e32efbfc authored by Jens Axboe's avatar Jens Axboe
Browse files

NVMe: make setup work for devices that don't do INTx



The setup/probe part currently relies on INTx being there and
working, that's not always the case. For devices that don't
advertise INTx, enable a single MSIx vector early on and disable
it again before we ask for our full range of queue vecs.

Acked-by: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent b3521729
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -1998,6 +1998,13 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
	/* Deregister the admin queue's interrupt */
	/* Deregister the admin queue's interrupt */
	free_irq(dev->entry[0].vector, adminq);
	free_irq(dev->entry[0].vector, adminq);


	/*
	 * If we enable msix early due to not intx, disable it again before
	 * setting up the full range we need.
	 */
	if (!pdev->irq)
		pci_disable_msix(pdev);

	for (i = 0; i < nr_io_queues; i++)
	for (i = 0; i < nr_io_queues; i++)
		dev->entry[i].entry = i;
		dev->entry[i].entry = i;
	vecs = pci_enable_msix_range(pdev, dev->entry, 1, nr_io_queues);
	vecs = pci_enable_msix_range(pdev, dev->entry, 1, nr_io_queues);
@@ -2150,10 +2157,22 @@ static int nvme_dev_map(struct nvme_dev *dev)
	dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
	dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
	if (!dev->bar)
	if (!dev->bar)
		goto disable;
		goto disable;

	if (readl(&dev->bar->csts) == -1) {
	if (readl(&dev->bar->csts) == -1) {
		result = -ENODEV;
		result = -ENODEV;
		goto unmap;
		goto unmap;
	}
	}

	/*
	 * Some devices don't advertse INTx interrupts, pre-enable a single
	 * MSIX vec for setup. We'll adjust this later.
	 */
	if (!pdev->irq) {
		result = pci_enable_msix(pdev, dev->entry, 1);
		if (result < 0)
			goto unmap;
	}

	cap = readq(&dev->bar->cap);
	cap = readq(&dev->bar->cap);
	dev->q_depth = min_t(int, NVME_CAP_MQES(cap) + 1, NVME_Q_DEPTH);
	dev->q_depth = min_t(int, NVME_CAP_MQES(cap) + 1, NVME_Q_DEPTH);
	dev->db_stride = 1 << NVME_CAP_STRIDE(cap);
	dev->db_stride = 1 << NVME_CAP_STRIDE(cap);