mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	"mika.westerberg@linux.intel.com"
	<mika.westerberg@linux.intel.com>,
	"Koul, Vinod" <vinod.koul@intel.com>,
	"Krogerus, Heikki" <heikki.krogerus@intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	Viresh Kumar <viresh.kumar@st.com>,
	Kukjin Kim <kgene.kim@samsung.com>,
	yuanyabin1978@sina.com, linux-kernel@vger.kernel.org,
	Ben Dooks <ben-linux@fluff.org>,
	Peter Pearse <peter.pearse@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	Alessandro Rubini <rubini@unipv.it>
Subject: Re: [PATCH 06/13] DMAENGINE: driver for the ARM PL080/PL081 PrimeCells
Date: Mon, 10 Mar 2014 06:56:30 -0700	[thread overview]
Message-ID: <1394459790.2270.39.camel@shinybook.infradead.org> (raw)
In-Reply-To: <20110101151545.GC25924@n2100.arm.linux.org.uk>

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

On Sat, 2011-01-01 at 15:15 +0000, Russell King - ARM Linux wrote:
> On Wed, Dec 22, 2010 at 03:45:39PM -0800, Dan Williams wrote:
> > Support for the DMA_COMPL flags are necessary if the DMA_MEMCPY
> > capability is advertised, yes this driver got this wrong.  I'll update
> > the documentation to make this requirement clear, and audit the other
> > drivers.  With slave-only drivers the only usage model is one where
> > the client driver owns dma-mapping.  In the non-slave (opportunistic
> > memcpy offload) case the client is unaware of the engine so the driver
> > owns unmapping.  The minimal fix is to disable memcpy offload.
> 
> As a side note, the DMA mapping for slaves should be done using the
> DMA struct device, not the struct device of the peripheral making use
> of the DMA engine.
> 
> Why?  The slave device has no knowledge of how the DMA engine is
> connected into the system, or the DMA parameters associated with the
> device performing the DMA, such as the DMA mask and boundaries.  (If
> there are several generic DMA agents in the system, it can't know
> which is the correct one to use until a channel has been allocated.)
> The only struct device which has this information is the one for the
> DMA engine itself.
> 
> Therefore, the struct device which is passed into the DMA mapping APIs
> to prepare memory for DMA must always be the DMA engine struct device
> (chan->device->dev) and never the slave struct device.

That all seems eminently sensible. However, I wonder if it always has to
be true.

It is not impossible for the DMA controller to "delegate" transactions
so that (to the IOMMU) they appear to come from the individual slave
device rather than from itself.

The Intel IOMMU has now gained support for DMA mapping for devices
enumerated by ACPI — essentially the ACPI "DMAR" table just has a lookup
table of ACPI device paths, and tells us the PCI bus/devfn that their
DMA transactions will *appear* to be from.

What we've seen is that it is the individual slave devices that are
listed in these tables, *not* the DMA controller itself. It looks like
we are actually expected to set up the IOMMU mapping for the *slave*,
not the DMA controller. The system doesn't even *tell* me how to set up
DMA mappings for the DMA controller device; only the slaves.

I haven't looked at the datasheet for the DMA controller in question,
but it's probably the case that there's a per-channel configuration for
what PCIe source-id to put into the DMA transactions.¹

Of course, it's also possible that all these BIOSes are broken and they
*should* just list the DMA controller itself, instead of all the slave
devices. But while I'm always quick to jump to the conclusion that it's
the BIOS at fault, that doesn't necessarily seem likely here...

-- 
dwmw2

¹ We've seen plenty of multi-function devices where the DMA appears to
  come from the wrong function by *accident*, requiring quirks to make
  it work with the IOMMU. This would just be a case of doing the same
  kind of delegation on purpose.


[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]

  parent reply	other threads:[~2014-03-10 13:57 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-11 15:27 Linus Walleij
2010-06-14  6:02 ` Viresh KUMAR
2010-06-14 13:39   ` Linus Walleij
2010-06-15  5:25     ` Viresh KUMAR
2010-06-15 20:14       ` Linus WALLEIJ
2010-06-16  3:59         ` Viresh KUMAR
2010-06-16  6:38           ` Linus Walleij
2010-06-15 10:25 ` Kukjin Kim
2010-06-15 10:45   ` Jassi Brar
2010-06-15 11:17     ` Maurus Cuelenaere
2010-06-15 11:39       ` Jassi Brar
2010-06-15 12:04         ` Maurus Cuelenaere
2010-06-15 20:55     ` Linus WALLEIJ
2010-12-21 18:20 ` Russell King - ARM Linux
2010-12-21 22:25   ` Russell King - ARM Linux
2010-12-22 12:22   ` Russell King - ARM Linux
2010-12-22 12:29   ` Russell King - ARM Linux
2010-12-22 23:45     ` Dan Williams
2010-12-22 23:54       ` Russell King - ARM Linux
2010-12-23  0:53         ` Dan Williams
2010-12-23  0:10       ` Russell King - ARM Linux
2010-12-23  1:11         ` Dan Williams
2010-12-23  1:31           ` Dan Williams
2010-12-31 21:50             ` Russell King - ARM Linux
2011-01-02  9:42               ` Dan Williams
2011-01-02 11:22                 ` Russell King - ARM Linux
2011-01-02 20:33               ` Linus Walleij
2011-01-03 11:14                 ` Russell King - ARM Linux
2010-12-23  9:18           ` Russell King - ARM Linux
2010-12-23  8:17       ` Linus Walleij
2010-12-23  8:30         ` Jassi Brar
2010-12-23 12:30         ` Russell King - ARM Linux
2010-12-28  0:33           ` Linus Walleij
2011-01-01 15:15       ` Russell King - ARM Linux
2011-01-02 20:29         ` Linus Walleij
2014-03-10 13:56         ` David Woodhouse [this message]
2014-03-10 14:11           ` Arnd Bergmann
2014-03-10 14:27             ` David Woodhouse
2014-03-10 14:40               ` Arnd Bergmann
2014-03-10 14:32           ` Russell King - ARM Linux
2014-03-10 14:52             ` David Woodhouse
2014-03-13  8:17               ` Linus Walleij
2014-03-13  8:52                 ` Arnd Bergmann
2014-03-13 14:35                   ` Linus Walleij
2011-01-01 15:36       ` Russell King - ARM Linux
2011-01-03 15:19       ` Russell King - ARM Linux
2011-01-04  0:41         ` Jassi Brar
2011-01-04 10:47         ` Linus Walleij

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=1394459790.2270.39.camel@shinybook.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ben-linux@fluff.org \
    --cc=dan.j.williams@intel.com \
    --cc=heikki.krogerus@intel.com \
    --cc=kgene.kim@samsung.com \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mika.westerberg@linux.intel.com \
    --cc=peter.pearse@arm.com \
    --cc=rubini@unipv.it \
    --cc=vinod.koul@intel.com \
    --cc=viresh.kumar@st.com \
    --cc=yuanyabin1978@sina.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

all inboxes | Powered by JetHome®