public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Doug Ledford <dledford@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	Parav Pandit <parav@mellanox.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bart Van Assche <bart.vanassche@sandisk.com>
Subject: [PATCH 2/2] IB/core: Restore I/O MMU, s390 and powerpc support
Date: Mon, 6 Mar 2017 16:35:49 -0800	[thread overview]
Message-ID: <20170307003549.3872-3-bart.vanassche@sandisk.com> (raw)
In-Reply-To: <20170307003549.3872-1-bart.vanassche@sandisk.com>

Avoid that the following error message is reported on the console
while loading an RDMA driver with I/O MMU support enabled:

DMAR: Allocating domain for mlx5_0 failed

Ensure that DMA mapping operations that use to_pci_dev() to
access to struct pci_dev see the correct PCI device. E.g. the s390
and powerpc DMA mapping operations use to_pci_dev() even with I/O
MMU support disabled.

Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Reported-by: Parav Pandit <parav@mellanox.com>
Fixes: commit 99db9494035f ("IB/core: Remove ib_device.dma_device")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 drivers/infiniband/core/device.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 593d2ce6ec7c..93c23e873841 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -39,6 +39,7 @@
 #include <linux/init.h>
 #include <linux/mutex.h>
 #include <linux/netdevice.h>
+#include <linux/pci.h>
 #include <rdma/rdma_netlink.h>
 #include <rdma/ib_addr.h>
 #include <rdma/ib_cache.h>
@@ -325,6 +326,10 @@ EXPORT_SYMBOL(ib_get_device_fw_str);
  * devices with the IB core.  All registered clients will receive a
  * callback for each device that is added. @device must be allocated
  * with ib_alloc_device().
+ *
+ * Unless requested otherwise by the caller, this function makes sure that DMA
+ * mapping operations on &device->dev behave identical to DMA mapping
+ * operations on the parent device (device->dev.parent).
  */
 int ib_register_device(struct ib_device *device,
 		       int (*port_callback)(struct ib_device *,
@@ -336,8 +341,11 @@ int ib_register_device(struct ib_device *device,
 	struct device *parent = device->dev.parent;
 
 	WARN_ON_ONCE(!parent);
-	if (!device->dev.dma_ops)
+	if (!device->dev.dma_ops) {
 		device->dev.dma_ops = parent->dma_ops;
+		device->dev.pci_dev = to_pci_dev(parent);
+		device->dev.archdata = parent->archdata;
+	}
 	if (!device->dev.dma_mask)
 		device->dev.dma_mask = parent->dma_mask;
 	if (!device->dev.coherent_dma_mask)
-- 
2.12.0

      parent reply	other threads:[~2017-03-07  0:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07  0:35 [PATCH 0/2] IB/core fixes for kernel v4.11-rc Bart Van Assche
     [not found] ` <20170307003549.3872-1-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-07  0:35   ` [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev Bart Van Assche
     [not found]     ` <20170307003549.3872-2-bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-07  2:41       ` Parav Pandit
2017-03-07  2:44         ` Bart Van Assche
     [not found]           ` <1488854653.2997.1.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-07  4:50             ` gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
2017-03-07  3:21       ` Parav Pandit
2017-03-07  4:52       ` Greg Kroah-Hartman
2017-03-07 16:54         ` Bart Van Assche
     [not found]           ` <1488905685.2739.1.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-07 17:14             ` gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
2017-03-07 18:27               ` Parav Pandit
     [not found]         ` <20170307045236.GC3913-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2017-03-07  5:08           ` Parav Pandit
     [not found]             ` <VI1PR0502MB3008BEC2FB8747DDA40A10FCD12F0-o1MPJYiShExKsLr+rGaxW8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-03-07  5:13               ` Bart Van Assche
     [not found]                 ` <1488863593.2997.3.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-07  5:20                   ` Parav Pandit
2017-03-08  1:52           ` Benjamin Herrenschmidt
2017-03-07  0:35 ` Bart Van Assche [this message]

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=20170307003549.3872-3-bart.vanassche@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=dledford@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=parav@mellanox.com \
    --cc=sebott@linux.vnet.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox