RDMA/qedr: Use rdma_umem_for_each_dma_block() instead of open-coding
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 4 Sep 2020 22:41:50 +0000 (19:41 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Sep 2020 13:24:53 +0000 (10:24 -0300)
This loop is splitting the DMA SGL into pg_shift sized pages, use the core
code for this directly.

Link: https://lore.kernel.org/r/9-v2-270386b7e60b+28f4-umem_1_jgg@nvidia.com
Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/qedr/verbs.c

index 02368c3df80267cf506c991280f1c7e9ddf34cb0..6605841e27399d1e7bc643a03c5c1307f28b5e59 100644 (file)
@@ -601,11 +601,9 @@ static void qedr_populate_pbls(struct qedr_dev *dev, struct ib_umem *umem,
                               struct qedr_pbl_info *pbl_info, u32 pg_shift)
 {
        int pbe_cnt, total_num_pbes = 0;
-       u32 fw_pg_cnt, fw_pg_per_umem_pg;
        struct qedr_pbl *pbl_tbl;
-       struct sg_dma_page_iter sg_iter;
+       struct ib_block_iter biter;
        struct regpair *pbe;
-       u64 pg_addr;
 
        if (!pbl_info->num_pbes)
                return;
@@ -626,32 +624,25 @@ static void qedr_populate_pbls(struct qedr_dev *dev, struct ib_umem *umem,
 
        pbe_cnt = 0;
 
-       fw_pg_per_umem_pg = BIT(PAGE_SHIFT - pg_shift);
+       rdma_umem_for_each_dma_block (umem, &biter, BIT(pg_shift)) {
+               u64 pg_addr = rdma_block_iter_dma_address(&biter);
 
-       for_each_sg_dma_page (umem->sg_head.sgl, &sg_iter, umem->nmap, 0) {
-               pg_addr = sg_page_iter_dma_address(&sg_iter);
-               for (fw_pg_cnt = 0; fw_pg_cnt < fw_pg_per_umem_pg;) {
-                       pbe->lo = cpu_to_le32(pg_addr);
-                       pbe->hi = cpu_to_le32(upper_32_bits(pg_addr));
+               pbe->lo = cpu_to_le32(pg_addr);
+               pbe->hi = cpu_to_le32(upper_32_bits(pg_addr));
 
-                       pg_addr += BIT(pg_shift);
-                       pbe_cnt++;
-                       total_num_pbes++;
-                       pbe++;
+               pbe_cnt++;
+               total_num_pbes++;
+               pbe++;
 
-                       if (total_num_pbes == pbl_info->num_pbes)
-                               return;
+               if (total_num_pbes == pbl_info->num_pbes)
+                       return;
 
-                       /* If the given pbl is full storing the pbes,
-                        * move to next pbl.
-                        */
-                       if (pbe_cnt == (pbl_info->pbl_size / sizeof(u64))) {
-                               pbl_tbl++;
-                               pbe = (struct regpair *)pbl_tbl->va;
-                               pbe_cnt = 0;
-                       }
-
-                       fw_pg_cnt++;
+               /* If the given pbl is full storing the pbes, move to next pbl.
+                */
+               if (pbe_cnt == (pbl_info->pbl_size / sizeof(u64))) {
+                       pbl_tbl++;
+                       pbe = (struct regpair *)pbl_tbl->va;
+                       pbe_cnt = 0;
                }
        }
 }