Commit b66905e0 authored by Jack Wang's avatar Jack Wang Committed by Leon Romanovsky

RDMA/rtrs-clt: Use the right sg_cnt after ib_dma_map_sg

When iommu is enabled, we hit warnings like this:
WARNING: at rtrs/rtrs.c:178 rtrs_iu_post_rdma_write_imm+0x9b/0x110

rtrs warn on one sge entry length is 0, which is unexpected.

The problem is ib_dma_map_sg augments the SGL into a 'dma mapped SGL'.
This process may change the number of entries and the lengths of each
entry.

Code that touches dma_address is iterating over the 'dma mapped SGL'
and must use dma_nents which returned from ib_dma_map_sg().
So pass the count return from ib_dma_map_sg.

Fixes: 6a98d71d ("RDMA/rtrs: client: main functionality")
Link: https://lore.kernel.org/r/20220818105355.110344-3-haris.iqbal@ionos.comSigned-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
Reviewed-by: default avatarAleksei Marov <aleksei.marov@ionos.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent b16de8b9
...@@ -1004,7 +1004,8 @@ rtrs_clt_get_copy_req(struct rtrs_clt_path *alive_path, ...@@ -1004,7 +1004,8 @@ rtrs_clt_get_copy_req(struct rtrs_clt_path *alive_path,
static int rtrs_post_rdma_write_sg(struct rtrs_clt_con *con, static int rtrs_post_rdma_write_sg(struct rtrs_clt_con *con,
struct rtrs_clt_io_req *req, struct rtrs_clt_io_req *req,
struct rtrs_rbuf *rbuf, bool fr_en, struct rtrs_rbuf *rbuf, bool fr_en,
u32 size, u32 imm, struct ib_send_wr *wr, u32 count, u32 size, u32 imm,
struct ib_send_wr *wr,
struct ib_send_wr *tail) struct ib_send_wr *tail)
{ {
struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); struct rtrs_clt_path *clt_path = to_clt_path(con->c.path);
...@@ -1024,12 +1025,12 @@ static int rtrs_post_rdma_write_sg(struct rtrs_clt_con *con, ...@@ -1024,12 +1025,12 @@ static int rtrs_post_rdma_write_sg(struct rtrs_clt_con *con,
num_sge = 2; num_sge = 2;
ptail = tail; ptail = tail;
} else { } else {
for_each_sg(req->sglist, sg, req->sg_cnt, i) { for_each_sg(req->sglist, sg, count, i) {
sge[i].addr = sg_dma_address(sg); sge[i].addr = sg_dma_address(sg);
sge[i].length = sg_dma_len(sg); sge[i].length = sg_dma_len(sg);
sge[i].lkey = clt_path->s.dev->ib_pd->local_dma_lkey; sge[i].lkey = clt_path->s.dev->ib_pd->local_dma_lkey;
} }
num_sge = 1 + req->sg_cnt; num_sge = 1 + count;
} }
sge[i].addr = req->iu->dma_addr; sge[i].addr = req->iu->dma_addr;
sge[i].length = size; sge[i].length = size;
...@@ -1142,7 +1143,7 @@ static int rtrs_clt_write_req(struct rtrs_clt_io_req *req) ...@@ -1142,7 +1143,7 @@ static int rtrs_clt_write_req(struct rtrs_clt_io_req *req)
*/ */
rtrs_clt_update_all_stats(req, WRITE); rtrs_clt_update_all_stats(req, WRITE);
ret = rtrs_post_rdma_write_sg(req->con, req, rbuf, fr_en, ret = rtrs_post_rdma_write_sg(req->con, req, rbuf, fr_en, count,
req->usr_len + sizeof(*msg), req->usr_len + sizeof(*msg),
imm, wr, &inv_wr); imm, wr, &inv_wr);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment