summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew.r.wilcox@intel.com>2011-02-01 22:24:35 +0100
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2011-11-04 20:52:54 +0100
commit574e8b95bc3780e10e9b5e9d51074d503dd3d5d9 (patch)
tree084c993dd157fe9d3bfd427cbbdabcc6a618b6be
parentNVMe: Allow queues to be allocated above 4GB (diff)
downloadlinux-574e8b95bc3780e10e9b5e9d51074d503dd3d5d9.tar.xz
linux-574e8b95bc3780e10e9b5e9d51074d503dd3d5d9.zip
NVMe: Request I/O regions
Calling pci_request_selected_regions() reserves these regions for our use. Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
-rw-r--r--drivers/block/nvme.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 46f872021369..bda91178f475 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -1088,7 +1088,7 @@ static void nvme_release_instance(struct nvme_dev *dev)
static int __devinit nvme_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
- int result = -ENOMEM;
+ int bars, result = -ENOMEM;
struct nvme_dev *dev;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
@@ -1106,6 +1106,9 @@ static int __devinit nvme_probe(struct pci_dev *pdev,
if (pci_enable_device_mem(pdev))
goto free;
pci_set_master(pdev);
+ bars = pci_select_bars(pdev, IORESOURCE_MEM);
+ if (pci_request_selected_regions(pdev, bars, "nvme"))
+ goto disable;
INIT_LIST_HEAD(&dev->namespaces);
dev->pci_dev = pdev;
@@ -1118,7 +1121,7 @@ static int __devinit nvme_probe(struct pci_dev *pdev,
dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
if (!dev->bar) {
result = -ENOMEM;
- goto disable;
+ goto disable_msix;
}
result = nvme_configure_admin_queue(dev);
@@ -1135,10 +1138,12 @@ static int __devinit nvme_probe(struct pci_dev *pdev,
nvme_free_queues(dev);
unmap:
iounmap(dev->bar);
- disable:
+ disable_msix:
pci_disable_msix(pdev);
nvme_release_instance(dev);
+ disable:
pci_disable_device(pdev);
+ pci_release_regions(pdev);
free:
kfree(dev->queues);
kfree(dev->entry);
@@ -1154,6 +1159,7 @@ static void __devexit nvme_remove(struct pci_dev *pdev)
iounmap(dev->bar);
nvme_release_instance(dev);
pci_disable_device(pdev);
+ pci_release_regions(pdev);
kfree(dev->queues);
kfree(dev->entry);
kfree(dev);