summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Moroni <jmoroni@google.com>2026-10-22 21:06:50 +0000
committerLeon Romanovsky <leon@kernel.org>2026-11-03 07:14:46 -0500
commitcefc2270e42baed46d64d7d79fa23172bbad9533 (patch)
tree9a2da38ed09efdcc278f3460470eac6a8dc6cd4c
parentd706625c62b45135ffd6f40b669081c4896dde6f (diff)
RDMA/irdma: Fix paged PBLE and virtual AEQ for PAGE_SIZE > 4K
HMC page descriptors and the virtual AEQ PBL always assume 4K HW pages, but irdma_map_vm_page_list() returns one DMA address per PAGE_SIZE page and irdma_pble_get_paged_mem() sizes the chunk as PAGE_SIZE * pg_cnt. This breaks when PAGE_SIZE is greater than 4K. For example, with a 64K PAGE_SIZE, the second HW page points to vaddr+64K whereas the driver assumes it to be at vaddr+4096, etc. It also ends up using an incorrect chunk size which causes each paged chunk to claim 16x more PBL entries than what actually exist. Fix these issues by taking into account the potential difference between the HW page size (4K) and the system PAGE_SIZE during allocation and mapping (so on a 64K kernel, each page ends up populating 16 PDs, etc.). Fixes: 44d9e52977a1 ("RDMA/irdma: Implement device initialization definitions") Fixes: 915cc7ac0f8e ("RDMA/irdma: Add miscellaneous utility definitions") Tested-by: Leah Li <leahlijuan@google.com> Signed-off-by: Jacob Moroni <jmoroni@google.com> Link: https://patch.msgid.link/20261022210650.1182000-3-jmoroni@google.com Acked-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
-rw-r--r--drivers/infiniband/hw/irdma/hw.c4
-rw-r--r--drivers/infiniband/hw/irdma/utils.c22
2 files changed, 15 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/irdma/hw.c b/drivers/infiniband/hw/irdma/hw.c
index fbb8fb47d0d1..1d57b3c9f490 100644
--- a/drivers/infiniband/hw/irdma/hw.c
+++ b/drivers/infiniband/hw/irdma/hw.c
@@ -700,7 +700,7 @@ static void irdma_destroy_cqp(struct irdma_pci_f *rf)
static void irdma_destroy_virt_aeq(struct irdma_pci_f *rf)
{
struct irdma_aeq *aeq = &rf->aeq;
- u32 pg_cnt = DIV_ROUND_UP(aeq->mem.size, PAGE_SIZE);
+ u32 pg_cnt = DIV_ROUND_UP(aeq->mem.size, IRDMA_HW_PAGE_SIZE);
dma_addr_t *pg_arr = (dma_addr_t *)aeq->palloc.level1.addr;
irdma_unmap_vm_page_list(&rf->hw, pg_arr, pg_cnt);
@@ -1479,7 +1479,7 @@ static int irdma_create_virt_aeq(struct irdma_pci_f *rf, u32 size)
if (!aeq->mem.va)
return -ENOMEM;
- pg_cnt = DIV_ROUND_UP(aeq->mem.size, PAGE_SIZE);
+ pg_cnt = DIV_ROUND_UP(aeq->mem.size, IRDMA_HW_PAGE_SIZE);
status = irdma_get_pble(rf->pble_rsrc, &aeq->palloc, pg_cnt, true);
if (status) {
vfree(aeq->mem.va);
diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
index 290ad02ed657..3efc4125bb59 100644
--- a/drivers/infiniband/hw/irdma/utils.c
+++ b/drivers/infiniband/hw/irdma/utils.c
@@ -2199,20 +2199,24 @@ int irdma_map_vm_page_list(struct irdma_hw *hw, void *va, dma_addr_t *pg_dma,
u32 pg_cnt)
{
struct page *vm_page;
- int i;
+ dma_addr_t dma;
+ u32 i, j;
u8 *addr;
addr = (u8 *)(uintptr_t)va;
- for (i = 0; i < pg_cnt; i++) {
+ for (i = 0; i < pg_cnt; i += IRDMA_HW_PAGES_PER_PAGE) {
vm_page = vmalloc_to_page(addr);
if (!vm_page)
goto err;
- pg_dma[i] = dma_map_page(hw->device, vm_page, 0, PAGE_SIZE,
- DMA_BIDIRECTIONAL);
- if (dma_mapping_error(hw->device, pg_dma[i]))
+ dma = dma_map_page(hw->device, vm_page, 0, PAGE_SIZE,
+ DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(hw->device, dma))
goto err;
+ for (j = 0; j < IRDMA_HW_PAGES_PER_PAGE && i + j < pg_cnt; j++)
+ pg_dma[i + j] = dma + j * IRDMA_HW_PAGE_SIZE;
+
addr += PAGE_SIZE;
}
@@ -2225,9 +2229,9 @@ err:
void irdma_unmap_vm_page_list(struct irdma_hw *hw, dma_addr_t *pg_dma, u32 pg_cnt)
{
- int i;
+ u32 i;
- for (i = 0; i < pg_cnt; i++)
+ for (i = 0; i < pg_cnt; i += IRDMA_HW_PAGES_PER_PAGE)
dma_unmap_page(hw->device, pg_dma[i], PAGE_SIZE, DMA_BIDIRECTIONAL);
}
@@ -2254,7 +2258,7 @@ done:
/**
* irdma_pble_get_paged_mem -allocate paged memory for pbles
* @chunk: chunk to add for paged memory
- * @pg_cnt: number of pages needed
+ * @pg_cnt: number of HW (4K) pages needed
*/
int irdma_pble_get_paged_mem(struct irdma_chunk *chunk, u32 pg_cnt)
{
@@ -2265,7 +2269,7 @@ int irdma_pble_get_paged_mem(struct irdma_chunk *chunk, u32 pg_cnt)
if (!chunk->dmainfo.dmaaddrs)
return -ENOMEM;
- size = PAGE_SIZE * pg_cnt;
+ size = pg_cnt * IRDMA_HW_PAGE_SIZE;
va = vmalloc(size);
if (!va)
goto err;