From: Christoph Hellwig <hch@infradead.org>
To: John Stultz <john.stultz@linaro.org>
Cc: Christoph Hellwig <hch@infradead.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>,
"Andrew F . Davis" <afd@ti.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>,
Rob Clark <robdclark@gmail.com>
Subject: Re: [PATCH v6 2/5] dma-buf: heaps: Add heap helpers
Date: Tue, 23 Jul 2019 23:58:13 -0700 [thread overview]
Message-ID: <20190724065813.GB16225@infradead.org> (raw)
In-Reply-To: <CALAqxLX1s4mbitE-_1s1vFPJrbrCKqpyhYoFW0V6hMEqE=eKVw@mail.gmail.com>
On Mon, Jul 22, 2019 at 09:09:25PM -0700, John Stultz wrote:
> On Thu, Jul 18, 2019 at 3:06 AM Christoph Hellwig <hch@infradead.org> wrote:
> >
> > > +void INIT_HEAP_HELPER_BUFFER(struct heap_helper_buffer *buffer,
> > > + void (*free)(struct heap_helper_buffer *))
> >
> > Please use a lower case naming following the naming scheme for the
> > rest of the file.
>
> Yes! Apologies as this was a hold-over from when the initialization
> function was an inline function in the style of
> INIT_WORK/INIT_LIST_HEAD. No longer appropriate that its a function.
> I'll change it.
>
> > > +static void *dma_heap_map_kernel(struct heap_helper_buffer *buffer)
> > > +{
> > > + void *vaddr;
> > > +
> > > + vaddr = vmap(buffer->pages, buffer->pagecount, VM_MAP, PAGE_KERNEL);
> > > + if (!vaddr)
> > > + return ERR_PTR(-ENOMEM);
> > > +
> > > + return vaddr;
> > > +}
> >
> > Unless I'm misreading the patches this is used for the same pages that
> > also might be dma mapped. In this case you need to use
> > flush_kernel_vmap_range and invalidate_kernel_vmap_range in the right
> > places to ensure coherency between the vmap and device view. Please
> > also document the buffer ownership, as this really can get complicated.
>
> Forgive me I wasn't familiar with those calls, but this seems like it
> would apply to all dma-buf exporters if so, and I don't see any
> similar flush_kernel_vmap_range calls there (both functions are
> seemingly only used by xfs, md and bio).
>
> We do have the dma_heap_dma_buf_begin_cpu_access()/dma_heap_dma_buf_end_cpu_access()
> hooks (see more on these below) which sync the buffers for each
> attachment (via dma_sync_sg_for_cpu/device), and are used around cpu
> access to the buffers. Are you suggesting the
> flush_kernel_vmap_range() call be added to those hooks or is the
> dma_sync_sg_for_* calls sufficient there?
dma_sync_sg_for_* only operates on the kernel direct mapping, that
is what you get from page_address/kmap* for the page. But with vmap
your create another alias in kernel virtual space, which
dma_sync_sg_for_* can't know about. Now for most CPUs caches are
indexed by physical addresses so this doesn't matter, but a significant
minority of CPUs (parisc, some arm, some mips) index by virtual address,
in which case we need non-empy flush_kernel_vmap_range and
invalidate_kernel_vmap_range helper to deal with that vmap alias.
next prev parent reply other threads:[~2019-07-24 6:58 UTC|newest]
Thread overview: 39+ 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-07-18 10:06 ` Christoph Hellwig
2019-07-23 4:09 ` John Stultz
2019-07-23 20:09 ` Rob Clark
2019-07-24 6:55 ` Christoph Hellwig
2019-07-24 15:20 ` Andrew F. Davis
2019-07-25 12:41 ` Christoph Hellwig
2019-07-25 15:23 ` Rob Clark
2019-07-24 6:58 ` Christoph Hellwig [this message]
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-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 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 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-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-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=20190724065813.GB16225@infradead.org \
--to=hch@infradead.org \
--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=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=robdclark@gmail.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 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).