From patchwork Sun May 7 18:29:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13233885 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 041D8C77B7D for ; Sun, 7 May 2023 18:41:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbjEGSlN (ORCPT ); Sun, 7 May 2023 14:41:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjEGSlM (ORCPT ); Sun, 7 May 2023 14:41:12 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67C83A5DF for ; Sun, 7 May 2023 11:41:10 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-528dd896165so2526269a12.2 for ; Sun, 07 May 2023 11:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1683484870; x=1686076870; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xKi+WILmmhxYAJe0cmF3E+FCnKhOeE7oiNAvnKnVcbg=; b=Eo1vWlyfTvTFCniVvzSPL0LeM9Nyik+zDnxNnH9UCpC10q0lY2sF4XQ0UwPQ/K3obp t5O65ZNrRXzayERyHf57cKw75p5fctZHRHxDcDNnrW39qgm4uJXfLJeKmX1QkV42rFYM 5+/4JE403up5LtXx2x8gnaNOj65APMXOI5uYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683484870; x=1686076870; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xKi+WILmmhxYAJe0cmF3E+FCnKhOeE7oiNAvnKnVcbg=; b=UR+aiBNQIsWEbKmn8fXjtc35CNWXnNNLEGSZHaZVquhtYl2COl80Yb2rcDBor9+Rrv P4A7ok+N11MsNFyd15ZPooVqtR0x1nHQHzIPkouGbzDV07G3UI3w7cFOHmt48MtEIUUL tM9ZpmrizPb1mFFdJEyVCF9ugk7x+E0KCVasoMrdIAu80bmlrgztCn35vMt8IcaVQTz4 E6xC+VAzwuKVmLWjigAIEPSz7FwIbh3+/28Kr/apdaTZcQhXMnrlbP9iUlYP70vjJ2/K 0SyM7xr9G4bZOsIAFhxsdVXUqnWGAo/VWHr3MxFlPhViUPVuGSN1TW2+nLHuEzEFQh7C /jUQ== X-Gm-Message-State: AC+VfDw9ML+mxW39x0WEMXWsoCf3zZsuUoALrIXBR5C97HgpPcgHo7Jt +SPPR9UHa8xYWGKAe0kiq89o9gz8gb8027GTA3g= X-Google-Smtp-Source: ACHHUZ4nUOKr1IkFz2DsEPuEKq2fEsyAqcOYpBRHBQSMAS56UT1wOzeFgJfLj8AWbvdfoKsThWaAQg== X-Received: by 2002:a17:902:ea11:b0:1ac:7f56:de04 with SMTP id s17-20020a170902ea1100b001ac7f56de04mr63979plg.45.1683484869801; Sun, 07 May 2023 11:41:09 -0700 (PDT) Received: from dhcp-10-192-206-197.iig.avagotech.net.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id u5-20020a17090282c500b001aafc8cea5fsm5457306plz.148.2023.05.07.11.41.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 May 2023 11:41:07 -0700 (PDT) From: Selvin Xavier To: jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, Selvin Xavier , Kalesh AP , Kashyap Desai Subject: [PATCH for-rc] RDMA/bnxt_re: Fix the page_size used during the MR creation Date: Sun, 7 May 2023 11:29:29 -0700 Message-Id: <1683484169-9539-1-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Driver populates the list of pages used for Memory region wrongly when page size is more than system page size. This is causing a failure when some of the applications that creates MR with page size as 2M. Since HW can support multiple page sizes, pass the correct page size while creating the MR. Also, driver need not adjust the number of pages when HW Queues are created with user memory. It should work with the number of dma blocks returned by ib_umem_num_dma_blocks. Fix this calculation also. Fixes: 0c4dcd602817 ("RDMA/bnxt_re: Refactor hardware queue memory allocation") Fixes: f6919d56388c ("RDMA/bnxt_re: Code refactor while populating user MRs") Signed-off-by: Kalesh AP Signed-off-by: Kashyap Desai Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/qplib_res.c | 12 ++---------- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 7 +++---- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c index 126d4f2..81b0c5e 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c @@ -215,17 +215,9 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq, return -EINVAL; hwq_attr->sginfo->npages = npages; } else { - unsigned long sginfo_num_pages = ib_umem_num_dma_blocks( - hwq_attr->sginfo->umem, hwq_attr->sginfo->pgsize); - + npages = ib_umem_num_dma_blocks(hwq_attr->sginfo->umem, + hwq_attr->sginfo->pgsize); hwq->is_user = true; - npages = sginfo_num_pages; - npages = (npages * PAGE_SIZE) / - BIT_ULL(hwq_attr->sginfo->pgshft); - if ((sginfo_num_pages * PAGE_SIZE) % - BIT_ULL(hwq_attr->sginfo->pgshft)) - if (!npages) - npages++; } if (npages == MAX_PBL_LVL_0_PGS && !hwq_attr->sginfo->nopte) { diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c index b802981..bae7d89 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c @@ -584,16 +584,15 @@ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr, /* Free the hwq if it already exist, must be a rereg */ if (mr->hwq.max_elements) bnxt_qplib_free_hwq(res, &mr->hwq); - /* Use system PAGE_SIZE */ hwq_attr.res = res; hwq_attr.depth = pages; - hwq_attr.stride = buf_pg_size; + hwq_attr.stride = sizeof(dma_addr_t); hwq_attr.type = HWQ_TYPE_MR; hwq_attr.sginfo = &sginfo; hwq_attr.sginfo->umem = umem; hwq_attr.sginfo->npages = pages; - hwq_attr.sginfo->pgsize = PAGE_SIZE; - hwq_attr.sginfo->pgshft = PAGE_SHIFT; + hwq_attr.sginfo->pgsize = buf_pg_size; + hwq_attr.sginfo->pgshft = ilog2(buf_pg_size); rc = bnxt_qplib_alloc_init_hwq(&mr->hwq, &hwq_attr); if (rc) { dev_err(&res->pdev->dev,