* [PATCH v2] nvme-rdma: fix in-casule data send for chained sgls
@ 2021-05-28 1:16 Sagi Grimberg
2021-05-30 10:48 ` Max Gurtovoy
2021-05-31 6:04 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Sagi Grimberg @ 2021-05-28 1:16 UTC (permalink / raw)
To: linux-nvme, Christoph Hellwig, Keith Busch; +Cc: Max Gurtovoy
We have only 2 inline sg entries and we allow 4 sg entries for the send
wr sge. Larger sgls entries will be chained. However when we build
in-capsule send wr sge, we iterate without taking into account that the
sgl may be chained and still fit in-capsule (which can happen if the sgl
is bigger than 2, but lower-equal to 4).
Fix in-capsule data mapping to correctly iterate chained sgls.
Reported-by: Walker, Benjamin <benjamin.walker@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
Changes from v1:
- fix silly compilation error
drivers/nvme/host/rdma.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 8d107b201f16..f61bf39c39a0 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1320,16 +1320,17 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue,
int count)
{
struct nvme_sgl_desc *sg = &c->common.dptr.sgl;
- struct scatterlist *sgl = req->data_sgl.sg_table.sgl;
struct ib_sge *sge = &req->sge[1];
+ struct scatterlist *sgl;
u32 len = 0;
int i;
- for (i = 0; i < count; i++, sgl++, sge++) {
+ for_each_sg(req->data_sgl.sg_table.sgl, sgl, count, i) {
sge->addr = sg_dma_address(sgl);
sge->length = sg_dma_len(sgl);
sge->lkey = queue->device->pd->local_dma_lkey;
len += sge->length;
+ sge++;
}
sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff);
--
2.27.0
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nvme-rdma: fix in-casule data send for chained sgls
2021-05-28 1:16 [PATCH v2] nvme-rdma: fix in-casule data send for chained sgls Sagi Grimberg
@ 2021-05-30 10:48 ` Max Gurtovoy
2021-05-31 6:04 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Max Gurtovoy @ 2021-05-30 10:48 UTC (permalink / raw)
To: Sagi Grimberg, linux-nvme, Christoph Hellwig, Keith Busch; +Cc: Max Gurtovoy
On 5/28/2021 4:16 AM, Sagi Grimberg wrote:
> We have only 2 inline sg entries and we allow 4 sg entries for the send
> wr sge. Larger sgls entries will be chained. However when we build
> in-capsule send wr sge, we iterate without taking into account that the
> sgl may be chained and still fit in-capsule (which can happen if the sgl
> is bigger than 2, but lower-equal to 4).
>
> Fix in-capsule data mapping to correctly iterate chained sgls.
>
> Reported-by: Walker, Benjamin <benjamin.walker@intel.com>
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
> Changes from v1:
> - fix silly compilation error
>
> drivers/nvme/host/rdma.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index 8d107b201f16..f61bf39c39a0 100644
> --- a/drivers/nvme/host/rdma.c
> +++ b/drivers/nvme/host/rdma.c
> @@ -1320,16 +1320,17 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue,
> int count)
> {
> struct nvme_sgl_desc *sg = &c->common.dptr.sgl;
> - struct scatterlist *sgl = req->data_sgl.sg_table.sgl;
> struct ib_sge *sge = &req->sge[1];
> + struct scatterlist *sgl;
> u32 len = 0;
> int i;
>
> - for (i = 0; i < count; i++, sgl++, sge++) {
> + for_each_sg(req->data_sgl.sg_table.sgl, sgl, count, i) {
> sge->addr = sg_dma_address(sgl);
> sge->length = sg_dma_len(sgl);
> sge->lkey = queue->device->pd->local_dma_lkey;
> len += sge->length;
> + sge++;
> }
>
> sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff);
Looks good,
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nvme-rdma: fix in-casule data send for chained sgls
2021-05-28 1:16 [PATCH v2] nvme-rdma: fix in-casule data send for chained sgls Sagi Grimberg
2021-05-30 10:48 ` Max Gurtovoy
@ 2021-05-31 6:04 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-05-31 6:04 UTC (permalink / raw)
To: Sagi Grimberg; +Cc: linux-nvme, Christoph Hellwig, Keith Busch, Max Gurtovoy
Thanks,
applied to nvme-5.13.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-31 6:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-28 1:16 [PATCH v2] nvme-rdma: fix in-casule data send for chained sgls Sagi Grimberg
2021-05-30 10:48 ` Max Gurtovoy
2021-05-31 6:04 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).