diff options
author | Roland Dreier <rolandd@cisco.com> | 2008-09-30 00:37:33 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-09-30 00:37:33 -0400 |
commit | 208dde28b0f73c0e2dc6be74040fa562e129a6e8 (patch) | |
tree | e4ef7fa60a3411fb6fba868ec1c8549c083e799c /drivers | |
parent | 9824b8f11373b0df806c135a342da9319ef1d893 (diff) |
IB/mthca: Use pci_request_regions()
Back in prehistoric (pre-git!) days, the kernel's MSI-X support did
request_mem_region() on a device's MSI-X tables, which meant that a
driver that enabled MSI-X couldn't use pci_request_regions() (since
that would clash with the PCI layer's MSI-X request).
However, that was removed (by me!) years ago, so mthca can just use
pci_request_regions() and pci_release_regions() instead of its own
much more complicated code that avoids requesting the MSI-X tables.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_catas.c | 15 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_eq.c | 51 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_main.c | 59 |
3 files changed, 14 insertions, 111 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c index cc440f90000b..65ad359fdf16 100644 --- a/drivers/infiniband/hw/mthca/mthca_catas.c +++ b/drivers/infiniband/hw/mthca/mthca_catas.c | |||
@@ -149,18 +149,10 @@ void mthca_start_catas_poll(struct mthca_dev *dev) | |||
149 | ((pci_resource_len(dev->pdev, 0) - 1) & | 149 | ((pci_resource_len(dev->pdev, 0) - 1) & |
150 | dev->catas_err.addr); | 150 | dev->catas_err.addr); |
151 | 151 | ||
152 | if (!request_mem_region(addr, dev->catas_err.size * 4, | ||
153 | DRV_NAME)) { | ||
154 | mthca_warn(dev, "couldn't request catastrophic error region " | ||
155 | "at 0x%lx/0x%x\n", addr, dev->catas_err.size * 4); | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | dev->catas_err.map = ioremap(addr, dev->catas_err.size * 4); | 152 | dev->catas_err.map = ioremap(addr, dev->catas_err.size * 4); |
160 | if (!dev->catas_err.map) { | 153 | if (!dev->catas_err.map) { |
161 | mthca_warn(dev, "couldn't map catastrophic error region " | 154 | mthca_warn(dev, "couldn't map catastrophic error region " |
162 | "at 0x%lx/0x%x\n", addr, dev->catas_err.size * 4); | 155 | "at 0x%lx/0x%x\n", addr, dev->catas_err.size * 4); |
163 | release_mem_region(addr, dev->catas_err.size * 4); | ||
164 | return; | 156 | return; |
165 | } | 157 | } |
166 | 158 | ||
@@ -175,13 +167,8 @@ void mthca_stop_catas_poll(struct mthca_dev *dev) | |||
175 | { | 167 | { |
176 | del_timer_sync(&dev->catas_err.timer); | 168 | del_timer_sync(&dev->catas_err.timer); |
177 | 169 | ||
178 | if (dev->catas_err.map) { | 170 | if (dev->catas_err.map) |
179 | iounmap(dev->catas_err.map); | 171 | iounmap(dev->catas_err.map); |
180 | release_mem_region(pci_resource_start(dev->pdev, 0) + | ||
181 | ((pci_resource_len(dev->pdev, 0) - 1) & | ||
182 | dev->catas_err.addr), | ||
183 | dev->catas_err.size * 4); | ||
184 | } | ||
185 | 172 | ||
186 | spin_lock_irq(&catas_lock); | 173 | spin_lock_irq(&catas_lock); |
187 | list_del(&dev->catas_err.list); | 174 | list_del(&dev->catas_err.list); |
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index cc6858f0b65b..28f0e0c40d7d 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c | |||
@@ -652,27 +652,13 @@ static int mthca_map_reg(struct mthca_dev *dev, | |||
652 | { | 652 | { |
653 | unsigned long base = pci_resource_start(dev->pdev, 0); | 653 | unsigned long base = pci_resource_start(dev->pdev, 0); |
654 | 654 | ||
655 | if (!request_mem_region(base + offset, size, DRV_NAME)) | ||
656 | return -EBUSY; | ||
657 | |||
658 | *map = ioremap(base + offset, size); | 655 | *map = ioremap(base + offset, size); |
659 | if (!*map) { | 656 | if (!*map) |
660 | release_mem_region(base + offset, size); | ||
661 | return -ENOMEM; | 657 | return -ENOMEM; |
662 | } | ||
663 | 658 | ||
664 | return 0; | 659 | return 0; |
665 | } | 660 | } |
666 | 661 | ||
667 | static void mthca_unmap_reg(struct mthca_dev *dev, unsigned long offset, | ||
668 | unsigned long size, void __iomem *map) | ||
669 | { | ||
670 | unsigned long base = pci_resource_start(dev->pdev, 0); | ||
671 | |||
672 | release_mem_region(base + offset, size); | ||
673 | iounmap(map); | ||
674 | } | ||
675 | |||
676 | static int mthca_map_eq_regs(struct mthca_dev *dev) | 662 | static int mthca_map_eq_regs(struct mthca_dev *dev) |
677 | { | 663 | { |
678 | if (mthca_is_memfree(dev)) { | 664 | if (mthca_is_memfree(dev)) { |
@@ -699,9 +685,7 @@ static int mthca_map_eq_regs(struct mthca_dev *dev) | |||
699 | dev->fw.arbel.eq_arm_base) + 4, 4, | 685 | dev->fw.arbel.eq_arm_base) + 4, 4, |
700 | &dev->eq_regs.arbel.eq_arm)) { | 686 | &dev->eq_regs.arbel.eq_arm)) { |
701 | mthca_err(dev, "Couldn't map EQ arm register, aborting.\n"); | 687 | mthca_err(dev, "Couldn't map EQ arm register, aborting.\n"); |
702 | mthca_unmap_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) & | 688 | iounmap(dev->clr_base); |
703 | dev->fw.arbel.clr_int_base, MTHCA_CLR_INT_SIZE, | ||
704 | dev->clr_base); | ||
705 | return -ENOMEM; | 689 | return -ENOMEM; |
706 | } | 690 | } |
707 | 691 | ||
@@ -710,12 +694,8 @@ static int mthca_map_eq_regs(struct mthca_dev *dev) | |||
710 | MTHCA_EQ_SET_CI_SIZE, | 694 | MTHCA_EQ_SET_CI_SIZE, |
711 | &dev->eq_regs.arbel.eq_set_ci_base)) { | 695 | &dev->eq_regs.arbel.eq_set_ci_base)) { |
712 | mthca_err(dev, "Couldn't map EQ CI register, aborting.\n"); | 696 | mthca_err(dev, "Couldn't map EQ CI register, aborting.\n"); |
713 | mthca_unmap_reg(dev, ((pci_resource_len(dev->pdev, 0) - 1) & | 697 | iounmap(dev->eq_regs.arbel.eq_arm); |
714 | dev->fw.arbel.eq_arm_base) + 4, 4, | 698 | iounmap(dev->clr_base); |
715 | dev->eq_regs.arbel.eq_arm); | ||
716 | mthca_unmap_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) & | ||
717 | dev->fw.arbel.clr_int_base, MTHCA_CLR_INT_SIZE, | ||
718 | dev->clr_base); | ||
719 | return -ENOMEM; | 699 | return -ENOMEM; |
720 | } | 700 | } |
721 | } else { | 701 | } else { |
@@ -731,8 +711,7 @@ static int mthca_map_eq_regs(struct mthca_dev *dev) | |||
731 | &dev->eq_regs.tavor.ecr_base)) { | 711 | &dev->eq_regs.tavor.ecr_base)) { |
732 | mthca_err(dev, "Couldn't map ecr register, " | 712 | mthca_err(dev, "Couldn't map ecr register, " |
733 | "aborting.\n"); | 713 | "aborting.\n"); |
734 | mthca_unmap_reg(dev, MTHCA_CLR_INT_BASE, MTHCA_CLR_INT_SIZE, | 714 | iounmap(dev->clr_base); |
735 | dev->clr_base); | ||
736 | return -ENOMEM; | 715 | return -ENOMEM; |
737 | } | 716 | } |
738 | } | 717 | } |
@@ -744,22 +723,12 @@ static int mthca_map_eq_regs(struct mthca_dev *dev) | |||
744 | static void mthca_unmap_eq_regs(struct mthca_dev *dev) | 723 | static void mthca_unmap_eq_regs(struct mthca_dev *dev) |
745 | { | 724 | { |
746 | if (mthca_is_memfree(dev)) { | 725 | if (mthca_is_memfree(dev)) { |
747 | mthca_unmap_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) & | 726 | iounmap(dev->eq_regs.arbel.eq_set_ci_base); |
748 | dev->fw.arbel.eq_set_ci_base, | 727 | iounmap(dev->eq_regs.arbel.eq_arm); |
749 | MTHCA_EQ_SET_CI_SIZE, | 728 | iounmap(dev->clr_base); |
750 | dev->eq_regs.arbel.eq_set_ci_base); | ||
751 | mthca_unmap_reg(dev, ((pci_resource_len(dev->pdev, 0) - 1) & | ||
752 | dev->fw.arbel.eq_arm_base) + 4, 4, | ||
753 | dev->eq_regs.arbel.eq_arm); | ||
754 | mthca_unmap_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) & | ||
755 | dev->fw.arbel.clr_int_base, MTHCA_CLR_INT_SIZE, | ||
756 | dev->clr_base); | ||
757 | } else { | 729 | } else { |
758 | mthca_unmap_reg(dev, MTHCA_ECR_BASE, | 730 | iounmap(dev->eq_regs.tavor.ecr_base); |
759 | MTHCA_ECR_SIZE + MTHCA_ECR_CLR_SIZE, | 731 | iounmap(dev->clr_base); |
760 | dev->eq_regs.tavor.ecr_base); | ||
761 | mthca_unmap_reg(dev, MTHCA_CLR_INT_BASE, MTHCA_CLR_INT_SIZE, | ||
762 | dev->clr_base); | ||
763 | } | 732 | } |
764 | } | 733 | } |
765 | 734 | ||
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 | ||
924 | static 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 | |||
954 | err_bar4_failed: | ||
955 | pci_release_region(pdev, 2); | ||
956 | |||
957 | err_bar2_failed: | ||
958 | release_mem_region(pci_resource_start(pdev, 0) + MTHCA_HCR_BASE, | ||
959 | MTHCA_HCR_SIZE); | ||
960 | |||
961 | return err; | ||
962 | } | ||
963 | |||
964 | static 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 | |||
976 | static int mthca_enable_msi_x(struct mthca_dev *mdev) | 924 | static 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 | ||
1198 | err_free_res: | 1146 | err_free_res: |
1199 | mthca_release_regions(pdev, ddr_hidden); | 1147 | pci_release_regions(pdev); |
1200 | 1148 | ||
1201 | err_disable_pdev: | 1149 | err_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 | } |