diff options
author | Michael S. Tsirkin <mst@mellanox.co.il> | 2007-02-10 16:13:12 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-02-12 19:16:29 -0500 |
commit | c20e20ab0f3af9a44842ea11287c9ecd034a5d33 (patch) | |
tree | 18c002063c73a3d415b9311ed65549305cfcee0e /drivers | |
parent | 391e4dea7189eef32b0c2d121e7e047110c1b83c (diff) |
IB/mthca: Merge MR and FMR space on 64-bit systems
For Tavor, we currently reserve separate MPT and MTT space for FMRs to
avoid abusing the vmalloc space on 32 bit kernels. No such problem
exists on 64 bit kernels so let's not do it there.
This way we have a shared pool for MR and FMR resources, used on
demand. This will also make it possible to write MTTs for regular
regions directly from driver.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_mr.c | 20 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_profile.c | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index 7d08f2038aff..958c6d5b6bc0 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
@@ -765,7 +765,7 @@ void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr) | |||
765 | int mthca_init_mr_table(struct mthca_dev *dev) | 765 | int mthca_init_mr_table(struct mthca_dev *dev) |
766 | { | 766 | { |
767 | unsigned long addr; | 767 | unsigned long addr; |
768 | int err, i; | 768 | int mpts, mtts, err, i; |
769 | 769 | ||
770 | err = mthca_alloc_init(&dev->mr_table.mpt_alloc, | 770 | err = mthca_alloc_init(&dev->mr_table.mpt_alloc, |
771 | dev->limits.num_mpts, | 771 | dev->limits.num_mpts, |
@@ -799,13 +799,21 @@ int mthca_init_mr_table(struct mthca_dev *dev) | |||
799 | err = -EINVAL; | 799 | err = -EINVAL; |
800 | goto err_fmr_mpt; | 800 | goto err_fmr_mpt; |
801 | } | 801 | } |
802 | mpts = mtts = 1 << i; | ||
803 | } else { | ||
804 | mpts = dev->limits.num_mtt_segs; | ||
805 | mtts = dev->limits.num_mpts; | ||
806 | } | ||
807 | |||
808 | if (!mthca_is_memfree(dev) && | ||
809 | (dev->mthca_flags & MTHCA_FLAG_FMR)) { | ||
802 | 810 | ||
803 | addr = pci_resource_start(dev->pdev, 4) + | 811 | addr = pci_resource_start(dev->pdev, 4) + |
804 | ((pci_resource_len(dev->pdev, 4) - 1) & | 812 | ((pci_resource_len(dev->pdev, 4) - 1) & |
805 | dev->mr_table.mpt_base); | 813 | dev->mr_table.mpt_base); |
806 | 814 | ||
807 | dev->mr_table.tavor_fmr.mpt_base = | 815 | dev->mr_table.tavor_fmr.mpt_base = |
808 | ioremap(addr, (1 << i) * sizeof(struct mthca_mpt_entry)); | 816 | ioremap(addr, mpts * sizeof(struct mthca_mpt_entry)); |
809 | 817 | ||
810 | if (!dev->mr_table.tavor_fmr.mpt_base) { | 818 | if (!dev->mr_table.tavor_fmr.mpt_base) { |
811 | mthca_warn(dev, "MPT ioremap for FMR failed.\n"); | 819 | mthca_warn(dev, "MPT ioremap for FMR failed.\n"); |
@@ -818,19 +826,21 @@ int mthca_init_mr_table(struct mthca_dev *dev) | |||
818 | dev->mr_table.mtt_base); | 826 | dev->mr_table.mtt_base); |
819 | 827 | ||
820 | dev->mr_table.tavor_fmr.mtt_base = | 828 | dev->mr_table.tavor_fmr.mtt_base = |
821 | ioremap(addr, (1 << i) * MTHCA_MTT_SEG_SIZE); | 829 | ioremap(addr, mtts * MTHCA_MTT_SEG_SIZE); |
822 | if (!dev->mr_table.tavor_fmr.mtt_base) { | 830 | if (!dev->mr_table.tavor_fmr.mtt_base) { |
823 | mthca_warn(dev, "MTT ioremap for FMR failed.\n"); | 831 | mthca_warn(dev, "MTT ioremap for FMR failed.\n"); |
824 | err = -ENOMEM; | 832 | err = -ENOMEM; |
825 | goto err_fmr_mtt; | 833 | goto err_fmr_mtt; |
826 | } | 834 | } |
835 | } | ||
827 | 836 | ||
828 | err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, i); | 837 | if (dev->limits.fmr_reserved_mtts) { |
838 | err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, fls(mtts - 1)); | ||
829 | if (err) | 839 | if (err) |
830 | goto err_fmr_mtt_buddy; | 840 | goto err_fmr_mtt_buddy; |
831 | 841 | ||
832 | /* Prevent regular MRs from using FMR keys */ | 842 | /* Prevent regular MRs from using FMR keys */ |
833 | err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, i); | 843 | err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, fls(mtts - 1)); |
834 | if (err) | 844 | if (err) |
835 | goto err_reserve_fmr; | 845 | goto err_reserve_fmr; |
836 | 846 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c index 58d44aa3c302..26bf86d1cfcd 100644 --- a/drivers/infiniband/hw/mthca/mthca_profile.c +++ b/drivers/infiniband/hw/mthca/mthca_profile.c | |||
@@ -277,7 +277,7 @@ u64 mthca_make_profile(struct mthca_dev *dev, | |||
277 | * out of the MR pool. They don't use additional memory, but | 277 | * out of the MR pool. They don't use additional memory, but |
278 | * we assign them as part of the HCA profile anyway. | 278 | * we assign them as part of the HCA profile anyway. |
279 | */ | 279 | */ |
280 | if (mthca_is_memfree(dev)) | 280 | if (mthca_is_memfree(dev) || BITS_PER_LONG == 64) |
281 | dev->limits.fmr_reserved_mtts = 0; | 281 | dev->limits.fmr_reserved_mtts = 0; |
282 | else | 282 | else |
283 | dev->limits.fmr_reserved_mtts = request->fmr_reserved_mtts; | 283 | dev->limits.fmr_reserved_mtts = request->fmr_reserved_mtts; |