Skip to content

Commit 4772e03

Browse files
oulijunjgunthorpe
authored andcommitted
RDMA/hns: Fix bug that caused srq creation to fail
Due to the incorrect use of the seg and obj information, the position of the mtt is calculated incorrectly, and the free space of the page is not enough to store the entire mtt, resulting in access to the next page. This patch fixes this problem. Unable to handle kernel paging request at virtual address ffff00006e3cd000 ... Call trace: hns_roce_write_mtt+0x154/0x2f0 [hns_roce] hns_roce_buf_write_mtt+0xa8/0xd8 [hns_roce] hns_roce_create_srq+0x74c/0x808 [hns_roce] ib_create_srq+0x28/0xc8 Fixes: 0203b14 ("RDMA/hns: Unify the calculation for hem index in hip08") Signed-off-by: chenglang <[email protected]> Signed-off-by: Lijun Ou <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent ea7a5c7 commit 4772e03

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

drivers/infiniband/hw/hns/hns_roce_hem.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
792792
idx_offset = (obj & (table->num_obj - 1)) % obj_per_chunk;
793793
dma_offset = offset = idx_offset * table->obj_size;
794794
} else {
795+
u32 seg_size = 64; /* 8 bytes per BA and 8 BA per segment */
796+
795797
hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, &mhop);
796798
/* mtt mhop */
797799
i = mhop.l0_idx;
@@ -803,8 +805,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
803805
hem_idx = i;
804806

805807
hem = table->hem[hem_idx];
806-
dma_offset = offset = (obj & (table->num_obj - 1)) *
807-
table->obj_size % mhop.bt_chunk_size;
808+
dma_offset = offset = (obj & (table->num_obj - 1)) * seg_size %
809+
mhop.bt_chunk_size;
808810
if (mhop.hop_num == 2)
809811
dma_offset = offset = 0;
810812
}

drivers/infiniband/hw/hns/hns_roce_mr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,6 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev,
746746
struct hns_roce_hem_table *table;
747747
dma_addr_t dma_handle;
748748
__le64 *mtts;
749-
u32 s = start_index * sizeof(u64);
750749
u32 bt_page_size;
751750
u32 i;
752751

@@ -780,7 +779,8 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev *hr_dev,
780779
return -EINVAL;
781780

782781
mtts = hns_roce_table_find(hr_dev, table,
783-
mtt->first_seg + s / hr_dev->caps.mtt_entry_sz,
782+
mtt->first_seg +
783+
start_index / HNS_ROCE_MTT_ENTRY_PER_SEG,
784784
&dma_handle);
785785
if (!mtts)
786786
return -ENOMEM;

0 commit comments

Comments
 (0)