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: 6a98d71dae
("RDMA/rtrs: client: main functionality")
Link: https://lore.kernel.org/r/20220818105355.110344-3-haris.iqbal@ionos.com
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Reviewed-by: Aleksei Marov <aleksei.marov@ionos.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
b16de8b9e7
commit
b66905e04d
|
@ -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,
|
||||
struct rtrs_clt_io_req *req,
|
||||
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 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,
|
|||
num_sge = 2;
|
||||
ptail = tail;
|
||||
} 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].length = sg_dma_len(sg);
|
||||
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].length = size;
|
||||
|
@ -1142,7 +1143,7 @@ static int rtrs_clt_write_req(struct rtrs_clt_io_req *req)
|
|||
*/
|
||||
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),
|
||||
imm, wr, &inv_wr);
|
||||
if (ret) {
|
||||
|
|
Loading…
Reference in New Issue