diff options
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 6bcde1cb9688..19b7f61cf04c 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -923,17 +923,13 @@ static struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd, | |||
923 | struct mthca_mr *mr; | 923 | struct mthca_mr *mr; |
924 | u64 *page_list; | 924 | u64 *page_list; |
925 | u64 total_size; | 925 | u64 total_size; |
926 | u64 mask; | 926 | unsigned long mask; |
927 | int shift; | 927 | int shift; |
928 | int npages; | 928 | int npages; |
929 | int err; | 929 | int err; |
930 | int i, j, n; | 930 | int i, j, n; |
931 | 931 | ||
932 | /* First check that we have enough alignment */ | 932 | mask = buffer_list[0].addr ^ *iova_start; |
933 | if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) | ||
934 | return ERR_PTR(-EINVAL); | ||
935 | |||
936 | mask = 0; | ||
937 | total_size = 0; | 933 | total_size = 0; |
938 | for (i = 0; i < num_phys_buf; ++i) { | 934 | for (i = 0; i < num_phys_buf; ++i) { |
939 | if (i != 0) | 935 | if (i != 0) |
@@ -947,17 +943,7 @@ static struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd, | |||
947 | if (mask & ~PAGE_MASK) | 943 | if (mask & ~PAGE_MASK) |
948 | return ERR_PTR(-EINVAL); | 944 | return ERR_PTR(-EINVAL); |
949 | 945 | ||
950 | /* Find largest page shift we can use to cover buffers */ | 946 | shift = __ffs(mask | 1 << 31); |
951 | for (shift = PAGE_SHIFT; shift < 31; ++shift) | ||
952 | if (num_phys_buf > 1) { | ||
953 | if ((1ULL << shift) & mask) | ||
954 | break; | ||
955 | } else { | ||
956 | if (1ULL << shift >= | ||
957 | buffer_list[0].size + | ||
958 | (buffer_list[0].addr & ((1ULL << shift) - 1))) | ||
959 | break; | ||
960 | } | ||
961 | 947 | ||
962 | buffer_list[0].size += buffer_list[0].addr & ((1ULL << shift) - 1); | 948 | buffer_list[0].size += buffer_list[0].addr & ((1ULL << shift) - 1); |
963 | buffer_list[0].addr &= ~0ull << shift; | 949 | buffer_list[0].addr &= ~0ull << shift; |