From: Robin Murphy <robin.murphy@arm.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
"Joerg Roedel (AMD)" <joro@8bytes.org>,
Will Deacon <will@kernel.org>, Leon Romanovsky <leon@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
Marek Szyprowski <m.szyprowski@samsung.com>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH RFC 1/2] iommu/dma: skip swiotlb bounce for DMA_ATTR_MMIO in iommu_dma_map_phys
Date: Fri, 18 Sep 2026 15:37:14 +0100 [thread overview]
Message-ID: <8f449ded-b4ca-401d-9225-6d1f9ac93e08@arm.com> (raw)
In-Reply-To: <20260916-iommu-dma-fix-v1-1-a59a0c45ec5b@nxp.com>
On 16/09/2026 4:23 pm, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> MMIO resources mapped via dma_map_resource() carry DMA_ATTR_MMIO. These
> never need swiotlb bounce buffering, but the current code enters the
> swiotlb path when the physical address is not page-aligned, then rejects
> the mapping because MMIO cannot be bounced.
>
> Move the DMA_ATTR_MMIO check before the swiotlb block so the entire bounce
> path is skipped for MMIO, falling through directly to __iommu_dma_map()
> which creates the IOVA mapping.
Acked-by: Robin Murphy <robin.murphy@arm.comn>
I'd agree that we shouldn't need patch #2 - I don't see any good reason
to ever try to use dma_iova_link() instead of dma_map_resource() for
mapping actual device data registers, and for the link API use-cases
where the "MMIO" is peer device memory and IOMMU isolation is more
relevant, it seems sensible to keep the alignment constraint unless and
until there is a definite compelling need to do otherwise.
Thanks,
Robin.
> Fixes: f9374de14c0e8 ("iommu/dma: implement DMA_ATTR_MMIO for iommu_dma_(un)map_phys()")
> Assisted-by: Claude:claude-opus-4-6
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/iommu/dma-iommu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 65d692ec7fced..26b9c2d71cd30 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -1228,9 +1228,9 @@ dma_addr_t iommu_dma_map_phys(struct device *dev, phys_addr_t phys, size_t size,
> * If both the physical buffer start address and size are page aligned,
> * we don't need to use a bounce page.
> */
> - if (dev_use_swiotlb(dev, size, dir) &&
> + if (!(attrs & DMA_ATTR_MMIO) && dev_use_swiotlb(dev, size, dir) &&
> iova_unaligned(iovad, phys, size)) {
> - if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
> + if (attrs & DMA_ATTR_REQUIRE_COHERENT)
> return DMA_MAPPING_ERROR;
>
> phys = iommu_dma_map_swiotlb(dev, phys, size, dir, attrs);
>
next prev parent reply other threads:[~2026-09-18 14:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 15:23 [PATCH RFC 0/2] iommu/dma: Fix DMA_ATTR_MMIO swiotlb rejection Peng Fan (OSS)
2026-09-16 15:23 ` [PATCH RFC 1/2] iommu/dma: skip swiotlb bounce for DMA_ATTR_MMIO in iommu_dma_map_phys Peng Fan (OSS)
2026-09-18 14:37 ` Robin Murphy [this message]
2026-09-16 15:23 ` [PATCH RFC 2/2] iommu/dma: skip swiotlb bounce for DMA_ATTR_MMIO in dma_iova_link() Peng Fan (OSS)
2026-09-18 12:37 ` [PATCH RFC 0/2] iommu/dma: Fix DMA_ATTR_MMIO swiotlb rejection Leon Romanovsky
2026-09-18 14:12 ` Peng Fan
2026-09-18 15:43 ` Marek Szyprowski
2026-09-18 15:49 ` Leon Romanovsky
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=8f449ded-b4ca-401d-9225-6d1f9ac93e08@arm.com \
--to=robin.murphy@arm.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=will@kernel.org \
/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®