aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_provider.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@mellanox.co.il>2006-01-09 16:50:57 -0500
committerRoland Dreier <rolandd@cisco.com>2006-01-09 16:50:57 -0500
commit6627fa662e86c400284b64c13661fdf6bff05983 (patch)
treeece216b8bbdedd86dbf19e02ce38d9ada18e2984 /drivers/infiniband/hw/mthca/mthca_provider.c
parent5367f2d67c7d0bf1faae90e6e7b4e2ac3c9b5e0f (diff)
IB/mthca: fix page shift calculation in mthca_reg_phys_mr()
For all pages except possibly the last one, the byte beyond the buffer end must be page aligned. Therefore, when computing the page shift to use, OR the end addresses of the buffers as well as the start addresses into the mask we check. Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_provider.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 4cc7e2846df1..30b67c200267 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -783,24 +783,20 @@ static struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd,
783 if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) 783 if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK))
784 return ERR_PTR(-EINVAL); 784 return ERR_PTR(-EINVAL);
785 785
786 if (num_phys_buf > 1 &&
787 ((buffer_list[0].addr + buffer_list[0].size) & ~PAGE_MASK))
788 return ERR_PTR(-EINVAL);
789
790 mask = 0; 786 mask = 0;
791 total_size = 0; 787 total_size = 0;
792 for (i = 0; i < num_phys_buf; ++i) { 788 for (i = 0; i < num_phys_buf; ++i) {
793 if (i != 0 && buffer_list[i].addr & ~PAGE_MASK) 789 if (i != 0)
794 return ERR_PTR(-EINVAL); 790 mask |= buffer_list[i].addr;
795 if (i != 0 && i != num_phys_buf - 1 && 791 if (i != num_phys_buf - 1)
796 (buffer_list[i].size & ~PAGE_MASK)) 792 mask |= buffer_list[i].addr + buffer_list[i].size;
797 return ERR_PTR(-EINVAL);
798 793
799 total_size += buffer_list[i].size; 794 total_size += buffer_list[i].size;
800 if (i > 0)
801 mask |= buffer_list[i].addr;
802 } 795 }
803 796
797 if (mask & ~PAGE_MASK)
798 return ERR_PTR(-EINVAL);
799
804 /* Find largest page shift we can use to cover buffers */ 800 /* Find largest page shift we can use to cover buffers */
805 for (shift = PAGE_SHIFT; shift < 31; ++shift) 801 for (shift = PAGE_SHIFT; shift < 31; ++shift)
806 if (num_phys_buf > 1) { 802 if (num_phys_buf > 1) {