RDMA/irdma: Do not request 2-level PBLEs for CQ alloc
authorMustafa Ismail <mustafa.ismail@intel.com>
Tue, 15 Nov 2022 01:17:01 +0000 (19:17 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:32 +0000 (13:32 +0100)
[ Upstream commit 8f7e2daa6336f9f4b6f8a4715a809674606df16b ]

When allocating PBLE's for a large CQ, it is possible
that a 2-level PBLE is returned which would cause the
CQ allocation to fail since 1-level is assumed and checked for.
Fix this by requesting a level one PBLE only.

Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/20221115011701.1379-4-shiraz.saleem@intel.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/irdma/verbs.c

index 01d0dc4..dc3f5f3 100644 (file)
@@ -2329,9 +2329,10 @@ static bool irdma_check_mr_contiguous(struct irdma_pble_alloc *palloc,
  * @rf: RDMA PCI function
  * @iwmr: mr pointer for this memory registration
  * @use_pbles: flag if to use pble's
+ * @lvl_1_only: request only level 1 pble if true
  */
 static int irdma_setup_pbles(struct irdma_pci_f *rf, struct irdma_mr *iwmr,
-                            bool use_pbles)
+                            bool use_pbles, bool lvl_1_only)
 {
        struct irdma_pbl *iwpbl = &iwmr->iwpbl;
        struct irdma_pble_alloc *palloc = &iwpbl->pble_alloc;
@@ -2342,7 +2343,7 @@ static int irdma_setup_pbles(struct irdma_pci_f *rf, struct irdma_mr *iwmr,
 
        if (use_pbles) {
                status = irdma_get_pble(rf->pble_rsrc, palloc, iwmr->page_cnt,
-                                       false);
+                                       lvl_1_only);
                if (status)
                        return status;
 
@@ -2385,16 +2386,10 @@ static int irdma_handle_q_mem(struct irdma_device *iwdev,
        bool ret = true;
 
        pg_size = iwmr->page_size;
-       err = irdma_setup_pbles(iwdev->rf, iwmr, use_pbles);
+       err = irdma_setup_pbles(iwdev->rf, iwmr, use_pbles, true);
        if (err)
                return err;
 
-       if (use_pbles && palloc->level != PBLE_LEVEL_1) {
-               irdma_free_pble(iwdev->rf->pble_rsrc, palloc);
-               iwpbl->pbl_allocated = false;
-               return -ENOMEM;
-       }
-
        if (use_pbles)
                arr = palloc->level1.addr;
 
@@ -2870,7 +2865,7 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
        case IRDMA_MEMREG_TYPE_MEM:
                use_pbles = (iwmr->page_cnt != 1);
 
-               err = irdma_setup_pbles(iwdev->rf, iwmr, use_pbles);
+               err = irdma_setup_pbles(iwdev->rf, iwmr, use_pbles, false);
                if (err)
                        goto error;