goto err_umem;
 
        mlx5_ib_cont_pages(cq->buf.umem, ucmd.buf_addr, 0, &npages, &page_shift,
-                          &ncont, NULL);
+                          &ncont);
        mlx5_ib_dbg(dev, "addr 0x%llx, size %u, npages %d, page_shift %d, ncont %d\n",
                    ucmd.buf_addr, entries * ucmd.cqe_size, npages, page_shift, ncont);
 
                return err;
        }
 
-       mlx5_ib_cont_pages(umem, ucmd.buf_addr, 0, &npages, page_shift,
-                          npas, NULL);
+       mlx5_ib_cont_pages(umem, ucmd.buf_addr, 0, &npages, page_shift, npas);
 
        cq->resize_umem = umem;
        *cqe_size = ucmd.cqe_size;
 
 
        mlx5_ib_cont_pages(obj->umem, obj->umem->address,
                           MLX5_MKEY_PAGE_SHIFT_MASK, &npages,
-                          &obj->page_shift, &obj->ncont, NULL);
+                          &obj->page_shift, &obj->ncont);
 
        if (!npages) {
                ib_umem_release(obj->umem);
 
  * @count: number of PAGE_SIZE pages covered by umem
  * @shift: page shift for the compound pages found in the region
  * @ncont: number of compund pages
- * @order: log2 of the number of compound pages
  */
 void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr,
                        unsigned long max_page_shift,
                        int *count, int *shift,
-                       int *ncont, int *order)
+                       int *ncont)
 {
        unsigned long tmp;
        unsigned long m;
                *shift = odp->page_shift;
                *ncont = ib_umem_odp_num_pages(odp);
                *count = *ncont << (*shift - PAGE_SHIFT);
-               if (order)
-                       *order = ilog2(roundup_pow_of_two(*count));
                return;
        }
 
 
        if (i) {
                m = min_t(unsigned long, ilog2(roundup_pow_of_two(i)), m);
-
-               if (order)
-                       *order = ilog2(roundup_pow_of_two(i) >> m);
-
                *ncont = DIV_ROUND_UP(i, (1 << m));
        } else {
                m  = 0;
-
-               if (order)
-                       *order = 0;
-
                *ncont = 0;
        }
        *shift = PAGE_SHIFT + m;
 
 void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr,
                        unsigned long max_page_shift,
                        int *count, int *shift,
-                       int *ncont, int *order);
+                       int *ncont);
 void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
                            int page_shift, size_t offset, size_t num_pages,
                            __be64 *pas, int access_flags);
 
        int npages;
        int page_shift;
        int ncont;
-       int order;
 
        mlx5_ib_cont_pages(umem, iova, MLX5_MKEY_PAGE_SHIFT_MASK, &npages,
-                          &page_shift, &ncont, &order);
-       ent = mr_cache_ent_from_order(dev, order);
+                          &page_shift, &ncont);
+       ent = mr_cache_ent_from_order(dev, order_base_2(ib_umem_num_dma_blocks(
+                                                  umem, 1UL << page_shift)));
        if (!ent)
                return ERR_PTR(-E2BIG);
 
                return ERR_PTR(-ENOMEM);
 
        mlx5_ib_cont_pages(umem, iova, MLX5_MKEY_PAGE_SHIFT_MASK, &npages,
-                          &page_shift, &ncont, NULL);
+                          &page_shift, &ncont);
 
        mr->page_shift = page_shift;
        mr->ibmr.pd = pd;
 
                return PTR_ERR(*umem);
        }
 
-       mlx5_ib_cont_pages(*umem, addr, 0, npages, page_shift, ncont, NULL);
+       mlx5_ib_cont_pages(*umem, addr, 0, npages, page_shift, ncont);
 
        err = mlx5_ib_get_buf_offset(addr, *page_shift, offset);
        if (err) {
        }
 
        mlx5_ib_cont_pages(rwq->umem, ucmd->buf_addr, 0, &npages, &page_shift,
-                          &ncont, NULL);
+                          &ncont);
        err = mlx5_ib_get_buf_offset(ucmd->buf_addr, page_shift,
                                     &rwq->rq_page_offset);
        if (err) {
 
        }
 
        mlx5_ib_cont_pages(srq->umem, ucmd.buf_addr, 0, &npages,
-                          &page_shift, &ncont, NULL);
+                          &page_shift, &ncont);
        err = mlx5_ib_get_buf_offset(ucmd.buf_addr, page_shift,
                                     &offset);
        if (err) {