aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_main.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c59
1 files changed, 3 insertions, 56 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index fb9f91b60f30..52f60f4eea00 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -921,58 +921,6 @@ err_uar_table_free:
921 return err; 921 return err;
922} 922}
923 923
924static int mthca_request_regions(struct pci_dev *pdev, int ddr_hidden)
925{
926 int err;
927
928 /*
929 * We can't just use pci_request_regions() because the MSI-X
930 * table is right in the middle of the first BAR. If we did
931 * pci_request_region and grab all of the first BAR, then
932 * setting up MSI-X would fail, since the PCI core wants to do
933 * request_mem_region on the MSI-X vector table.
934 *
935 * So just request what we need right now, and request any
936 * other regions we need when setting up EQs.
937 */
938 if (!request_mem_region(pci_resource_start(pdev, 0) + MTHCA_HCR_BASE,
939 MTHCA_HCR_SIZE, DRV_NAME))
940 return -EBUSY;
941
942 err = pci_request_region(pdev, 2, DRV_NAME);
943 if (err)
944 goto err_bar2_failed;
945
946 if (!ddr_hidden) {
947 err = pci_request_region(pdev, 4, DRV_NAME);
948 if (err)
949 goto err_bar4_failed;
950 }
951
952 return 0;
953
954err_bar4_failed:
955 pci_release_region(pdev, 2);
956
957err_bar2_failed:
958 release_mem_region(pci_resource_start(pdev, 0) + MTHCA_HCR_BASE,
959 MTHCA_HCR_SIZE);
960
961 return err;
962}
963
964static void mthca_release_regions(struct pci_dev *pdev,
965 int ddr_hidden)
966{
967 if (!ddr_hidden)
968 pci_release_region(pdev, 4);
969
970 pci_release_region(pdev, 2);
971
972 release_mem_region(pci_resource_start(pdev, 0) + MTHCA_HCR_BASE,
973 MTHCA_HCR_SIZE);
974}
975
976static int mthca_enable_msi_x(struct mthca_dev *mdev) 924static int mthca_enable_msi_x(struct mthca_dev *mdev)
977{ 925{
978 struct msix_entry entries[3]; 926 struct msix_entry entries[3];
@@ -1059,7 +1007,7 @@ static int __mthca_init_one(struct pci_dev *pdev, int hca_type)
1059 if (!(pci_resource_flags(pdev, 4) & IORESOURCE_MEM)) 1007 if (!(pci_resource_flags(pdev, 4) & IORESOURCE_MEM))
1060 ddr_hidden = 1; 1008 ddr_hidden = 1;
1061 1009
1062 err = mthca_request_regions(pdev, ddr_hidden); 1010 err = pci_request_regions(pdev, DRV_NAME);
1063 if (err) { 1011 if (err) {
1064 dev_err(&pdev->dev, "Cannot obtain PCI resources, " 1012 dev_err(&pdev->dev, "Cannot obtain PCI resources, "
1065 "aborting.\n"); 1013 "aborting.\n");
@@ -1196,7 +1144,7 @@ err_free_dev:
1196 ib_dealloc_device(&mdev->ib_dev); 1144 ib_dealloc_device(&mdev->ib_dev);
1197 1145
1198err_free_res: 1146err_free_res:
1199 mthca_release_regions(pdev, ddr_hidden); 1147 pci_release_regions(pdev);
1200 1148
1201err_disable_pdev: 1149err_disable_pdev:
1202 pci_disable_device(pdev); 1150 pci_disable_device(pdev);
@@ -1240,8 +1188,7 @@ static void __mthca_remove_one(struct pci_dev *pdev)
1240 pci_disable_msix(pdev); 1188 pci_disable_msix(pdev);
1241 1189
1242 ib_dealloc_device(&mdev->ib_dev); 1190 ib_dealloc_device(&mdev->ib_dev);
1243 mthca_release_regions(pdev, mdev->mthca_flags & 1191 pci_release_regions(pdev);
1244 MTHCA_FLAG_DDR_HIDDEN);
1245 pci_disable_device(pdev); 1192 pci_disable_device(pdev);
1246 pci_set_drvdata(pdev, NULL); 1193 pci_set_drvdata(pdev, NULL);
1247 } 1194 }