All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Clark <robdclark@gmail.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: "Andrew F. Davis" <afd@ti.com>,
	John Stultz <john.stultz@linaro.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Laura Abbott <labbott@redhat.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Liam Mark <lmark@codeaurora.org>,
	Pratik Patel <pratikp@codeaurora.org>,
	Brian Starkey <Brian.Starkey@arm.com>,
	Vincent Donnefort <Vincent.Donnefort@arm.com>,
	Sudipto Paul <Sudipto.Paul@arm.com>,
	Xu YiPing <xuyiping@hisilicon.com>,
	"Chenfeng (puck)" <puck.chen@hisilicon.com>,
	butao <butao@hisilicon.com>,
	"Xiaqing (A)" <saberlily.xia@hisilicon.com>,
	Yudongbin <yudongbin@hisilicon.com>,
	Chenbo Feng <fengc@google.com>,
	Alistair Strachan <astrachan@google.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Hridya Valsaraju <hridya@google.com>
Subject: Re: [PATCH v6 2/5] dma-buf: heaps: Add heap helpers
Date: Thu, 25 Jul 2019 08:23:51 -0700	[thread overview]
Message-ID: <CAF6AEGuKMu+=HYxmOPUL-5gkU1a1aqCxbx+E2ygYQqy4gmZ0Xw@mail.gmail.com> (raw)
In-Reply-To: <20190725124142.GA20286@infradead.org>

On Thu, Jul 25, 2019 at 5:41 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Jul 24, 2019 at 11:20:31AM -0400, Andrew F. Davis wrote:
> > Well then lets think on this. A given buffer can have 3 owners states
> > (CPU-owned, Device-owned, and Un-owned). These are based on the caching
> > state from the CPU perspective.
> >
> > If a buffer is CPU-owned then we (Linux) can write to the buffer safely
> > without worry that the data is stale or that it will be accessed by the
> > device without having been flushed. Device-owned buffers should not be
> > accessed by the CPU, and inter-device synchronization should be handled
> > by fencing as Rob points out. Un-owned is how a buffer starts for
> > consistency and to prevent unneeded cache operations on unwritten buffers.
>
> CPU owned also needs to be split into which mapping owns it - in the
> normal DMA this is the kernel direct mapping, but in dma-buf it seems
> the primary way of using it in kernel space is the vmap, in addition
> to that the mappings can also be exported to userspace, which is another
> mapping that is possibly not cache coherent with the kernel one.

Just for some history, dmabuf->vmap() is optional, and mostly added
for the benefit of drm/udl (usb display, where CPU needs to read out
and encode (?) the video stream.. most of the drm drivers are using
tmpfs to get backing pages, and if there is any kernel direct mapping
it is unused.

It is probably ok for any allocator that does care about a kernel
direct mapping to simply not implement vmap.

BR,
-R

WARNING: multiple messages have this Message-ID (diff)
From: Rob Clark <robdclark@gmail.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: "Andrew F. Davis" <afd@ti.com>,
	John Stultz <john.stultz@linaro.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Laura Abbott <labbott@redhat.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Liam Mark <lmark@codeaurora.org>,
	Pratik Patel <pratikp@codeaurora.org>,
	Brian Starkey <Brian.Starkey@arm.com>,
	Vincent Donnefort <Vincent.Donnefort@arm.com>,
	Sudipto Paul <Sudipto.Paul@arm.com>,
	Xu YiPing <xuyiping@hisilicon.com>,
	"Chenfeng (puck)" <puck.chen@hisilicon.com>,
	butao <butao@hisilicon.com>,
	"Xiaqing (A)" <saberlily.xia@hisilicon.com>,
	Yudongbin <yudongbin@hisilicon.com>,
	Chenbo Feng <fengc@google.com>,
	Alistair Strachan <astrachan@google.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Hridy
Subject: Re: [PATCH v6 2/5] dma-buf: heaps: Add heap helpers
Date: Thu, 25 Jul 2019 08:23:51 -0700	[thread overview]
Message-ID: <CAF6AEGuKMu+=HYxmOPUL-5gkU1a1aqCxbx+E2ygYQqy4gmZ0Xw@mail.gmail.com> (raw)
In-Reply-To: <20190725124142.GA20286@infradead.org>

On Thu, Jul 25, 2019 at 5:41 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Jul 24, 2019 at 11:20:31AM -0400, Andrew F. Davis wrote:
> > Well then lets think on this. A given buffer can have 3 owners states
> > (CPU-owned, Device-owned, and Un-owned). These are based on the caching
> > state from the CPU perspective.
> >
> > If a buffer is CPU-owned then we (Linux) can write to the buffer safely
> > without worry that the data is stale or that it will be accessed by the
> > device without having been flushed. Device-owned buffers should not be
> > accessed by the CPU, and inter-device synchronization should be handled
> > by fencing as Rob points out. Un-owned is how a buffer starts for
> > consistency and to prevent unneeded cache operations on unwritten buffers.
>
> CPU owned also needs to be split into which mapping owns it - in the
> normal DMA this is the kernel direct mapping, but in dma-buf it seems
> the primary way of using it in kernel space is the vmap, in addition
> to that the mappings can also be exported to userspace, which is another
> mapping that is possibly not cache coherent with the kernel one.

Just for some history, dmabuf->vmap() is optional, and mostly added
for the benefit of drm/udl (usb display, where CPU needs to read out
and encode (?) the video stream.. most of the drm drivers are using
tmpfs to get backing pages, and if there is any kernel direct mapping
it is unused.

It is probably ok for any allocator that does care about a kernel
direct mapping to simply not implement vmap.

BR,
-R

  reply	other threads:[~2019-07-25 15:24 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 19:49 [PATCH v6 0/5] DMA-BUF Heaps (destaging ION) John Stultz
2019-06-24 19:49 ` [PATCH v6 1/5] dma-buf: Add dma-buf heaps framework John Stultz
2019-06-24 19:49 ` [PATCH v6 2/5] dma-buf: heaps: Add heap helpers John Stultz
2019-06-24 19:49   ` John Stultz
2019-07-18 10:06   ` Christoph Hellwig
2019-07-23  4:09     ` John Stultz
2019-07-23  4:09       ` John Stultz
2019-07-23 20:09       ` Rob Clark
2019-07-23 20:09         ` Rob Clark
2019-07-24  6:55         ` Christoph Hellwig
2019-07-24  6:55           ` Christoph Hellwig
2019-07-24 15:20           ` Andrew F. Davis
2019-07-24 15:20             ` Andrew F. Davis
2019-07-25 12:41             ` Christoph Hellwig
2019-07-25 12:41               ` Christoph Hellwig
2019-07-25 15:23               ` Rob Clark [this message]
2019-07-25 15:23                 ` Rob Clark
2019-07-24  6:58       ` Christoph Hellwig
2019-07-24  6:58         ` Christoph Hellwig
2019-06-24 19:49 ` [PATCH v6 3/5] dma-buf: heaps: Add system heap to dmabuf heaps John Stultz
2019-06-24 19:49 ` [PATCH v6 4/5] dma-buf: heaps: Add CMA " John Stultz
2019-07-18 10:08   ` Christoph Hellwig
2019-07-23  5:04     ` John Stultz
2019-07-23  5:04       ` John Stultz
2019-07-24  6:59       ` Christoph Hellwig
2019-07-24  8:08         ` Benjamin Gaignard
2019-07-25 12:45           ` Christoph Hellwig
2019-07-24 11:38         ` Laura Abbott
2019-07-25 12:48           ` Christoph Hellwig
2019-07-25 13:47             ` Andrew F. Davis
2019-07-25 13:47               ` Andrew F. Davis
2019-07-25 14:05               ` Christoph Hellwig
2019-07-24 15:46         ` Andrew F. Davis
2019-07-25 12:50           ` Christoph Hellwig
2019-07-25 13:31             ` Andrew F. Davis
2019-07-25 13:31               ` Andrew F. Davis
2019-07-25 14:04               ` Christoph Hellwig
2019-07-25 14:10                 ` Andrew F. Davis
2019-07-25 14:11                   ` Christoph Hellwig
2019-07-25 14:25                     ` Andrew F. Davis
2019-07-25 14:30                       ` Christoph Hellwig
2019-07-25 14:51                         ` Andrew F. Davis
2019-07-25 14:51                           ` Andrew F. Davis
2019-07-24 18:46         ` John Stultz
2019-07-24 18:46           ` John Stultz
2019-07-25 12:52           ` Christoph Hellwig
2019-07-25 13:20             ` Benjamin Gaignard
2019-07-25 14:33               ` Christoph Hellwig
2019-07-25 14:46                 ` Benjamin Gaignard
2019-06-24 19:49 ` [PATCH v6 5/5] kselftests: Add dma-heap test John Stultz
2019-06-24 19:49   ` John Stultz
2019-07-01 21:45 ` [PATCH v6 0/5] DMA-BUF Heaps (destaging ION) Laura Abbott
2019-07-01 21:55   ` John Stultz

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='CAF6AEGuKMu+=HYxmOPUL-5gkU1a1aqCxbx+E2ygYQqy4gmZ0Xw@mail.gmail.com' \
    --to=robdclark@gmail.com \
    --cc=Brian.Starkey@arm.com \
    --cc=Sudipto.Paul@arm.com \
    --cc=Vincent.Donnefort@arm.com \
    --cc=afd@ti.com \
    --cc=astrachan@google.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=butao@hisilicon.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fengc@google.com \
    --cc=hch@infradead.org \
    --cc=hridya@google.com \
    --cc=john.stultz@linaro.org \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lmark@codeaurora.org \
    --cc=pratikp@codeaurora.org \
    --cc=puck.chen@hisilicon.com \
    --cc=saberlily.xia@hisilicon.com \
    --cc=sumit.semwal@linaro.org \
    --cc=xuyiping@hisilicon.com \
    --cc=yudongbin@hisilicon.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.