From: sashiko-bot@kernel.org
To: "Mikko Perttunen" <mperttunen@nvidia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 04/11] ARM: dma-mapping: Implement and expose DMA setup functions
Date: Fri, 16 Oct 2026 07:06:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-173900@kernel.org> (raw)
In-Reply-To: <20261016-b4-arm32-iommu-dma-cookie-v2-4-b06842a01938@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] arm-iommu: missing owns_domain check in arm_iommu_attach_device causes kref warning
--
commit 9a5832f0c5c50cf332fad22584273f026af693a5
Author: Mikko Perttunen <mperttunen@nvidia.com>
ARM: dma-mapping: Implement and expose DMA setup functions
This commit allows the IOMMU core to allocate DMA domains and get the
cookie from the ARM DMA code. It implements ARM versions of
iommu_get_dma_cookie and iommu_put_dma_cookie.
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 4284950a92469..f2d3e8ec34872 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
[ ... ]
> @@ -1660,6 +1742,14 @@ void arm_iommu_detach_device(struct device *dev)
> return;
> }
>
> + /*
> + * This pairs with arm_iommu_attach_device() on a driver-owned mapping.
> + * A mapping which is merely the cookie of a core-owned default domain
> + * must not be torn down from here.
> + */
> + if (WARN_ON(!mapping->owns_domain))
> + return;
> +
[Severity: High]
Should __arm_iommu_attach_device() also have a similar check for
!mapping->owns_domain?
Mappings created by the IOMMU core via iommu_get_dma_cookie() are
zero-initialized and bypass kref_init(), relying instead on the owns_domain
flag being false to prevent refcount operations.
If a legacy driver saves a device's original core-owned mapping during
initialization and later attempts to restore it by calling
arm_iommu_attach_device(), __arm_iommu_attach_device() will execute:
arch/arm/mm/dma-mapping.c:__arm_iommu_attach_device() {
...
err = iommu_attach_device(mapping->domain, dev);
if (err)
return err;
kref_get(&mapping->kref);
...
}
Calling kref_get() on a zero-initialized kref would trigger a refcount warning
traceback. Does __arm_iommu_attach_device() need a
WARN_ON(!mapping->owns_domain) check to prevent driver interactions with
core-owned mappings?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016-b4-arm32-iommu-dma-cookie-v2-0-b06842a01938@nvidia.com?part=4
next prev parent reply other threads:[~2026-10-16 7:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 6:46 [PATCH v2 00/11] Make the 32-bit ARM DMA API work with normal IOMMU DMA default domains (+ Tegra PoC) Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 01/11] iommu: Add iommu_teardown_dma_ops Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 02/11] iommu: Add cookie type for ARM_DMA_USE_IOMMU Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 03/11] ARM: dma-mapping: Split mapping allocation from domain allocation Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 04/11] ARM: dma-mapping: Implement and expose DMA setup functions Mikko Perttunen
2026-10-16 7:06 ` sashiko-bot [this message]
2026-10-16 6:46 ` [PATCH v2 05/11] ARM: dma-mapping: Bypass the legacy path for core-owned DMA API domains Mikko Perttunen
2026-10-16 7:01 ` sashiko-bot
2026-10-16 6:46 ` [PATCH v2 06/11] ARM: dma-mapping: Handle foreign buffers in arm_iommu_get_sgtable Mikko Perttunen
2026-10-16 7:04 ` sashiko-bot
2026-10-16 6:46 ` [PATCH v2 07/11] iommu: Let 32-bit ARM drivers opt into a DMA API default domain Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 08/11] iommu/tegra-smmu: Defer display client translation to driver handover Mikko Perttunen
2026-10-16 7:01 ` sashiko-bot
2026-10-16 6:46 ` [PATCH v2 09/11] gpu: host1x: Drop release of legacy 32-bit ARM DMA domain Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 10/11] drm/tegra: " Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 11/11] iommu/tegra-smmu: Use a DMA API default domain per swgroup Mikko Perttunen
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=sashiko-outbox-173900@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mperttunen@nvidia.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.