public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data structures
@ 2017-01-19  0:22 Parav Pandit
       [not found] ` <1484785346-2991-1-git-send-email-parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Parav Pandit @ 2017-01-19  0:22 UTC (permalink / raw)
  To: hch-jcswGhMUV9g, sagi-NQWnxTmZq1alnMjI0IkVqw,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	dledford-H+wXaHxf7aLQT0dZR+AlfA
  Cc: parav-VPRAkNaXOzVWk0Htik3J/w

This patch performs dma sync operations on nvme_command
and nvme_completion.

nvme_command is synced
(a) on receiving of the recv queue completion for cpu access.
(b) before posting recv wqe back to rdma adapter for device access.

nvme_completion is synced
(a) on receiving of the recv queue completion of associated
nvme_command for cpu access.
(b) before posting send wqe to rdma adapter for device access.

This patch is generated for git://git.infradead.org/nvme-fabrics.git
Branch: nvmf-4.10

Signed-off-by: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Max Gurtovoy <maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 drivers/nvme/target/rdma.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 6c1c368..0599217 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -438,6 +438,10 @@ static int nvmet_rdma_post_recv(struct nvmet_rdma_device *ndev,
 {
 	struct ib_recv_wr *bad_wr;
 
+	ib_dma_sync_single_for_device(ndev->device,
+		cmd->sge[0].addr, cmd->sge[0].length,
+		DMA_FROM_DEVICE);
+
 	if (ndev->srq)
 		return ib_post_srq_recv(ndev->srq, &cmd->wr, &bad_wr);
 	return ib_post_recv(cmd->queue->cm_id->qp, &cmd->wr, &bad_wr);
@@ -538,6 +542,11 @@ static void nvmet_rdma_queue_response(struct nvmet_req *req)
 		first_wr = &rsp->send_wr;
 
 	nvmet_rdma_post_recv(rsp->queue->dev, rsp->cmd);
+
+	ib_dma_sync_single_for_device(rsp->queue->dev->device,
+			rsp->send_sge.addr, rsp->send_sge.length,
+			DMA_TO_DEVICE);
+
 	if (ib_post_send(cm_id->qp, first_wr, &bad_wr)) {
 		pr_err("sending cmd response failed\n");
 		nvmet_rdma_release_rsp(rsp);
@@ -698,6 +707,13 @@ static void nvmet_rdma_handle_command(struct nvmet_rdma_queue *queue,
 	cmd->n_rdma = 0;
 	cmd->req.port = queue->port;
 
+	ib_dma_sync_single_for_cpu(queue->dev->device,
+		cmd->cmd->sge[0].addr, cmd->cmd->sge[0].length,
+		DMA_FROM_DEVICE);
+	ib_dma_sync_single_for_cpu(queue->dev->device,
+			cmd->send_sge.addr, cmd->send_sge.length,
+			DMA_TO_DEVICE);
+
 	if (!nvmet_req_init(&cmd->req, &queue->nvme_cq,
 			&queue->nvme_sq, &nvmet_rdma_ops))
 		return;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data structures
       [not found] ` <1484785346-2991-1-git-send-email-parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
@ 2017-01-19  7:42   ` Sagi Grimberg
  2017-01-19 15:22   ` Christoph Hellwig
  1 sibling, 0 replies; 6+ messages in thread
From: Sagi Grimberg @ 2017-01-19  7:42 UTC (permalink / raw)
  To: Parav Pandit, hch-jcswGhMUV9g,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	dledford-H+wXaHxf7aLQT0dZR+AlfA

Looks much better, I'm fine with it.

Christoph?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data structures
       [not found] ` <1484785346-2991-1-git-send-email-parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  2017-01-19  7:42   ` Sagi Grimberg
@ 2017-01-19 15:22   ` Christoph Hellwig
       [not found]     ` <20170119152240.GA32400-jcswGhMUV9g@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2017-01-19 15:22 UTC (permalink / raw)
  To: Parav Pandit
  Cc: hch-jcswGhMUV9g, sagi-NQWnxTmZq1alnMjI0IkVqw,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	dledford-H+wXaHxf7aLQT0dZR+AlfA

On Wed, Jan 18, 2017 at 06:22:26PM -0600, Parav Pandit wrote:
> This patch performs dma sync operations on nvme_command
> and nvme_completion.
> 
> nvme_command is synced
> (a) on receiving of the recv queue completion for cpu access.
> (b) before posting recv wqe back to rdma adapter for device access.
> 
> nvme_completion is synced
> (a) on receiving of the recv queue completion of associated
> nvme_command for cpu access.
> (b) before posting send wqe to rdma adapter for device access.
> 
> This patch is generated for git://git.infradead.org/nvme-fabrics.git
> Branch: nvmf-4.10
> 
> Signed-off-by: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Reviewed-by: Max Gurtovoy <maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> ---
>  drivers/nvme/target/rdma.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
> index 6c1c368..0599217 100644
> --- a/drivers/nvme/target/rdma.c
> +++ b/drivers/nvme/target/rdma.c
> @@ -438,6 +438,10 @@ static int nvmet_rdma_post_recv(struct nvmet_rdma_device *ndev,
>  {
>  	struct ib_recv_wr *bad_wr;
>  
> +	ib_dma_sync_single_for_device(ndev->device,
> +		cmd->sge[0].addr, cmd->sge[0].length,
> +		DMA_FROM_DEVICE);
> +
>  	if (ndev->srq)
>  		return ib_post_srq_recv(ndev->srq, &cmd->wr, &bad_wr);
>  	return ib_post_recv(cmd->queue->cm_id->qp, &cmd->wr, &bad_wr);
> @@ -538,6 +542,11 @@ static void nvmet_rdma_queue_response(struct nvmet_req *req)
>  		first_wr = &rsp->send_wr;
>  
>  	nvmet_rdma_post_recv(rsp->queue->dev, rsp->cmd);
> +
> +	ib_dma_sync_single_for_device(rsp->queue->dev->device,
> +			rsp->send_sge.addr, rsp->send_sge.length,
> +			DMA_TO_DEVICE);
> +
>  	if (ib_post_send(cm_id->qp, first_wr, &bad_wr)) {
>  		pr_err("sending cmd response failed\n");
>  		nvmet_rdma_release_rsp(rsp);
> @@ -698,6 +707,13 @@ static void nvmet_rdma_handle_command(struct nvmet_rdma_queue *queue,
>  	cmd->n_rdma = 0;
>  	cmd->req.port = queue->port;
>  
> +	ib_dma_sync_single_for_cpu(queue->dev->device,
> +		cmd->cmd->sge[0].addr, cmd->cmd->sge[0].length,
> +		DMA_FROM_DEVICE);
> +	ib_dma_sync_single_for_cpu(queue->dev->device,
> +			cmd->send_sge.addr, cmd->send_sge.length,
> +			DMA_TO_DEVICE);

Why the different indentation here?  Both one or two tab indents
look fine to me in this context, but don't mix them.

Except for that this looks fine:

Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data structures
       [not found]     ` <20170119152240.GA32400-jcswGhMUV9g@public.gmane.org>
@ 2017-01-19 15:45       ` Parav Pandit
       [not found]         ` <VI1PR0502MB300864C57897C37D4397A76AD17E0-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Parav Pandit @ 2017-01-19 15:45 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Hi Christoph,

> -----Original Message-----
> From: Christoph Hellwig [mailto:hch-jcswGhMUV9g@public.gmane.org]
> Sent: Thursday, January 19, 2017 9:23 AM
> To: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Cc: hch-jcswGhMUV9g@public.gmane.org; sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org; linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org; linux-
> rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
> Subject: Re: [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data
> structures
> 
> >
> > +	ib_dma_sync_single_for_cpu(queue->dev->device,
> > +		cmd->cmd->sge[0].addr, cmd->cmd->sge[0].length,
> > +		DMA_FROM_DEVICE);
> > +	ib_dma_sync_single_for_cpu(queue->dev->device,
> > +			cmd->send_sge.addr, cmd->send_sge.length,
> > +			DMA_TO_DEVICE);
> 
> Why the different indentation here?  Both one or two tab indents look fine to
> me in this context, but don't mix them.
> 
I agree. I should have taken care of that.
Shall I resend patch with same indentation at all places or this can be taken care during commit?

> Except for that this looks fine:
> 
> Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data structures
       [not found]         ` <VI1PR0502MB300864C57897C37D4397A76AD17E0-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
@ 2017-01-19 15:46           ` Christoph Hellwig
       [not found]             ` <20170119154601.GA597-jcswGhMUV9g@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2017-01-19 15:46 UTC (permalink / raw)
  To: Parav Pandit
  Cc: Christoph Hellwig, sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

On Thu, Jan 19, 2017 at 03:45:30PM +0000, Parav Pandit wrote:
> I agree. I should have taken care of that.
> Shall I resend patch with same indentation at all places or this can be taken care during commit?

I think Sagi or I can just take care of it on commit.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data structures
       [not found]             ` <20170119154601.GA597-jcswGhMUV9g@public.gmane.org>
@ 2017-01-19 15:51               ` Parav Pandit
  0 siblings, 0 replies; 6+ messages in thread
From: Parav Pandit @ 2017-01-19 15:51 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

After sending I realized that Doug might also need to do that to merge this to Linux-rdma so that Bart's dma_ops series works correctly.
So its work for more people.
Let me just resend it. Its minor.

Parav

> -----Original Message-----
> From: Christoph Hellwig [mailto:hch-jcswGhMUV9g@public.gmane.org]
> Sent: Thursday, January 19, 2017 9:46 AM
> To: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>; sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org; linux-
> nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org; linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org;
> dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
> Subject: Re: [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data
> structures
> 
> On Thu, Jan 19, 2017 at 03:45:30PM +0000, Parav Pandit wrote:
> > I agree. I should have taken care of that.
> > Shall I resend patch with same indentation at all places or this can be taken
> care during commit?
> 
> I think Sagi or I can just take care of it on commit.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-19 15:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19  0:22 [PATCHv3] nvmet-rdma: Fix missing dma sync to nvme data structures Parav Pandit
     [not found] ` <1484785346-2991-1-git-send-email-parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-19  7:42   ` Sagi Grimberg
2017-01-19 15:22   ` Christoph Hellwig
     [not found]     ` <20170119152240.GA32400-jcswGhMUV9g@public.gmane.org>
2017-01-19 15:45       ` Parav Pandit
     [not found]         ` <VI1PR0502MB300864C57897C37D4397A76AD17E0-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-01-19 15:46           ` Christoph Hellwig
     [not found]             ` <20170119154601.GA597-jcswGhMUV9g@public.gmane.org>
2017-01-19 15:51               ` Parav Pandit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox