From: Minchan Kim <minchan@kernel.org>
To: John Stultz <john.stultz@linaro.org>
Cc: Hyesoo Yu <hyesoo.yu@samsung.com>,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
Matthew Wilcox <willy@infradead.org>,
david@redhat.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz,
Suren Baghdasaryan <surenb@google.com>,
KyongHo Cho <pullip.cho@samsung.com>,
John Dias <joaodias@google.com>,
Hridya Valsaraju <hridya@google.com>,
Sumit Semwal <sumit.semwal@linaro.org>,
Brian Starkey <Brian.Starkey@arm.com>,
linux-media <linux-media@vger.kernel.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>, Rob Herring <robh@kernel.org>,
Christian Koenig <christian.koenig@amd.com>,
"moderated list:DMA BUFFER SHARING FRAMEWORK"
<linaro-mm-sig@lists.linaro.org>,
Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Subject: Re: [PATCH 4/4] dma-heap: Devicetree binding for chunk heap
Date: Thu, 10 Dec 2020 08:06:36 -0800 [thread overview]
Message-ID: <X9JHjPTdxv6Z7lCW@google.com> (raw)
In-Reply-To: <CALAqxLWthd8bEDRMWmuOf8dOCW8=cFao9HBawKGuRhQZkdgXXw@mail.gmail.com>
On Thu, Dec 10, 2020 at 12:15:15AM -0800, John Stultz wrote:
> On Wed, Dec 9, 2020 at 3:53 PM Minchan Kim <minchan@kernel.org> wrote:
> > On Wed, Nov 18, 2020 at 07:19:07PM -0800, John Stultz wrote:
> > > The CMA heap currently only registers the default CMA heap, as we
> > > didn't want to expose all CMA regions and there's otherwise no way to
> > > pick and choose.
> >
> > Yub.
> >
> > dma-buf really need a way to make exclusive CMA area. Otherwise, default
> > CMA would be shared among drivers and introduce fragmentation easily
> > since we couldn't control other drivers. In such aspect, I don't think
> > current cma-heap works if userspace needs big memory chunk.
>
> Yes, the default CMA region is not always optimal.
>
> That's why I was hopeful for Kunihiko Hayashi's patch to allow for
> exposing specific cma regions:
> https://lore.kernel.org/lkml/1594948208-4739-1-git-send-email-hayashi.kunihiko@socionext.com/
>
> I think it would be a good solution, but all we need is *some* driver
> which can be considered the primary user/owner of the cma region which
> would then explicitly export it via the dmabuf heaps.
>
> > Here, the problem is there is no in-kernel user to bind the specific
> > CMA area because the owner will be random in userspace via dma-buf
> > interface.
>
> Well, while I agree that conceptually the dmabuf heaps allow for
> allocations for multi-device pipelines, and thus are not tied to
> specific devices. I do think that the memory types exposed are likely
> to have specific devices/drivers in the pipeline that it matters most
> to. So I don't see a big issue with the in-kernel driver registering a
> specific CMA region as a dmabuf heap.
Then, I am worry about that we spread out dma_heap_add_cma to too many
drivers since kernel doesn't how userspace will use it.
For example, system 1 could have device A-B-C pipeline so they added
it A driver. After that, system 2 could have device B-C-D pipeline
so they add dma_heap_add_cma into B device.
>
> > > > Is there a reason to use dma-heap framework to add cma-area for specific device ?
> > > >
> > > > Even if some in-tree users register dma-heap with cma-area, the buffers could be allocated in user-land and these could be shared among other devices.
> > > > For exclusive access, I guess, the device don't need to register dma-heap for cma area.
> > > >
> > >
> > > It's not really about exclusive access. More just that if you want to
> > > bind a memory reservation/region (cma or otherwise), at least for DTS,
> > > it needs to bind with some device in DT.
> > >
> > > Then the device driver can register that region with a heap driver.
> > > This avoids adding new Linux-specific software bindings to DT. It
> > > becomes a driver implementation detail instead. The primary user of
> > > the heap type would probably be a practical pick (ie the display or
> > > isp driver).
> >
> > If it's the only solution, we could create some dummy driver which has
> > only module_init and bind it from there but I don't think it's a good
> > idea.
>
> Yea, an un-upstreamable dummy driver is maybe what it devolves to in
> the worst case. But I suspect it would be cleaner for a display or ISP
> driver that benefits most from the heap type to add the reserved
> memory reference to their DT node, and on init for them to register
> the region with the dmabuf heap code.
As I mentioned above, it could be a display at this moment but it could
be different driver next time. If I miss your point, let me know.
Thanks for the review, John.
>
>
> > > The other potential solution Rob has suggested is that we create some
> > > tag for the memory reservation (ie: like we do with cma: "reusable"),
> > > which can be used to register the region to a heap. But this has the
> > > problem that each tag has to be well defined and map to a known heap.
> >
> > Do you think that's the only solution to make progress for this feature?
> > Then, could you elaborate it a bit more or any other ideas from dma-buf
> > folks?
>
> I'm skeptical of that DT tag approach working out, as we'd need a new
> DT binding for the new tag name, and we'd have to do so for each new
> heap type that needs this (so non-default cma, your chunk heap,
> whatever other similar heap types that use reserved regions folks come
> up with). Having *some* driver take ownership for the reserved region
> and register it with the appropriate heap type seems much
> cleaner/flexible and avoids mucking with the DT ABI.
>
> thanks
> -john
next prev parent reply other threads:[~2020-12-10 16:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-17 18:19 [PATCH 0/4] Chunk Heap Support on DMA-HEAP Minchan Kim
2020-11-17 18:19 ` [PATCH 1/4] mm: introduce cma_alloc_bulk API Minchan Kim
2020-11-23 14:15 ` David Hildenbrand
2020-11-25 20:12 ` Minchan Kim
2020-11-17 18:19 ` [PATCH 2/4] dma-buf: add export symbol for dma-heap Minchan Kim
2020-11-18 5:18 ` John Stultz
2020-11-17 18:19 ` [PATCH 3/4] dma-buf: heaps: add chunk heap to dmabuf heaps Minchan Kim
2020-11-18 9:00 ` Hillf Danton
2020-11-19 1:16 ` Hyesoo Yu
2020-11-17 18:19 ` [PATCH 4/4] dma-heap: Devicetree binding for chunk heap Minchan Kim
2020-11-18 3:00 ` John Stultz
2020-11-19 1:14 ` Hyesoo Yu
2020-11-19 3:19 ` John Stultz
2020-11-19 6:30 ` Hyesoo Yu
2020-12-09 23:53 ` Minchan Kim
2020-12-10 8:15 ` John Stultz
2020-12-10 16:06 ` Minchan Kim [this message]
2020-12-10 22:40 ` John Stultz
2020-12-10 23:30 ` Minchan Kim
2020-12-08 16:56 ` [PATCH 0/4] Chunk Heap Support on DMA-HEAP Nicolas Dufresne
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=X9JHjPTdxv6Z7lCW@google.com \
--to=minchan@kernel.org \
--cc=Brian.Starkey@arm.com \
--cc=akpm@linux-foundation.org \
--cc=christian.koenig@amd.com \
--cc=david@redhat.com \
--cc=devicetree@vger.kernel.org \
--cc=hayashi.kunihiko@socionext.com \
--cc=hridya@google.com \
--cc=hyesoo.yu@samsung.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=joaodias@google.com \
--cc=john.stultz@linaro.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pullip.cho@samsung.com \
--cc=robh@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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.