From: "Christian König" <christian.koenig@amd.com>
To: Maxime Ripard <mripard@kernel.org>, 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>
Cc: 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
Subject: Re: [PATCH v2 1/2] dma-buf: heaps: system: Remove global variable
Date: Tue, 1 Apr 2025 17:28:43 +0200 [thread overview]
Message-ID: <e268d75d-c75a-499e-872d-09f91defed6b@amd.com> (raw)
In-Reply-To: <20250401-dma-buf-ecc-heap-v2-1-043fd006a1af@kernel.org>
Am 01.04.25 um 17:12 schrieb Maxime Ripard:
> The system heap has been using its struct dma_heap pointer but wasn't
> using it anywhere.
>
> Since we'll need additional parameters to attach to that heap type,
> let's create a private structure and set it as the dma_heap drvdata,
> removing the global variable in the process.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
> drivers/dma-buf/heaps/system_heap.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index 26d5dc89ea1663a0d078e3a5723ca3d8d12b935f..adf422eaa33a52794f952d9d4260b8743d37f421 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -19,11 +19,13 @@
> #include <linux/module.h>
> #include <linux/scatterlist.h>
> #include <linux/slab.h>
> #include <linux/vmalloc.h>
>
> -static struct dma_heap *sys_heap;
> +struct system_heap {
> + struct dma_heap *heap;
> +};
>
> struct system_heap_buffer {
> struct dma_heap *heap;
> struct list_head attachments;
> struct mutex lock;
> @@ -422,17 +424,22 @@ static const struct dma_heap_ops system_heap_ops = {
> };
>
> static int __init system_heap_create(void)
> {
> struct dma_heap_export_info exp_info;
> + struct system_heap *sys_heap;
> +
> + sys_heap = kzalloc(sizeof(*sys_heap), GFP_KERNEL);
> + if (!sys_heap)
> + return -ENOMEM;
>
> exp_info.name = "system";
> exp_info.ops = &system_heap_ops;
> - exp_info.priv = NULL;
> + exp_info.priv = sys_heap;
Why do you even need this?
>
> - sys_heap = dma_heap_add(&exp_info);
> - if (IS_ERR(sys_heap))
> - return PTR_ERR(sys_heap);
> + sys_heap->heap = dma_heap_add(&exp_info);
> + if (IS_ERR(sys_heap->heap))
> + return PTR_ERR(sys_heap->heap);
That's clearly missing freeing sys_heap again.
Christian.
>
> return 0;
> }
> module_init(system_heap_create);
>
next prev parent reply other threads:[~2025-04-01 15:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 15:12 [PATCH v2 0/2] dma-buf: heaps: Support carved-out heaps Maxime Ripard
2025-04-01 15:12 ` [PATCH v2 1/2] dma-buf: heaps: system: Remove global variable Maxime Ripard
2025-04-01 15:28 ` Christian König [this message]
2025-04-03 7:04 ` Maxime Ripard
2025-04-01 15:12 ` [PATCH v2 2/2] dma-buf: heaps: Introduce a new heap for reserved memory 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=e268d75d-c75a-499e-872d-09f91defed6b@amd.com \
--to=christian.koenig@amd.com \
--cc=Brian.Starkey@arm.com \
--cc=benjamin.gaignard@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jstultz@google.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mkorpershoek@kernel.org \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).