Skip to content

Commit 681cc36

Browse files
Bart Van Asschedledford
Bart Van Assche
authored andcommitted
IB/srp: Fix infinite loop when FMR sg[0].offset != 0
Avoid that mapping an sg-list in which the first element has a non-zero offset triggers an infinite loop when using FMR. This patch makes the FMR mapping code similar to that of ib_sg_to_pages(). Note: older Mellanox HCAs do not support non-zero offsets for FMR. See also commit 8c4037b ("IB/srp: always avoid non-zero offsets into an FMR"). Reported-by: Alex Estrin <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Cc: <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 52bb8c6 commit 681cc36

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,9 @@ static int srp_map_sg_entry(struct srp_map_state *state,
14021402

14031403
while (dma_len) {
14041404
unsigned offset = dma_addr & ~dev->mr_page_mask;
1405-
if (state->npages == dev->max_pages_per_mr || offset != 0) {
1405+
1406+
if (state->npages == dev->max_pages_per_mr ||
1407+
(state->npages > 0 && offset != 0)) {
14061408
ret = srp_map_finish_fmr(state, ch);
14071409
if (ret)
14081410
return ret;
@@ -1419,12 +1421,12 @@ static int srp_map_sg_entry(struct srp_map_state *state,
14191421
}
14201422

14211423
/*
1422-
* If the last entry of the MR wasn't a full page, then we need to
1424+
* If the end of the MR is not on a page boundary then we need to
14231425
* close it out and start a new one -- we can only merge at page
14241426
* boundaries.
14251427
*/
14261428
ret = 0;
1427-
if (len != dev->mr_page_size)
1429+
if ((dma_addr & ~dev->mr_page_mask) != 0)
14281430
ret = srp_map_finish_fmr(state, ch);
14291431
return ret;
14301432
}

0 commit comments

Comments
 (0)