All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
To: "alex.estrin-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
	<alex.estrin-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
	<dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org"
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH v2 00/26] IB: Optimize DMA mapping
Date: Tue, 17 Jan 2017 21:48:44 +0000	[thread overview]
Message-ID: <1484689709.2729.6.camel@sandisk.com> (raw)
In-Reply-To: <F3529576D8E232409F431C309E29399336C6006C-8k97q/ur5Z1cIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On Sat, 2017-01-14 at 02:05 +0000, Estrin, Alex wrote:
> [ ... ]
> please see hfi1/verbs.c @ hfi1_register_ib_device()  
> [ ... ]

Hello Alex,

I think I figured out what I did wrong: both the hfi1 and the qib drivers need two
sets of DMA mapping operations. ULPs have to use &dma_virt_ops and the SDMA code
has to use the PCIe DMA mapping operations. My patch series made the SDMA code use
dma_virt_ops and that's wrong. The attached patch should fix this. Unfortunately I
do not have access to a hfi1 or qib test setup. Can you help me by testing the
attached patch on top of the already posted patches?

Thanks,

Bart.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-hfi1-qib-rdmavt-Use-proper-DMA-mapping-operations.patch --]
[-- Type: text/x-patch; name="0001-hfi1-qib-rdmavt-Use-proper-DMA-mapping-operations.patch", Size: 3583 bytes --]

From 21ed4680a16b2281ea63caa9a3ef9e4c682a1d8b Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bart.vanassche@sandisk.com>
Date: Tue, 17 Jan 2017 13:22:35 -0800
Subject: [PATCH] hfi1, qib, rdmavt: Use proper DMA mapping operations

Make users of the hfi1 and qib drivers use dma_virt_ops. Use the PCIe
mapping operations for SDMA. Make sure that the rdmavt code does not
change the PCIe DMA mapping operations pointer into &dma_virt_ops.
---
 drivers/infiniband/hw/hfi1/mad.c      | 2 +-
 drivers/infiniband/hw/hfi1/verbs.c    | 1 -
 drivers/infiniband/hw/qib/qib_verbs.c | 1 -
 drivers/infiniband/sw/rdmavt/vt.c     | 2 ++
 include/rdma/rdma_vt.h                | 8 ++++++++
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index 6e595afca24c..041d503c399b 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -4406,7 +4406,7 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 	switch (in_mad->base_version) {
 	case OPA_MGMT_BASE_VERSION:
 		if (unlikely(in_mad_size != sizeof(struct opa_mad))) {
-			dev_err(ibdev->dma_device, "invalid in_mad_size\n");
+			dev_err(&ibdev->dev, "invalid in_mad_size\n");
 			return IB_MAD_RESULT_FAILURE;
 		}
 		return hfi1_process_opa_mad(ibdev, mad_flags, port,
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 95ed4d6da510..fa0ff3e11597 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -1784,7 +1784,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 	strlcpy(ibdev->name + lcpysz, "_%d", IB_DEVICE_NAME_MAX - lcpysz);
 	ibdev->owner = THIS_MODULE;
 	ibdev->phys_port_cnt = dd->num_pports;
-	ibdev->dma_device = &dd->pcidev->dev;
 	ibdev->modify_device = modify_device;
 	ibdev->alloc_hw_stats = alloc_hw_stats;
 	ibdev->get_hw_stats = get_hw_stats;
diff --git a/drivers/infiniband/hw/qib/qib_verbs.c b/drivers/infiniband/hw/qib/qib_verbs.c
index 4b54c0ddd08a..daa28a7b7574 100644
--- a/drivers/infiniband/hw/qib/qib_verbs.c
+++ b/drivers/infiniband/hw/qib/qib_verbs.c
@@ -1632,7 +1632,6 @@ int qib_register_ib_device(struct qib_devdata *dd)
 	ibdev->owner = THIS_MODULE;
 	ibdev->node_guid = ppd->guid;
 	ibdev->phys_port_cnt = dd->num_pports;
-	ibdev->dma_device = &dd->pcidev->dev;
 	ibdev->modify_device = qib_modify_device;
 	ibdev->process_mad = qib_process_mad;
 
diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
index 6a81b179f631..af9dcd47dace 100644
--- a/drivers/infiniband/sw/rdmavt/vt.c
+++ b/drivers/infiniband/sw/rdmavt/vt.c
@@ -103,6 +103,8 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
 	if (!rdi->ports)
 		ib_dealloc_device(&rdi->ibdev);
 
+	rdi->ib_dev.dma_device = &rdi->dma_device;
+
 	return rdi;
 }
 EXPORT_SYMBOL(rvt_alloc_device);
diff --git a/include/rdma/rdma_vt.h b/include/rdma/rdma_vt.h
index 861e23eaebda..b7259c9b056e 100644
--- a/include/rdma/rdma_vt.h
+++ b/include/rdma/rdma_vt.h
@@ -339,6 +339,14 @@ struct rvt_driver_provided {
 
 struct rvt_dev_info {
 	struct ib_device ibdev; /* Keep this first. Nothing above here */
+	/*
+	 * qib and hfi1 use two sets of DMA operations:
+	 * - The DMA operations of the PCIe device for SDMA.
+	 * - dma_virt_ops for users of the qib and hfi1 drivers.
+	 * The only purpose of @dma_device is to provide a struct device that
+	 * provides dma_virt_ops.
+	 */
+	struct device dma_device;
 
 	/*
 	 * Prior to calling for registration the driver will be responsible for
-- 
2.11.0


WARNING: multiple messages have this Message-ID (diff)
From: Bart Van Assche <Bart.VanAssche@sandisk.com>
To: "alex.estrin@intel.com" <alex.estrin@intel.com>,
	"dledford@redhat.com" <dledford@redhat.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v2 00/26] IB: Optimize DMA mapping
Date: Tue, 17 Jan 2017 21:48:44 +0000	[thread overview]
Message-ID: <1484689709.2729.6.camel@sandisk.com> (raw)
In-Reply-To: <F3529576D8E232409F431C309E29399336C6006C@CRSMSX102.amr.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On Sat, 2017-01-14 at 02:05 +0000, Estrin, Alex wrote:
> [ ... ]
> please see hfi1/verbs.c @ hfi1_register_ib_device()  
> [ ... ]

Hello Alex,

I think I figured out what I did wrong: both the hfi1 and the qib drivers need two
sets of DMA mapping operations. ULPs have to use &dma_virt_ops and the SDMA code
has to use the PCIe DMA mapping operations. My patch series made the SDMA code use
dma_virt_ops and that's wrong. The attached patch should fix this. Unfortunately I
do not have access to a hfi1 or qib test setup. Can you help me by testing the
attached patch on top of the already posted patches?

Thanks,

Bart.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-hfi1-qib-rdmavt-Use-proper-DMA-mapping-operations.patch --]
[-- Type: text/x-patch; name="0001-hfi1-qib-rdmavt-Use-proper-DMA-mapping-operations.patch", Size: 3583 bytes --]

From 21ed4680a16b2281ea63caa9a3ef9e4c682a1d8b Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bart.vanassche@sandisk.com>
Date: Tue, 17 Jan 2017 13:22:35 -0800
Subject: [PATCH] hfi1, qib, rdmavt: Use proper DMA mapping operations

Make users of the hfi1 and qib drivers use dma_virt_ops. Use the PCIe
mapping operations for SDMA. Make sure that the rdmavt code does not
change the PCIe DMA mapping operations pointer into &dma_virt_ops.
---
 drivers/infiniband/hw/hfi1/mad.c      | 2 +-
 drivers/infiniband/hw/hfi1/verbs.c    | 1 -
 drivers/infiniband/hw/qib/qib_verbs.c | 1 -
 drivers/infiniband/sw/rdmavt/vt.c     | 2 ++
 include/rdma/rdma_vt.h                | 8 ++++++++
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index 6e595afca24c..041d503c399b 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -4406,7 +4406,7 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 	switch (in_mad->base_version) {
 	case OPA_MGMT_BASE_VERSION:
 		if (unlikely(in_mad_size != sizeof(struct opa_mad))) {
-			dev_err(ibdev->dma_device, "invalid in_mad_size\n");
+			dev_err(&ibdev->dev, "invalid in_mad_size\n");
 			return IB_MAD_RESULT_FAILURE;
 		}
 		return hfi1_process_opa_mad(ibdev, mad_flags, port,
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 95ed4d6da510..fa0ff3e11597 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -1784,7 +1784,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 	strlcpy(ibdev->name + lcpysz, "_%d", IB_DEVICE_NAME_MAX - lcpysz);
 	ibdev->owner = THIS_MODULE;
 	ibdev->phys_port_cnt = dd->num_pports;
-	ibdev->dma_device = &dd->pcidev->dev;
 	ibdev->modify_device = modify_device;
 	ibdev->alloc_hw_stats = alloc_hw_stats;
 	ibdev->get_hw_stats = get_hw_stats;
diff --git a/drivers/infiniband/hw/qib/qib_verbs.c b/drivers/infiniband/hw/qib/qib_verbs.c
index 4b54c0ddd08a..daa28a7b7574 100644
--- a/drivers/infiniband/hw/qib/qib_verbs.c
+++ b/drivers/infiniband/hw/qib/qib_verbs.c
@@ -1632,7 +1632,6 @@ int qib_register_ib_device(struct qib_devdata *dd)
 	ibdev->owner = THIS_MODULE;
 	ibdev->node_guid = ppd->guid;
 	ibdev->phys_port_cnt = dd->num_pports;
-	ibdev->dma_device = &dd->pcidev->dev;
 	ibdev->modify_device = qib_modify_device;
 	ibdev->process_mad = qib_process_mad;
 
diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
index 6a81b179f631..af9dcd47dace 100644
--- a/drivers/infiniband/sw/rdmavt/vt.c
+++ b/drivers/infiniband/sw/rdmavt/vt.c
@@ -103,6 +103,8 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
 	if (!rdi->ports)
 		ib_dealloc_device(&rdi->ibdev);
 
+	rdi->ib_dev.dma_device = &rdi->dma_device;
+
 	return rdi;
 }
 EXPORT_SYMBOL(rvt_alloc_device);
diff --git a/include/rdma/rdma_vt.h b/include/rdma/rdma_vt.h
index 861e23eaebda..b7259c9b056e 100644
--- a/include/rdma/rdma_vt.h
+++ b/include/rdma/rdma_vt.h
@@ -339,6 +339,14 @@ struct rvt_driver_provided {
 
 struct rvt_dev_info {
 	struct ib_device ibdev; /* Keep this first. Nothing above here */
+	/*
+	 * qib and hfi1 use two sets of DMA operations:
+	 * - The DMA operations of the PCIe device for SDMA.
+	 * - dma_virt_ops for users of the qib and hfi1 drivers.
+	 * The only purpose of @dma_device is to provide a struct device that
+	 * provides dma_virt_ops.
+	 */
+	struct device dma_device;
 
 	/*
 	 * Prior to calling for registration the driver will be responsible for
-- 
2.11.0


  parent reply	other threads:[~2017-01-17 21:48 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12 19:06 [PATCH v2 00/26] IB: Optimize DMA mapping Bart Van Assche
2017-01-12 19:06 ` Bart Van Assche
2017-01-12 19:06 ` [PATCH v2 01/26] treewide: Constify most dma_map_ops structures Bart Van Assche
2017-01-12 19:06   ` Bart Van Assche
2017-01-12 19:06 ` [PATCH v2 02/26] treewide: Move dma_ops from struct dev_archdata into struct device Bart Van Assche
2017-01-12 19:06   ` Bart Van Assche
     [not found]   ` <20170112190718.6728-3-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-19  9:10     ` Greg Kroah-Hartman
2017-01-19  9:10       ` Greg Kroah-Hartman
2017-01-12 19:06 ` [PATCH v2 04/26] treewide: Consolidate get_dma_ops() implementations Bart Van Assche
2017-01-12 19:06   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 10/26] IB: Use dma_virt_ops instead of duplicating it Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 11/26] RDS: IB: Remove an unused structure member Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 12/26] IB: Convert ib_dma_*_coherent() argument type from u64 into dma_addr_t Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 13/26] IB/core: Inline ib_dma_map_*() functions Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 14/26] IB/mlx4: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
     [not found] ` <20170112190718.6728-1-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-12 19:06   ` [PATCH v2 03/26] treewide: Consolidate set_dma_ops() implementations Bart Van Assche
2017-01-12 19:06     ` Bart Van Assche
2017-01-12 19:06     ` Bart Van Assche
2017-01-12 19:06     ` Bart Van Assche
2017-01-12 19:06   ` [PATCH v2 05/26] lib/dma-noop: Clarify a comment Bart Van Assche
2017-01-12 19:06     ` Bart Van Assche
2017-01-12 19:06   ` [PATCH v2 06/26] lib/dma-noop: Only build dma_noop_ops for m32r and s390 Bart Van Assche
2017-01-12 19:06     ` Bart Van Assche
     [not found]     ` <20170112190718.6728-7-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-13  8:38       ` Christian Borntraeger
2017-01-13  8:38         ` Christian Borntraeger
2017-01-12 19:06   ` [PATCH v2 07/26] lib/dma-virt: Add dma_virt_ops Bart Van Assche
2017-01-12 19:06     ` Bart Van Assche
2017-01-12 19:07   ` [PATCH v2 08/26] IB/hf1: Remove DMA mapping code Bart Van Assche
2017-01-12 19:07     ` Bart Van Assche
2017-01-12 19:07   ` [PATCH v2 09/26] IB/qib: " Bart Van Assche
2017-01-12 19:07     ` Bart Van Assche
2017-01-12 19:07   ` [PATCH v2 15/26] IB/mlx5: Inline ib_dma_map_*() functions Bart Van Assche
2017-01-12 19:07     ` Bart Van Assche
2017-01-12 19:07   ` [PATCH v2 16/26] IB/IPoIB: " Bart Van Assche
2017-01-12 19:07     ` Bart Van Assche
     [not found]     ` <20170112190718.6728-17-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-13 11:33       ` Yuval Shaia
2017-01-13 11:33         ` Yuval Shaia
2017-01-13 18:27   ` [PATCH v2 00/26] IB: Optimize DMA mapping Estrin, Alex
2017-01-13 18:27     ` Estrin, Alex
2017-01-13 20:18     ` Bart Van Assche
2017-01-13 21:08       ` Estrin, Alex
     [not found]         ` <F3529576D8E232409F431C309E29399336C5FF78-8k97q/ur5Z1cIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-01-13 21:59           ` Bart Van Assche
2017-01-13 21:59             ` Bart Van Assche
     [not found]             ` <1484344759.2679.26.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-14  2:05               ` Estrin, Alex
2017-01-14  2:05                 ` Estrin, Alex
     [not found]                 ` <F3529576D8E232409F431C309E29399336C6006C-8k97q/ur5Z1cIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-01-17 21:48                   ` Bart Van Assche [this message]
2017-01-17 21:48                     ` Bart Van Assche
2017-01-17 22:00                     ` Bart Van Assche
     [not found]                       ` <1484690386.2729.8.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-17 22:27                         ` Jason Gunthorpe
2017-01-17 22:27                           ` Jason Gunthorpe
2017-01-17 22:33                           ` Bart Van Assche
2017-01-17 22:50                             ` Jason Gunthorpe
2017-01-13 21:26   ` Sagi Grimberg
2017-01-13 21:26     ` Sagi Grimberg
2017-01-12 19:07 ` [PATCH v2 17/26] IB/iser: Inline ib_dma_map_*() functions Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
     [not found]   ` <20170112190718.6728-18-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-13 21:26     ` Sagi Grimberg
2017-01-13 21:26       ` Sagi Grimberg
2017-01-12 19:07 ` [PATCH v2 18/26] IB/isert: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-13 21:26   ` Sagi Grimberg
2017-01-12 19:07 ` [PATCH v2 19/26] IB/srp: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 20/26] IB/srpt: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 21/26] staging/lustre: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 22/26] nvme-rdma: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 23/26] net/9p: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:07 ` [PATCH v2 24/26] net/rds: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
     [not found]   ` <20170112190718.6728-25-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-01-12 19:18     ` santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA
2017-01-12 19:18       ` santosh.shilimkar
2017-01-12 19:07 ` [PATCH v2 25/26] xprtrdma: " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche
2017-01-12 19:19   ` Chuck Lever
2017-01-12 19:07 ` [PATCH v2 26/26] IB/core: Remove " Bart Van Assche
2017-01-12 19:07   ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484689709.2729.6.camel@sandisk.com \
    --to=bart.vanassche-xdaiopvojttbdgjk7y7tuq@public.gmane.org \
    --cc=alex.estrin-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.