From: Andrew Davis <afd@ti.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: "Rob Herring" <robh@kernel.org>,
"Saravana Kannan" <saravanak@google.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
"Brian Starkey" <Brian.Starkey@arm.com>,
"John Stultz" <jstultz@google.com>,
"T.J. Mercier" <tjmercier@google.com>,
"Christian König" <christian.koenig@amd.com>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Jared Kangas" <jkangas@redhat.com>,
"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, iommu@lists.linux.dev
Subject: Re: [PATCH v6 2/2] dma-buf: heaps: cma: Create CMA heap for each CMA reserved region
Date: Thu, 10 Jul 2025 09:46:56 -0500 [thread overview]
Message-ID: <547da8d7-1967-4c56-8bc1-da22a5283b77@ti.com> (raw)
In-Reply-To: <20250710-daft-secret-squid-fb3eee@houat>
On 7/10/25 2:44 AM, Maxime Ripard wrote:
> On Wed, Jul 09, 2025 at 11:14:37AM -0500, Andrew Davis wrote:
>> On 7/9/25 7:44 AM, Maxime Ripard wrote:
>>> 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.
>>>
>>> Signed-off-by: Maxime Ripard <mripard@kernel.org>
>>> ---
>>> drivers/dma-buf/heaps/cma_heap.c | 52 +++++++++++++++++++++++++++++++++++++++-
>>> 1 file changed, 51 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
>>> index 0df007111975447d555714d61ead9699287fd65a..31a18683ee25788a800f3f878fd958718a930ff7 100644
>>> --- a/drivers/dma-buf/heaps/cma_heap.c
>>> +++ b/drivers/dma-buf/heaps/cma_heap.c
>>> @@ -19,10 +19,12 @@
>>> #include <linux/err.h>
>>> #include <linux/highmem.h>
>>> #include <linux/io.h>
>>> #include <linux/mm.h>
>>> #include <linux/module.h>
>>> +#include <linux/of.h>
>>> +#include <linux/of_reserved_mem.h>
>>> #include <linux/scatterlist.h>
>>> #include <linux/slab.h>
>>> #include <linux/vmalloc.h>
>>> #define DEFAULT_CMA_NAME "default_cma_region"
>>> @@ -421,7 +423,55 @@ static int __init add_default_cma_heap(void)
>>> ERR_PTR(ret));
>>> }
>>> return 0;
>>> }
>>> -module_init(add_default_cma_heap);
>>> +
>>> +static int __init add_cma_heaps(void)
>>> +{
>>> + struct device_node *rmem_node;
>>> + struct device_node *node;
>>> + int ret;
>>> +
>>> + ret = add_default_cma_heap();
>>
>> Will this double add the default CMA region if it was declared
>> using DT (reserved-memory) when all those nodes are again scanned
>> through below? Might need a check in that loop for linux,cma-default.
>
> Yeah, but we probably should anyway. Otherwise, if linux,cma-default
> ever change on a platform, we would get heaps appearing/disappearing as
> we reboot, which doesn't sound great from a regression perspective.
>
> Both would allocate from the same pool though, so we don't risk stepping
> into each others toes. Or am I missing something?
>
You are not missing anything, having both wouldn't cause anything to break,
but would cause heaps to appear/disappear based on how the CMA region was
defined (DT vs kernel cmd line) which we should avoid.
Andrew
>>> + if (ret)
>>> + return ret;
>>> +
>>> + rmem_node = of_find_node_by_path("/reserved-memory");
>>> + if (!rmem_node)
>>> + goto out;
>>
>> Can just return here, "out" path doesn't need to put a NULL node.
>
> Oh, right. Thanks!
> Maxime
next prev parent reply other threads:[~2025-07-10 14:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 12:44 [PATCH v6 0/2] dma-buf: heaps: Create a " Maxime Ripard
2025-07-09 12:44 ` [PATCH v6 1/2] dma/contiguous: Add helper to test reserved memory type Maxime Ripard
2025-07-09 15:55 ` Andrew Davis
2025-07-10 7:36 ` Maxime Ripard
2025-07-09 12:44 ` [PATCH v6 2/2] dma-buf: heaps: cma: Create CMA heap for each CMA reserved region Maxime Ripard
2025-07-09 16:14 ` Andrew Davis
2025-07-10 7:44 ` Maxime Ripard
2025-07-10 14:46 ` Andrew Davis [this message]
2025-07-10 15:11 ` Maxime Ripard
2025-07-09 13:10 ` [PATCH v6 0/2] dma-buf: heaps: Create a " Nicolas Dufresne
2025-07-09 13:38 ` Maxime Ripard
2025-07-10 15:21 ` Nicolas Dufresne
2025-07-11 7:03 ` Maxime Ripard
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=547da8d7-1967-4c56-8bc1-da22a5283b77@ti.com \
--to=afd@ti.com \
--cc=Brian.Starkey@arm.com \
--cc=benjamin.gaignard@collabora.com \
--cc=christian.koenig@amd.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=iommu@lists.linux.dev \
--cc=jkangas@redhat.com \
--cc=jstultz@google.com \
--cc=krzk+dt@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mkorpershoek@kernel.org \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=saravanak@google.com \
--cc=sumit.semwal@linaro.org \
--cc=tjmercier@google.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
all inboxes | Powered by JetHome®