提交 b0768080 编写于 作者: M Mike Marciniszyn 提交者: Nicholas Bellinger

ib_srpt: Use correct ib_sg_dma primitives

The code was incorrectly using sg_dma_address() and
sg_dma_len() instead of ib_sg_dma_address() and
ib_sg_dma_len().

This prevents srpt from functioning with the
Intel HCA and indeed will corrupt memory
badly.

Cc: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Tested-by: NVinod Kumar <vinod.kumar@intel.com>
Signed-off-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
Cc: stable@vger.kernel.org # 3.3+
Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
上级 e3d4440c
...@@ -1078,6 +1078,7 @@ static void srpt_unmap_sg_to_ib_sge(struct srpt_rdma_ch *ch, ...@@ -1078,6 +1078,7 @@ static void srpt_unmap_sg_to_ib_sge(struct srpt_rdma_ch *ch,
static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
struct srpt_send_ioctx *ioctx) struct srpt_send_ioctx *ioctx)
{ {
struct ib_device *dev = ch->sport->sdev->device;
struct se_cmd *cmd; struct se_cmd *cmd;
struct scatterlist *sg, *sg_orig; struct scatterlist *sg, *sg_orig;
int sg_cnt; int sg_cnt;
...@@ -1124,7 +1125,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, ...@@ -1124,7 +1125,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
db = ioctx->rbufs; db = ioctx->rbufs;
tsize = cmd->data_length; tsize = cmd->data_length;
dma_len = sg_dma_len(&sg[0]); dma_len = ib_sg_dma_len(dev, &sg[0]);
riu = ioctx->rdma_ius; riu = ioctx->rdma_ius;
/* /*
...@@ -1155,7 +1156,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, ...@@ -1155,7 +1156,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
++j; ++j;
if (j < count) { if (j < count) {
sg = sg_next(sg); sg = sg_next(sg);
dma_len = sg_dma_len(sg); dma_len = ib_sg_dma_len(
dev, sg);
} }
} }
} else { } else {
...@@ -1192,8 +1194,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, ...@@ -1192,8 +1194,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
tsize = cmd->data_length; tsize = cmd->data_length;
riu = ioctx->rdma_ius; riu = ioctx->rdma_ius;
sg = sg_orig; sg = sg_orig;
dma_len = sg_dma_len(&sg[0]); dma_len = ib_sg_dma_len(dev, &sg[0]);
dma_addr = sg_dma_address(&sg[0]); dma_addr = ib_sg_dma_address(dev, &sg[0]);
/* this second loop is really mapped sg_addres to rdma_iu->ib_sge */ /* this second loop is really mapped sg_addres to rdma_iu->ib_sge */
for (i = 0, j = 0; for (i = 0, j = 0;
...@@ -1216,8 +1218,10 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, ...@@ -1216,8 +1218,10 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
++j; ++j;
if (j < count) { if (j < count) {
sg = sg_next(sg); sg = sg_next(sg);
dma_len = sg_dma_len(sg); dma_len = ib_sg_dma_len(
dma_addr = sg_dma_address(sg); dev, sg);
dma_addr = ib_sg_dma_address(
dev, sg);
} }
} }
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册