From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Doug Ledford <dledford@redhat.com>,
Sebastian Ott <sebott@linux.vnet.ibm.com>,
Parav Pandit <parav@mellanox.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Bjorn Helgaas <bhelgaas@google.com>,
David Woodhouse <dwmw2@infradead.org>,
"H . Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Russell King <linux@armlinux.org.uk>
Subject: Re: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
Date: Wed, 08 Mar 2017 12:52:37 +1100 [thread overview]
Message-ID: <1488937957.2870.164.camel@kernel.crashing.org> (raw)
In-Reply-To: <20170307045236.GC3913@kroah.com>
On Tue, 2017-03-07 at 05:52 +0100, Greg Kroah-Hartman wrote:
> On Mon, Mar 06, 2017 at 04:35:48PM -0800, Bart Van Assche wrote:
> > The dma mapping operations of several architectures and also of
> > several I/O MMU implementations need to translate a struct
> > device pointer into a struct pci_dev pointer. This translation
> > is performed by to_pci_dev(). That macro assumes that struct
> > device is embedded in struct pci_dev. However, that is not the
> > case for the device structure in struct ib_device.
>
> Then don't blindly cast it backwards! Fix that up, an ib device should
> have access to the dma structures that the PCI device it depends on has.
> If not, you need to set that up properly in the IB core, don't mess with
> the driver core for this at all.
>
> Somehow all other subsystems work just fine, don't instantly think that
> the driver core needs to bend to the will of the IB code, because you
> are somehow "special". Hint, you aren't :)
Right, in his case, Bart, you can either pass the the struct device for
use for DMA to the ib devices, which is easy but a bit gross, or have
the ib core provide a set of dma_ops for the ib_device that are
"wrappers" calling back to the "parent" device.
Any struct device whose dma_ops haven't been setup by the architecture
core cannot be used for DMA as-is without such "reflector" dma_ops
provided by the creator of that struct device.
The architecture core only knows about some "directly" attached things
like PCI, some cases of platform devices etc... and has no way of
setting things up for subsystem specific thigns like ib_device.
Thus the subsystem must take care of it and provide its own dma_ops
that "reflect" the calls to the original parent device that was setup
by the architecture.
Cheers,
Ben.
next prev parent reply other threads:[~2017-03-08 3:43 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
2017-03-07 0:35 ` [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev Bart Van Assche
2017-03-07 2:41 ` Parav Pandit
2017-03-07 2:44 ` Bart Van Assche
2017-03-07 4:50 ` gregkh
2017-03-07 3:21 ` Parav Pandit
2017-03-07 4:52 ` Greg Kroah-Hartman
2017-03-07 5:08 ` Parav Pandit
2017-03-07 5:13 ` Bart Van Assche
2017-03-07 5:20 ` Parav Pandit
2017-03-07 16:54 ` Bart Van Assche
2017-03-07 17:14 ` gregkh
2017-03-07 18:27 ` Parav Pandit
2017-03-08 1:52 ` Benjamin Herrenschmidt [this message]
2017-03-07 0:35 ` [PATCH 2/2] IB/core: Restore I/O MMU, s390 and powerpc support 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=1488937957.2870.164.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=bart.vanassche@sandisk.com \
--cc=bhelgaas@google.com \
--cc=dledford@redhat.com \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mingo@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).