From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dma-coherent: report a failed reserved memory assignment
Date: Wed, 9 Sep 2026 11:29:31 +0200 [thread overview]
Message-ID: <fb39c105-db6c-4820-aee6-e423bf612cc7@samsung.com> (raw)
In-Reply-To: <20260905074727.108029-1-donggeunyoo.kernel@gmail.com>
On 05.09.2026 09:47, Donggeun Yoo wrote:
> rmem_dma_device_init() drops the return value of
> dma_assign_coherent_memory() and always reports success. That call fails
> with -EBUSY when the device already has a coherent pool, and the file
> allows only "*one* such region of memory" per device.
>
> of_reserved_mem_device_init_by_idx() reads the zero as success. It logs
> "assigned reserved memory node" for a region that was not assigned and
> records the pairing, so of_reserved_mem_device_release() later runs
> rmem_dma_device_release() for it. That clears dev->dma_mem without
> looking at which region it was called for, dropping the pool the device
> did get and leaving it on ordinary memory.
>
> dma_declare_coherent_memory() checks the same call and releases the
> memory on failure, and rmem_swiotlb_device_init() propagates its own
> errors. Return the error here as well, so a device tree that assigns two
> pools to one device fails the probe instead of half working.
>
> Fixes: 7bfa5ab6fa1b ("drivers: dma-coherent: add initialization from device tree")
> Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Applied to dma-mapping-fixes, thanks!
> ---
> Compile-tested only, with CONFIG_DMA_DECLARE_COHERENT=y and
> CONFIG_OF_RESERVED_MEM=y. I do not have a board that assigns two
> shared-dma-pool regions to one device; the release path was traced
> through of_reserved_mem_device_release() and rmem_dma_device_release()
> rather than observed.
>
> kernel/dma/coherent.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
> index 45bbae947f4b..4d0266893bcc 100644
> --- a/kernel/dma/coherent.c
> +++ b/kernel/dma/coherent.c
> @@ -352,8 +352,7 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
> min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit))
> dev_warn(dev, "reserved memory is beyond device's set DMA address range\n");
>
> - dma_assign_coherent_memory(dev, mem);
> - return 0;
> + return dma_assign_coherent_memory(dev, mem);
> }
>
> static void rmem_dma_device_release(struct reserved_mem *rmem,
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
prev parent reply other threads:[~2026-09-09 9:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260905074735eucas1p235b2a9129bc0bb01b5725d57149ed5f5@eucas1p2.samsung.com>
2026-09-05 7:47 ` [PATCH] dma-coherent: report a failed reserved memory assignment Donggeun Yoo
2026-09-09 9:29 ` Marek Szyprowski [this message]
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=fb39c105-db6c-4820-aee6-e423bf612cc7@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=donggeunyoo.kernel@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.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 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.