All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
	Daniel Vetter <daniel@ffwll.ch>,
	t.stanislaws@samsung.com, linux@arm.linux.org.uk,
	Sumit Semwal <sumit.semwal@ti.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
	jesse.barker@linaro.org, rob@ti.com, linux-media@vger.kernel.org,
	Sumit Semwal <sumit.semwal@linaro.org>,
	m.szyprowski@samsung.com
Subject: Re: [RFC v2 1/2] dma-buf: Introduce dma buffer sharing mechanism
Date: Mon, 5 Dec 2011 23:33:44 +0100	[thread overview]
Message-ID: <CAKMK7uH3KUOXXWfvdTWQMy1cBkctpUR6TP=xks63jX5-3XsFaA@mail.gmail.com> (raw)
In-Reply-To: <1438420.NYDLGGgKNc@wuerfel>

On Mon, Dec 05, 2011 at 11:04:09PM +0100, Arnd Bergmann wrote:
> On Monday 05 December 2011 21:58:39 Daniel Vetter wrote:
> > On Mon, Dec 05, 2011 at 08:29:49PM +0100, Arnd Bergmann wrote:
> > > ...
> >
> > Thanks a lot for this excellent overview. I think at least for the first
> > version of dmabuf we should drop the sync_* interfaces and simply require
> > users to bracket their usage of the buffer from the attached device by
> > map/unmap. A dma_buf provider is always free to cache the mapping and
> > simply call sync_sg_for of the streaming dma api.
>
> I think we still have the same problem if we allow multiple drivers
> to access a noncoherent buffer using map/unmap:
>
> 	driver A				driver B
>
> 1.	read/write				
> 2.						read/write
> 3.	map()					
> 4.						read/write
> 5.	dma
> 6.						map()
> 7.	dma
> 8.						dma
> 9.	unmap()
> 10.						dma
> 11.	read/write
> 12.						unmap()						
>
>
> In step 4, the buffer is owned by device A, but accessed by driver B, which
> is a bug. In step 11, the buffer is owned by device B but accessed by driver
> A, which is the same bug on the other side. In steps 7 and 8, the buffer
> is owned by both device A and B, which is currently undefined but would
> be ok if both devices are on the same coherency domain. Whether that point
> is meaningful depends on what the devices actually do. It would be ok
> if both are only reading, but not if they write into the same location
> concurrently.
>
> As I mentioned originally, the problem could be completely avoided if
> we only allow consistent (e.g. uncached) mappings or buffers that
> are not mapped into the kernel virtual address space at all.
>
> Alternatively, a clearer model would be to require each access to
> nonconsistent buffers to be exclusive: a map() operation would have
> to block until the current mapper (if any) has done an unmap(), and
> any access from the CPU would also have to call a dma_buf_ops pointer
> to serialize the CPU accesses with any device accesses. User
> mappings of the buffer can be easily blocked during a DMA access
> by unmapping the buffer from user space at map() time and blocking the
> vm_ops->fault() operation until the unmap().

See my other mail where I propose a more explicit coherency model, just a
comment here: GPU drivers hate blocking interfaces. Loathe, actually. In
general they're very happy to extend you any amount of rope if it can make
userspace a few percent faster.

So I think the right answer here is: You've asked for trouble, you've got
it. Also see the issue raised by Rob, at least for opengl (and also for
other graphics interfaces) the kernel is not even aware of all outstanding
rendering. So userspace needs to orchestrate access anyway if a gpu is
involved.

Otherwise I agree with your points in this mail.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
	Daniel Vetter <daniel@ffwll.ch>,
	t.stanislaws@samsung.com, linux@arm.linux.org.uk,
	Sumit Semwal <sumit.semwal@ti.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
	jesse.barker@linaro.org, rob@ti.com, linux-media@vger.kernel.org,
	Sumit Semwal <sumit.semwal@linaro.org>,
	m.szyprowski@samsung.com
Subject: Re: [RFC v2 1/2] dma-buf: Introduce dma buffer sharing mechanism
Date: Mon, 5 Dec 2011 23:33:44 +0100	[thread overview]
Message-ID: <CAKMK7uH3KUOXXWfvdTWQMy1cBkctpUR6TP=xks63jX5-3XsFaA@mail.gmail.com> (raw)
In-Reply-To: <1438420.NYDLGGgKNc@wuerfel>

On Mon, Dec 05, 2011 at 11:04:09PM +0100, Arnd Bergmann wrote:
> On Monday 05 December 2011 21:58:39 Daniel Vetter wrote:
> > On Mon, Dec 05, 2011 at 08:29:49PM +0100, Arnd Bergmann wrote:
> > > ...
> >
> > Thanks a lot for this excellent overview. I think at least for the first
> > version of dmabuf we should drop the sync_* interfaces and simply require
> > users to bracket their usage of the buffer from the attached device by
> > map/unmap. A dma_buf provider is always free to cache the mapping and
> > simply call sync_sg_for of the streaming dma api.
>
> I think we still have the same problem if we allow multiple drivers
> to access a noncoherent buffer using map/unmap:
>
> 	driver A				driver B
>
> 1.	read/write				
> 2.						read/write
> 3.	map()					
> 4.						read/write
> 5.	dma
> 6.						map()
> 7.	dma
> 8.						dma
> 9.	unmap()
> 10.						dma
> 11.	read/write
> 12.						unmap()						
>
>
> In step 4, the buffer is owned by device A, but accessed by driver B, which
> is a bug. In step 11, the buffer is owned by device B but accessed by driver
> A, which is the same bug on the other side. In steps 7 and 8, the buffer
> is owned by both device A and B, which is currently undefined but would
> be ok if both devices are on the same coherency domain. Whether that point
> is meaningful depends on what the devices actually do. It would be ok
> if both are only reading, but not if they write into the same location
> concurrently.
>
> As I mentioned originally, the problem could be completely avoided if
> we only allow consistent (e.g. uncached) mappings or buffers that
> are not mapped into the kernel virtual address space at all.
>
> Alternatively, a clearer model would be to require each access to
> nonconsistent buffers to be exclusive: a map() operation would have
> to block until the current mapper (if any) has done an unmap(), and
> any access from the CPU would also have to call a dma_buf_ops pointer
> to serialize the CPU accesses with any device accesses. User
> mappings of the buffer can be easily blocked during a DMA access
> by unmapping the buffer from user space at map() time and blocking the
> vm_ops->fault() operation until the unmap().

See my other mail where I propose a more explicit coherency model, just a
comment here: GPU drivers hate blocking interfaces. Loathe, actually. In
general they're very happy to extend you any amount of rope if it can make
userspace a few percent faster.

So I think the right answer here is: You've asked for trouble, you've got
it. Also see the issue raised by Rob, at least for opengl (and also for
other graphics interfaces) the kernel is not even aware of all outstanding
rendering. So userspace needs to orchestrate access anyway if a gpu is
involved.

Otherwise I agree with your points in this mail.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

--
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>

WARNING: multiple messages have this Message-ID (diff)
From: daniel@ffwll.ch (Daniel Vetter)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2 1/2] dma-buf: Introduce dma buffer sharing mechanism
Date: Mon, 5 Dec 2011 23:33:44 +0100	[thread overview]
Message-ID: <CAKMK7uH3KUOXXWfvdTWQMy1cBkctpUR6TP=xks63jX5-3XsFaA@mail.gmail.com> (raw)
In-Reply-To: <1438420.NYDLGGgKNc@wuerfel>

On Mon, Dec 05, 2011 at 11:04:09PM +0100, Arnd Bergmann wrote:
> On Monday 05 December 2011 21:58:39 Daniel Vetter wrote:
> > On Mon, Dec 05, 2011 at 08:29:49PM +0100, Arnd Bergmann wrote:
> > > ...
> >
> > Thanks a lot for this excellent overview. I think at least for the first
> > version of dmabuf we should drop the sync_* interfaces and simply require
> > users to bracket their usage of the buffer from the attached device by
> > map/unmap. A dma_buf provider is always free to cache the mapping and
> > simply call sync_sg_for of the streaming dma api.
>
> I think we still have the same problem if we allow multiple drivers
> to access a noncoherent buffer using map/unmap:
>
> 	driver A				driver B
>
> 1.	read/write				
> 2.						read/write
> 3.	map()					
> 4.						read/write
> 5.	dma
> 6.						map()
> 7.	dma
> 8.						dma
> 9.	unmap()
> 10.						dma
> 11.	read/write
> 12.						unmap()						
>
>
> In step 4, the buffer is owned by device A, but accessed by driver B, which
> is a bug. In step 11, the buffer is owned by device B but accessed by driver
> A, which is the same bug on the other side. In steps 7 and 8, the buffer
> is owned by both device A and B, which is currently undefined but would
> be ok if both devices are on the same coherency domain. Whether that point
> is meaningful depends on what the devices actually do. It would be ok
> if both are only reading, but not if they write into the same location
> concurrently.
>
> As I mentioned originally, the problem could be completely avoided if
> we only allow consistent (e.g. uncached) mappings or buffers that
> are not mapped into the kernel virtual address space at all.
>
> Alternatively, a clearer model would be to require each access to
> nonconsistent buffers to be exclusive: a map() operation would have
> to block until the current mapper (if any) has done an unmap(), and
> any access from the CPU would also have to call a dma_buf_ops pointer
> to serialize the CPU accesses with any device accesses. User
> mappings of the buffer can be easily blocked during a DMA access
> by unmapping the buffer from user space at map() time and blocking the
> vm_ops->fault() operation until the unmap().

See my other mail where I propose a more explicit coherency model, just a
comment here: GPU drivers hate blocking interfaces. Loathe, actually. In
general they're very happy to extend you any amount of rope if it can make
userspace a few percent faster.

So I think the right answer here is: You've asked for trouble, you've got
it. Also see the issue raised by Rob, at least for opengl (and also for
other graphics interfaces) the kernel is not even aware of all outstanding
rendering. So userspace needs to orchestrate access anyway if a gpu is
involved.

Otherwise I agree with your points in this mail.
-Daniel
-- 
Daniel Vetter
Mail: daniel at ffwll.ch
Mobile: +41 (0)79 365 57 48

  reply	other threads:[~2011-12-05 22:33 UTC|newest]

Thread overview: 198+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-02  8:57 [RFC v2 0/2] Introduce DMA buffer sharing mechanism Sumit Semwal
2011-12-02  8:57 ` Sumit Semwal
2011-12-02  8:57 ` Sumit Semwal
2011-12-02  8:57 ` [RFC v2 1/2] dma-buf: Introduce dma " Sumit Semwal
2011-12-02  8:57   ` Sumit Semwal
2011-12-02 17:11   ` Konrad Rzeszutek Wilk
2011-12-02 17:11     ` Konrad Rzeszutek Wilk
2011-12-02 17:11     ` Konrad Rzeszutek Wilk
2011-12-05  9:48     ` Semwal, Sumit
2011-12-05  9:48       ` Semwal, Sumit
2011-12-05  9:48       ` Semwal, Sumit
2011-12-05 17:18   ` Arnd Bergmann
2011-12-05 17:18     ` Arnd Bergmann
2011-12-05 17:18     ` Arnd Bergmann
2011-12-05 18:55     ` Daniel Vetter
2011-12-05 18:55       ` Daniel Vetter
2011-12-05 18:55       ` Daniel Vetter
2011-12-05 19:29       ` Arnd Bergmann
2011-12-05 19:29         ` Arnd Bergmann
2011-12-05 19:29         ` Arnd Bergmann
2011-12-05 20:58         ` Daniel Vetter
2011-12-05 20:58           ` Daniel Vetter
2011-12-05 20:58           ` Daniel Vetter
2011-12-05 22:04           ` Arnd Bergmann
2011-12-05 22:04             ` Arnd Bergmann
2011-12-05 22:04             ` Arnd Bergmann
2011-12-05 22:33             ` Daniel Vetter [this message]
2011-12-05 22:33               ` Daniel Vetter
2011-12-05 22:33               ` Daniel Vetter
2011-12-05 20:46     ` Rob Clark
2011-12-05 20:46       ` Rob Clark
2011-12-05 20:46       ` Rob Clark
2011-12-05 21:23       ` Daniel Vetter
2011-12-05 21:23         ` Daniel Vetter
2011-12-05 21:23         ` Daniel Vetter
2011-12-05 22:11         ` Rob Clark
2011-12-05 22:11           ` Rob Clark
2011-12-05 22:11           ` Rob Clark
2011-12-05 22:33           ` Daniel Vetter
2011-12-05 22:33             ` Daniel Vetter
2011-12-05 22:33             ` Daniel Vetter
2011-12-06 13:16           ` Arnd Bergmann
2011-12-06 13:16             ` Arnd Bergmann
2011-12-06 13:16             ` Arnd Bergmann
2011-12-06 15:28             ` Daniel Vetter
2011-12-06 15:28               ` Daniel Vetter
2011-12-06 15:28               ` Daniel Vetter
2011-12-07 13:27           ` Semwal, Sumit
2011-12-07 13:27             ` Semwal, Sumit
2011-12-07 13:27             ` Semwal, Sumit
2011-12-07 13:40             ` Arnd Bergmann
2011-12-07 13:40               ` Arnd Bergmann
2011-12-07 13:40               ` Arnd Bergmann
2011-12-08 21:44               ` [Linaro-mm-sig] " Daniel Vetter
2011-12-08 21:44                 ` Daniel Vetter
2011-12-08 21:44                 ` Daniel Vetter
2011-12-09 14:13                 ` Arnd Bergmann
2011-12-09 14:13                   ` Arnd Bergmann
2011-12-09 14:13                   ` Arnd Bergmann
2011-12-09 14:24                   ` Alan Cox
2011-12-09 14:24                     ` Alan Cox
2011-12-09 14:24                     ` Alan Cox
2011-12-10  4:01                     ` Daniel Vetter
2011-12-10  4:01                       ` Daniel Vetter
2011-12-10  4:01                       ` Daniel Vetter
2011-12-12 16:48                       ` Arnd Bergmann
2011-12-12 16:48                         ` Arnd Bergmann
2011-12-12 16:48                         ` Arnd Bergmann
2011-12-19  6:16                         ` Semwal, Sumit
2011-12-19  6:16                           ` Semwal, Sumit
2011-12-19  6:16                           ` Semwal, Sumit
2011-12-20 15:41                           ` Arnd Bergmann
2011-12-20 15:41                             ` Arnd Bergmann
2011-12-20 15:41                             ` Arnd Bergmann
2011-12-20 16:41                             ` Rob Clark
2011-12-20 16:41                               ` Rob Clark
2011-12-20 16:41                               ` Rob Clark
2011-12-20 17:14                               ` Daniel Vetter
2011-12-20 17:14                                 ` Daniel Vetter
2011-12-20 17:14                                 ` Daniel Vetter
2011-12-20 17:14                                 ` Daniel Vetter
2011-12-21 17:27                                 ` Arnd Bergmann
2011-12-21 17:27                                   ` Arnd Bergmann
2011-12-21 17:27                                   ` Arnd Bergmann
2011-12-21 19:04                                   ` Daniel Vetter
2011-12-21 19:04                                     ` Daniel Vetter
2011-12-21 19:04                                     ` Daniel Vetter
2011-12-23 10:00                                   ` Semwal, Sumit
2011-12-23 10:00                                     ` Semwal, Sumit
2011-12-23 10:00                                     ` Semwal, Sumit
2011-12-23 17:10                                     ` Rob Clark
2011-12-23 17:10                                       ` Rob Clark
2011-12-23 17:10                                       ` Rob Clark
2011-12-20  9:03                   ` Sakari Ailus
2011-12-20  9:03                     ` Sakari Ailus
2011-12-20  9:03                     ` Sakari Ailus
2011-12-20 15:36                     ` Arnd Bergmann
2011-12-20 15:36                       ` Arnd Bergmann
2011-12-20 15:36                       ` Arnd Bergmann
2012-01-01 20:53                       ` Sakari Ailus
2012-01-01 20:53                         ` Sakari Ailus
2012-01-01 20:53                         ` Sakari Ailus
2012-01-01 23:12                         ` Rob Clark
2012-01-01 23:12                           ` Rob Clark
2012-01-01 23:12                           ` Rob Clark
2011-12-13 13:33                 ` Hans Verkuil
2011-12-13 13:33                   ` Hans Verkuil
2011-12-13 13:33                   ` Hans Verkuil
2011-12-05 22:09       ` Arnd Bergmann
2011-12-05 22:09         ` Arnd Bergmann
2011-12-05 22:09         ` Arnd Bergmann
2011-12-05 22:09         ` Arnd Bergmann
2011-12-05 22:15         ` Rob Clark
2011-12-05 22:15           ` Rob Clark
2011-12-05 22:15           ` Rob Clark
2011-12-05 22:35         ` Rob Clark
2011-12-05 22:35           ` Rob Clark
2011-12-05 22:35           ` Rob Clark
2011-12-07  6:35     ` Semwal, Sumit
2011-12-07  6:35       ` Semwal, Sumit
2011-12-07  6:35       ` Semwal, Sumit
2011-12-07 10:11       ` Arnd Bergmann
2011-12-07 10:11         ` Arnd Bergmann
2011-12-07 10:11         ` Arnd Bergmann
2011-12-07 11:02         ` Semwal, Sumit
2011-12-07 11:02           ` Semwal, Sumit
2011-12-07 11:02           ` Semwal, Sumit
2011-12-07 11:34           ` Arnd Bergmann
2011-12-07 11:34             ` Arnd Bergmann
2011-12-07 11:34             ` Arnd Bergmann
2011-12-09 22:50     ` [Linaro-mm-sig] " Robert Morell
2011-12-09 22:50       ` Robert Morell
2011-12-09 22:50       ` Robert Morell
2011-12-09 22:50       ` Robert Morell
2011-12-10 11:13       ` Mauro Carvalho Chehab
2011-12-10 11:13         ` Mauro Carvalho Chehab
2011-12-10 11:13         ` Mauro Carvalho Chehab
2011-12-10 11:13         ` Mauro Carvalho Chehab
2011-12-12 22:44         ` Robert Morell
2011-12-12 22:44           ` Robert Morell
2011-12-12 22:44           ` Robert Morell
2011-12-12 22:44           ` Robert Morell
2011-12-13 15:10           ` Arnd Bergmann
2011-12-13 15:10             ` Arnd Bergmann
2011-12-13 15:10             ` Arnd Bergmann
2011-12-13 15:10             ` Arnd Bergmann
2011-12-20  2:05             ` Robert Morell
2011-12-20  2:05               ` Robert Morell
2011-12-20  2:05               ` Robert Morell
2011-12-20  2:05               ` Robert Morell
2011-12-20 14:29               ` Anca Emanuel
2011-12-20 14:29                 ` Anca Emanuel
2011-12-20 14:29                 ` Anca Emanuel
2011-12-20 14:29                 ` Anca Emanuel
2012-01-09  6:20   ` InKi Dae
2012-01-09  6:20     ` InKi Dae
2012-01-09  6:20     ` InKi Dae
2012-01-09  8:10     ` Daniel Vetter
2012-01-09  8:10       ` Daniel Vetter
2012-01-09  8:10       ` Daniel Vetter
2012-01-09  8:11       ` [Linaro-mm-sig] " Dave Airlie
2012-01-09  8:11         ` Dave Airlie
2012-01-09  8:11         ` Dave Airlie
2012-01-09 10:10       ` InKi Dae
2012-01-09 10:10         ` InKi Dae
2012-01-09 10:10         ` InKi Dae
2012-01-09 10:27         ` Daniel Vetter
2012-01-09 10:27           ` Daniel Vetter
2012-01-09 10:27           ` Daniel Vetter
2012-01-09 12:06           ` InKi Dae
2012-01-09 12:06             ` InKi Dae
2012-01-09 12:06             ` InKi Dae
2012-01-09 16:02             ` Daniel Vetter
2012-01-09 16:02               ` Daniel Vetter
2012-01-09 16:02               ` Daniel Vetter
2012-01-09 15:17         ` Rob Clark
2012-01-09 15:17           ` Rob Clark
2012-01-09 15:17           ` Rob Clark
2012-01-10  1:34           ` InKi Dae
2012-01-10  1:34             ` InKi Dae
2012-01-10  1:34             ` InKi Dae
2012-01-10  2:14             ` Rob Clark
2012-01-10  2:14               ` Rob Clark
2012-01-10  2:14               ` Rob Clark
2012-01-10  6:09               ` Semwal, Sumit
2012-01-10  6:09                 ` Semwal, Sumit
2012-01-10  6:09                 ` Semwal, Sumit
2012-01-10  7:28                 ` InKi Dae
2012-01-10  7:28                   ` InKi Dae
2012-01-10  7:28                   ` InKi Dae
2012-01-10  9:19                   ` InKi Dae
2012-01-10  9:19                     ` InKi Dae
2012-01-10  9:19                     ` InKi Dae
2012-01-11  1:08               ` InKi Dae
2012-01-11  1:08                 ` InKi Dae
2012-01-11  1:08                 ` InKi Dae
2011-12-02  8:57 ` [RFC v2 2/2] dma-buf: Documentation for buffer sharing framework Sumit Semwal
2011-12-02  8:57   ` Sumit Semwal

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='CAKMK7uH3KUOXXWfvdTWQMy1cBkctpUR6TP=xks63jX5-3XsFaA@mail.gmail.com' \
    --to=daniel@ffwll.ch \
    --cc=arnd@arndb.de \
    --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=m.szyprowski@samsung.com \
    --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 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.