Skip to contentSkip to conversation

RDMA/mana_ib: fix a bug in calculating the wrong page table index when 64kb page table is used

PATCH In review [email protected] 4 participants 6 messages Aug 28, 2024 – Aug 30, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/mana_ib: fix a bug in calculating the wrong page table index when 64kb page table is used

From: Long Li <[email protected]>

MANA hardware uses 4k page size. When calculating the page table index, it should use the hardware page size, not the system page size.

Fixes 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter")
---
 drivers/infiniband/hw/mana/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mana/main.c +1 -1
index d13abc954d2a..f68f54aea820 100644
@@ -383,7 +383,7 @@ static int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem
 
 	create_req->length = umem->length;
 	create_req->offset_in_page = ib_umem_dma_offset(umem, page_sz);
-	create_req->gdma_page_type = order_base_2(page_sz) - PAGE_SHIFT;
+	create_req->gdma_page_type = order_base_2(page_sz) - MANA_PAGE_SHIFT;
 	create_req->page_count = num_pages_total;
 
 	ibdev_dbg(&dev->ib_dev, "size_dma_region %lu num_pages_total %lu\n",
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 RDMA/mana_ib: use the correct page size for mapping user-mode doorbell page

From: Long Li <[email protected]>

When mapping doorbell page from user-mode, the driver should use the system page size as the doorbell is allocated via mmap() from user-mode.

Fixes 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter")
---
 drivers/infiniband/hw/mana/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mana/main.c +2 -2
index f68f54aea820..b26c4ebec2e0 100644
@@ -511,13 +511,13 @@ int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma)
 	      PAGE_SHIFT;
 	prot = pgprot_writecombine(vma->vm_page_prot);
 
-	ret = rdma_user_mmap_io(ibcontext, vma, pfn, gc->db_page_size, prot,
+	ret = rdma_user_mmap_io(ibcontext, vma, pfn, PAGE_SIZE, prot,
 				NULL);
 	if (ret)
 		ibdev_dbg(ibdev, "can't rdma_user_mmap_io ret %d\n", ret);
 	else
 		ibdev_dbg(ibdev, "mapped I/O pfn 0x%llx page_size %u, ret %d\n",
-			  pfn, gc->db_page_size, ret);
+			  pfn, PAGE_SIZE, ret);
 
 	return ret;
 }
Signature · 1 line
2.17.1
#4 lore raw
In reply to [email protected]
Quoted 11 lines · On Wed, Aug 28, 2024 at 01:06:08PM -0700, [email protected] wrote:

From: Long Li <[email protected]>

MANA hardware uses 4k page size. When calculating the page table index, it should use the hardware page size, not the system page size.

Fixes 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter")
---
 drivers/infiniband/hw/mana/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

These two patches are RDMA ones, please fix the target tree, rephrase the commit title to simplify it and resend.

Thanks

Quoted 17 lines
drivers/infiniband/hw/mana/main.c +1 -1
index d13abc954d2a..f68f54aea820 100644
@@ -383,7 +383,7 @@ static int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem
 
 	create_req->length = umem->length;
 	create_req->offset_in_page = ib_umem_dma_offset(umem, page_sz);
-	create_req->gdma_page_type = order_base_2(page_sz) - PAGE_SHIFT;
+	create_req->gdma_page_type = order_base_2(page_sz) - MANA_PAGE_SHIFT;
 	create_req->page_count = num_pages_total;
 
 	ibdev_dbg(&dev->ib_dev, "size_dma_region %lu num_pages_total %lu\n",
Signature · 1 line
2.17.1
reviewer
#2 lore raw

Re: [PATCH net] RDMA/mana_ib: use the correct page size for mapping user-mode doorbell page

In reply to [email protected]
Quoted 19 lines · On Wed, Aug 28, 2024 at 01:06:09PM -0700, [email protected] wrote:

From: Long Li <[email protected]>

When mapping doorbell page from user-mode, the driver should use the system page size as the doorbell is allocated via mmap() from user-mode.

Fixes 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter")
---
 drivers/infiniband/hw/mana/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mana/main.c +0 -0
index f68f54aea820..b26c4ebec2e0 100644
@@ -511,13 +511,13 @@ int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma)
 	      PAGE_SHIFT;
 	prot = pgprot_writecombine(vma->vm_page_prot);

drivers/infiniband/hw/mana/main.c int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma) · line 520

Quoted 10 lines
drivers/infiniband/hw/mana/main.c +2 -2
 
-	ret = rdma_user_mmap_io(ibcontext, vma, pfn, gc->db_page_size, prot,
+	ret = rdma_user_mmap_io(ibcontext, vma, pfn, PAGE_SIZE, prot,
 				NULL);
 	if (ret)
 		ibdev_dbg(ibdev, "can't rdma_user_mmap_io ret %d\n", ret);
 	else
 		ibdev_dbg(ibdev, "mapped I/O pfn 0x%llx page_size %u, ret %d\n",
-			  pfn, gc->db_page_size, ret);
+			  pfn, PAGE_SIZE, ret);

This is not a full review, but according to both clang-18 and gcc-14, this patch should also update the format specifier from %u to %lu.

Quoted 7 lines
drivers/infiniband/hw/mana/main.c +0 -0
 	return ret;
 }
Signature · 1 line
2.17.1
#3 lore raw

RE: [PATCH net] RDMA/mana_ib: use the correct page size for mapping user-mode doorbell page

Quoted 37 lines

Subject: Re: [PATCH net] RDMA/mana_ib: use the correct page size for mapping user-mode doorbell page

drivers/infiniband/hw/mana/main.c int mana_ib_mmap(struct ib_ucontext

Quoted 19 lines · On Wed, Aug 28, 2024 at 01:06:09PM -0700, [email protected] wrote:

From: Long Li <[email protected]>

When mapping doorbell page from user-mode, the driver should use the system page size as the doorbell is allocated via mmap() from user-mode.

Fixes 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure

Network Adapter")

---
 drivers/infiniband/hw/mana/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mana/main.c +0 -0
index f68f54aea820..b26c4ebec2e0 100644
@@ -511,13 +511,13 @@ int mana_ib_mmap(struct ib_ucontext

*ibcontext, struct vm_area_struct *vma)

drivers/infiniband/hw/mana/main.c int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma)

Quoted 4 lines
drivers/infiniband/hw/mana/main.c +0 -1
 	      PAGE_SHIFT;
 	prot = pgprot_writecombine(vma->vm_page_prot);
 
-	ret = rdma_user_mmap_io(ibcontext, vma, pfn, gc->db_page_size,

prot,

drivers/infiniband/hw/mana/main.c int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma)

Quoted 6 lines
drivers/infiniband/hw/mana/main.c +1 -0
+	ret = rdma_user_mmap_io(ibcontext, vma, pfn, PAGE_SIZE, prot,
 				NULL);
 	if (ret)
 		ibdev_dbg(ibdev, "can't rdma_user_mmap_io ret %d\n", ret);
 	else
 		ibdev_dbg(ibdev, "mapped I/O pfn 0x%llx page_size %u,

ret %d\n",

Quoted 5 lines

drivers/infiniband/hw/mana/main.c int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma) · line 520

Quoted 2 lines
drivers/infiniband/hw/mana/main.c +1 -1
-			  pfn, gc->db_page_size, ret);
+			  pfn, PAGE_SIZE, ret);

This is not a full review, but according to both clang-18 and gcc-14, this patch should also update the format specifier from %u to %lu.

Thank you. Will send v2 to fix it.

Long

#5 lore raw
In reply to Leon Romanovsky
Quoted 18 lines

Subject: Re: [PATCH net] RDMA/mana_ib: fix a bug in calculating the wrong page table index when 64kb page table is used

Quoted 5 lines · On Wed, Aug 28, 2024 at 01:06:08PM -0700, [email protected] wrote:

From: Long Li <[email protected]>

MANA hardware uses 4k page size. When calculating the page table index, it should use the hardware page size, not the system page size.

Quoted 7 lines
Fixes 0266a177631d ("RDMA/mana_ib: Add a driver for Microsoft Azure

Network Adapter")

---
 drivers/infiniband/hw/mana/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines

These two patches are RDMA ones, please fix the target tree, rephrase the commit title to simplify it and resend.

Thanks

I'm sending v2 to have those fixed.

Long