linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: 'Daniel Vetter' <daniel@ffwll.ch>
Cc: "'Clark, Rob'" <rob@ti.com>,
	Tomasz Stanislawski <t.stanislaws@samsung.com>,
	'Sumit Semwal' <sumit.semwal@ti.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org,
	linux-media@vger.kernel.org, arnd@arndb.de,
	jesse.barker@linaro.org, 'Sumit Semwal' <sumit.semwal@linaro.org>,
	'Russell King - ARM Linux' <linux@arm.linux.org.uk>
Subject: RE: [RFC 1/2] dma-buf: Introduce dma buffer sharing mechanismch
Date: Mon, 28 Nov 2011 08:47:31 +0100	[thread overview]
Message-ID: <000401ccada1$fbdcc030$f3964090$%szyprowski@samsung.com> (raw)
In-Reply-To: <20111108184314.GB4754@phenom.ffwll.local>

Hello,

I'm sorry for the late reply, I must have missed this mail...

On Tuesday, November 08, 2011 7:43 PM Daniel Vetter wrote:

> On Tue, Nov 08, 2011 at 05:55:17PM +0000, Russell King - ARM Linux wrote:
> > On Tue, Nov 08, 2011 at 06:42:27PM +0100, Daniel Vetter wrote:
> > > Actually I think the importer should get a _mapped_ scatterlist when it
> > > calls get_scatterlist. The simple reason is that for strange stuff like
> > > memory remapped into e.g. omaps TILER doesn't have any sensible notion of
> > > an address in physical memory. For the USB-example I think the right
> > > approach is to attach the usb hci to the dma_buf, after all that is the
> > > device that will read the data and move over the usb bus to the udl
> > > device. Similar for any other device that sits behind a bus that can't do
> > > dma (or it doesn't make sense to do dma).
> > >
> > > Imo if there's a use-case where the client needs to frob the sg_list
> > > before calling dma_map_sg, we have an issue with the dma subsystem in
> > > general.
> >
> > Let's clear something up about the DMA API, which I think is causing some
> > misunderstanding here.  For this purpose, I'm going to talk about
> > dma_map_single(), but the same applies to the scatterlist and _page
> > variants as well.
> >
> > 	dma = dma_map_single(dev, cpuaddr, size, dir);
> >
> > dev := the device _performing_ the DMA operation.  You are quite correct
> >        that in the case of a USB peripheral device, the device is normally
> >        the USB HCI device.
> >
> > dma := dma address to be programmed into 'dev' which corresponds (by some
> >        means) with 'cpuaddr'.  This may not be the physical address due
> >        to bus offset translations or mappings setup in IOMMUs.
> >
> > Therefore, it is wrong to talk about a 'physical address' when talking
> > about the DMA API.
> >
> > We can take this one step further.  Lets say that the USB HCI is not
> > capable of performing memory accesses itself, but it is connected to a
> > separate DMA engine device:
> >
> > 	mem <---> dma engine <---> usb hci <---> usb peripheral
> >
> > (such setups do exist, but despite having such implementations I've never
> > tried to support it.)
> >
> > In this case, the dma engine, in response to control signals from the
> > USB host controller, will generate the appropriate bus address to access
> > memory and transfer the data into the USB HCI device.
> >
> > So, in this case, the struct device to be used for mapping memory for
> > transfers to the usb peripheral is the DMA engine device, not the USB HCI
> > device nor the USB peripheral device.
> 
> Thanks for the clarification. I think this is another reason why
> get_scatterlist should return the sg_list already mapped into the device
> address space - it's more consisten with the other dma apis. Another
> reason to completely hide everything but mapped addresses is crazy stuff
> like this
> 
> 	mem <---> tiling iommu <-+-> gpu
> 	                         |
> 	                         +-> scanout engine
> 	                         |
> 				 +-> mpeg decoder
> 
> where it doesn't really make sense to talk about the memory backing the
> dma buffer because that's smeared all over the place due to tiling. IIRC
> for the case of omap these devices can also access memory through other
> paths and iommut that don't tile (but just remap like a normal iommu)

I really don't get why you want to force the exporter to map the buffer into
clients dma address space. Only the client device might know all the quirks
required to do this correctly. Exporter should only provide a scatter-list 
with the memory that belongs to the exported buffer (might be pinned). How
do you want to solve the following case - the gpu hardware from your diagram
and a simple usb webcam with generic driver. The application would like to
export a buffer from the webcam to scanout engine. How the generic webcam 
driver might know HOW to set up the tiller to create correct mappings for 
the GPU/scanout? IMHO only a GPU driver is capable of doing that assuming
it got just a scatter list from the webcam driver.

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-11-28  7:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11  9:23 [RFC 0/2] Introduce dma buffer sharing mechanism Sumit Semwal
2011-10-11  9:23 ` [RFC 1/2] dma-buf: " Sumit Semwal
2011-10-12 12:41   ` [Linaro-mm-sig] " Dave Airlie
2011-10-12 13:28     ` Rob Clark
2011-10-12 13:35       ` Dave Airlie
2011-10-12 13:50         ` Rob Clark
2011-10-12 14:01           ` Dave Airlie
2011-10-12 14:24             ` Rob Clark
2011-10-12 14:34               ` Dave Airlie
2011-10-12 14:49                 ` Daniel Vetter
2011-10-12 15:15                 ` Rob Clark
2011-10-14 10:00   ` Tomasz Stanislawski
2011-10-14 14:13     ` Sumit Semwal
2011-10-14 15:34     ` Rob Clark
2011-10-14 15:35     ` Daniel Vetter
2011-11-03  8:04       ` Marek Szyprowski
2011-11-08 16:59         ` Clark, Rob
2011-11-08 17:42           ` [RFC 1/2] dma-buf: Introduce dma buffer sharing mechanismch Daniel Vetter
2011-11-08 17:55             ` Russell King - ARM Linux
2011-11-08 18:43               ` Daniel Vetter
2011-11-28  7:47                 ` Marek Szyprowski [this message]
2011-11-28 10:34                   ` Daniel Vetter
2011-11-25 14:13   ` [Linaro-mm-sig] [RFC 1/2] dma-buf: Introduce dma buffer sharing mechanism Dave Airlie
2011-11-25 16:02     ` Daniel Vetter
2011-11-25 16:15   ` Dave Airlie
2011-11-25 16:28     ` Dave Airlie
2011-11-26 14:00       ` Daniel Vetter
2011-11-27  6:59         ` Rob Clark
2011-12-01  5:51           ` Semwal, Sumit
2011-12-01  5:55             ` Semwal, Sumit
2011-10-11  9:23 ` [RFC 2/2] dma-buf: Documentation for buffer sharing framework Sumit Semwal
2011-10-12 22:30   ` Randy Dunlap
2011-10-13  4:48     ` Semwal, Sumit

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='000401ccada1$fbdcc030$f3964090$%szyprowski@samsung.com' \
    --to=m.szyprowski@samsung.com \
    --cc=arnd@arndb.de \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jesse.barker@linaro.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@arm.linux.org.uk \
    --cc=rob@ti.com \
    --cc=sumit.semwal@linaro.org \
    --cc=sumit.semwal@ti.com \
    --cc=t.stanislaws@samsung.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).