Maxime Ripard
4f5f8baf73
dma-buf: heaps: cma: Create CMA heap for each CMA reserved region
...
Aside from the main CMA region, it can be useful to allow userspace to
allocate from the other CMA reserved regions.
Indeed, those regions can have specific properties that can be useful to
a specific us-case.
For example, one of them platform I've been with has ECC enabled on the
entire memory but for a specific region. Using that region to allocate
framebuffers can be particular beneficial because enabling the ECC has a
performance and memory footprint cost.
Thus, exposing these regions as heaps user-space can allocate from and
import wherever needed allows to cover that use-case.
For now, only shared-dma-pools regions with the reusable property (ie,
backed by CMA) are supported, but eventually we'll want to support other
DMA pools types.
Since we collected all the CMA regions created during boot, we can
simply iterate over all of them to create the heaps.
This has a weird interaction with the recent work on the CMA name, in
particular the backward compatibility code created by commit
854acbe75f ("dma-buf: heaps: Give default CMA heap a fixed name").
Indeed, the old name was either 'reserved', or the name of the
reserved-memory region device tree node if the linux,cma-default
property was set.
In both these cases, we have now collected this region during boot, and
we're using the same name. So we're now largely redundant with the
code to handle backward compatibility code, and we can thus remove it
and the associated Kconfig option.
Reviewed-by: T.J. Mercier <tjmercier@google.com >
Signed-off-by: Maxime Ripard <mripard@kernel.org >
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org >
[sumits: rebased the doc to latest]
Link: https://lore.kernel.org/r/20251013-dma-buf-ecc-heap-v8-5-04ce150ea3d9@kernel.org
2025-10-18 21:31:22 +05:30
Jared Kangas
854acbe75f
dma-buf: heaps: Give default CMA heap a fixed name
...
The CMA heap's name in devtmpfs can vary depending on how the heap is
defined. Its name defaults to "reserved", but if a CMA area is defined
in the devicetree, the heap takes on the devicetree node's name, such as
"default-pool" or "linux,cma". To simplify naming, unconditionally name
it "default_cma_region", but keep a legacy node in place backed by the
same underlying allocator for backwards compatibility.
Reviewed-by: Maxime Ripard <mripard@kernel.org >
Signed-off-by: Jared Kangas <jkangas@redhat.com >
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org >
Link: https://lore.kernel.org/r/20250610131231.1724627-4-jkangas@redhat.com
2025-07-09 15:51:40 +05:30
John Stultz
b61614ec31
dma-buf: heaps: Add CMA heap to dmabuf heaps
...
This adds a CMA heap, which allows userspace to allocate
a dma-buf of contiguous memory out of a CMA region.
This code is an evolution of the Android ION implementation, so
thanks to its original author and maintainters:
Benjamin Gaignard, Laura Abbott, and others!
NOTE: This patch only adds the default CMA heap. We will enable
selectively adding other CMA memory regions to the dmabuf heaps
interface with a later patch (which requires a dt binding)
Cc: Laura Abbott <labbott@redhat.com >
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Cc: Sumit Semwal <sumit.semwal@linaro.org >
Cc: Liam Mark <lmark@codeaurora.org >
Cc: Pratik Patel <pratikp@codeaurora.org >
Cc: Brian Starkey <Brian.Starkey@arm.com >
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com >
Cc: Sudipto Paul <Sudipto.Paul@arm.com >
Cc: Andrew F. Davis <afd@ti.com >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Chenbo Feng <fengc@google.com >
Cc: Alistair Strachan <astrachan@google.com >
Cc: Hridya Valsaraju <hridya@google.com >
Cc: Sandeep Patil <sspatil@google.com >
Cc: Hillf Danton <hdanton@sina.com >
Cc: Dave Airlie <airlied@gmail.com >
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Reviewed-by: Brian Starkey <brian.starkey@arm.com >
Acked-by: Sandeep Patil <sspatil@android.com >
Acked-by: Laura Abbott <labbott@redhat.com >
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com >
Signed-off-by: John Stultz <john.stultz@linaro.org >
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-5-john.stultz@linaro.org
2019-12-11 11:13:37 +05:30
John Stultz
efa04fefeb
dma-buf: heaps: Add system heap to dmabuf heaps
...
This patch adds system heap to the dma-buf heaps framework.
This allows applications to get a page-allocator backed dma-buf
for non-contiguous memory.
This code is an evolution of the Android ION implementation, so
thanks to its original authors and maintainters:
Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others!
Cc: Laura Abbott <labbott@redhat.com >
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Cc: Sumit Semwal <sumit.semwal@linaro.org >
Cc: Liam Mark <lmark@codeaurora.org >
Cc: Pratik Patel <pratikp@codeaurora.org >
Cc: Brian Starkey <Brian.Starkey@arm.com >
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com >
Cc: Sudipto Paul <Sudipto.Paul@arm.com >
Cc: Andrew F. Davis <afd@ti.com >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Chenbo Feng <fengc@google.com >
Cc: Alistair Strachan <astrachan@google.com >
Cc: Hridya Valsaraju <hridya@google.com >
Cc: Sandeep Patil <sspatil@google.com >
Cc: Hillf Danton <hdanton@sina.com >
Cc: Dave Airlie <airlied@gmail.com >
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Reviewed-by: Brian Starkey <brian.starkey@arm.com >
Acked-by: Sandeep Patil <sspatil@android.com >
Acked-by: Laura Abbott <labbott@redhat.com >
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com >
Signed-off-by: John Stultz <john.stultz@linaro.org >
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-4-john.stultz@linaro.org
2019-12-11 11:13:36 +05:30
Sean Paul
d59c5e0250
Revert "dma-buf: heaps: Add system heap to dmabuf heaps"
...
This reverts commit 47a32f9c12 .
This patchset doesn't meet the UAPI requirements set out in [1] for the DRM
subsystem. Once the userspace component is reviewed and ready for merge
we can try again.
[1]- https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
Fixes: 47a32f9c12 ("dma-buf: heaps: Add system heap to dmabuf heaps")
Cc: Laura Abbott <labbott@redhat.com >
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Cc: Sumit Semwal <sumit.semwal@linaro.org >
Cc: Liam Mark <lmark@codeaurora.org >
Cc: Pratik Patel <pratikp@codeaurora.org >
Cc: Brian Starkey <Brian.Starkey@arm.com >
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com >
Cc: Sudipto Paul <Sudipto.Paul@arm.com >
Cc: Andrew F. Davis <afd@ti.com >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Chenbo Feng <fengc@google.com >
Cc: Alistair Strachan <astrachan@google.com >
Cc: Hridya Valsaraju <hridya@google.com >
Cc: Hillf Danton <hdanton@sina.com >
Cc: dri-devel@lists.freedesktop.org
Cc: Brian Starkey <brian.starkey@arm.com >
Cc: John Stultz <john.stultz@linaro.org >
Cc: "Andrew F. Davis" <afd@ti.com >
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Acked-by: David Airlie <airlied@linux.ie >
Signed-off-by: Sean Paul <sean@poorly.run >
Link: https://patchwork.freedesktop.org/patch/msgid/20191030203003.101156-4-sean@poorly.run
2019-10-30 16:41:33 -04:00
Sean Paul
2e7f7cb2b5
Revert "dma-buf: heaps: Add CMA heap to dmabuf heaps"
...
This reverts commit 43d7238fb9 .
This patchset doesn't meet the UAPI requirements set out in [1] for the DRM
subsystem. Once the userspace component is reviewed and ready for merge
we can try again.
[1]- https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
Fixes: 43d7238fb9 ("dma-buf: heaps: Add CMA heap to dmabuf heaps")
Cc: Laura Abbott <labbott@redhat.com >
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Cc: Sumit Semwal <sumit.semwal@linaro.org >
Cc: Liam Mark <lmark@codeaurora.org >
Cc: Pratik Patel <pratikp@codeaurora.org >
Cc: Brian Starkey <Brian.Starkey@arm.com >
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com >
Cc: Sudipto Paul <Sudipto.Paul@arm.com >
Cc: Andrew F. Davis <afd@ti.com >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Chenbo Feng <fengc@google.com >
Cc: Alistair Strachan <astrachan@google.com >
Cc: Hridya Valsaraju <hridya@google.com >
Cc: Hillf Danton <hdanton@sina.com >
Cc: dri-devel@lists.freedesktop.org
Cc: Brian Starkey <brian.starkey@arm.com >
Cc: John Stultz <john.stultz@linaro.org >
Cc: "Andrew F. Davis" <afd@ti.com >
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Acked-by: David Airlie <airlied@linux.ie >
Signed-off-by: Sean Paul <sean@poorly.run >
Link: https://patchwork.freedesktop.org/patch/msgid/20191030203003.101156-3-sean@poorly.run
2019-10-30 16:41:23 -04:00
John Stultz
43d7238fb9
dma-buf: heaps: Add CMA heap to dmabuf heaps
...
This adds a CMA heap, which allows userspace to allocate
a dma-buf of contiguous memory out of a CMA region.
This code is an evolution of the Android ION implementation, so
thanks to its original author and maintainters:
Benjamin Gaignard, Laura Abbott, and others!
NOTE: This patch only adds the default CMA heap. We will enable
selectively adding other CMA memory regions to the dmabuf heaps
interface with a later patch (which requires a dt binding)
Cc: Laura Abbott <labbott@redhat.com >
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Cc: Sumit Semwal <sumit.semwal@linaro.org >
Cc: Liam Mark <lmark@codeaurora.org >
Cc: Pratik Patel <pratikp@codeaurora.org >
Cc: Brian Starkey <Brian.Starkey@arm.com >
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com >
Cc: Sudipto Paul <Sudipto.Paul@arm.com >
Cc: Andrew F. Davis <afd@ti.com >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Chenbo Feng <fengc@google.com >
Cc: Alistair Strachan <astrachan@google.com >
Cc: Hridya Valsaraju <hridya@google.com >
Cc: Hillf Danton <hdanton@sina.com >
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Reviewed-by: Brian Starkey <brian.starkey@arm.com >
Acked-by: Laura Abbott <labbott@redhat.com >
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com >
Signed-off-by: John Stultz <john.stultz@linaro.org >
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20191021190310.85221-5-john.stultz@linaro.org
2019-10-25 17:01:49 +05:30
John Stultz
47a32f9c12
dma-buf: heaps: Add system heap to dmabuf heaps
...
This patch adds system heap to the dma-buf heaps framework.
This allows applications to get a page-allocator backed dma-buf
for non-contiguous memory.
This code is an evolution of the Android ION implementation, so
thanks to its original authors and maintainters:
Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others!
Cc: Laura Abbott <labbott@redhat.com >
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Cc: Sumit Semwal <sumit.semwal@linaro.org >
Cc: Liam Mark <lmark@codeaurora.org >
Cc: Pratik Patel <pratikp@codeaurora.org >
Cc: Brian Starkey <Brian.Starkey@arm.com >
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com >
Cc: Sudipto Paul <Sudipto.Paul@arm.com >
Cc: Andrew F. Davis <afd@ti.com >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Chenbo Feng <fengc@google.com >
Cc: Alistair Strachan <astrachan@google.com >
Cc: Hridya Valsaraju <hridya@google.com >
Cc: Hillf Danton <hdanton@sina.com >
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org >
Reviewed-by: Brian Starkey <brian.starkey@arm.com >
Acked-by: Laura Abbott <labbott@redhat.com >
Tested-by: Ayan Kumar Halder <ayan.halder@arm.com >
Signed-off-by: John Stultz <john.stultz@linaro.org >
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org >
Link: https://patchwork.freedesktop.org/patch/msgid/20191021190310.85221-4-john.stultz@linaro.org
2019-10-25 17:01:48 +05:30