public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>
Subject: Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink()
Date: Mon, 24 Nov 2025 19:20:38 +0200	[thread overview]
Message-ID: <20251124172038.GD12483@unreal> (raw)
In-Reply-To: <0b214028-299b-46aa-8d98-0f789153c612@arm.com>

On Mon, Nov 24, 2025 at 05:15:48PM +0000, Robin Murphy wrote:
> On 2025-11-24 5:09 pm, Marek Szyprowski wrote:
> > Commit c288d657dd51 added support for DMA_ATTR_MMIO attribute in the
> > dma_iova_link() code path, but missed that the CPU cache is being also
> > touched in the dma_iova_unlink() path. Fix this.
> > 
> > Fixes: c288d657dd51 ("iommu/dma: implement DMA_ATTR_MMIO for dma_iova_link().")
> > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > ---
> >   drivers/iommu/dma-iommu.c | 5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> > index e52d19d2e833..c92088855450 100644
> > --- a/drivers/iommu/dma-iommu.c
> > +++ b/drivers/iommu/dma-iommu.c
> > @@ -2008,7 +2008,7 @@ static void iommu_dma_iova_unlink_range_slow(struct device *dev,
> >   			end - addr, iovad->granule - iova_start_pad);
> >   		if (!dev_is_dma_coherent(dev) &&
> > -		    !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> > +		    !(attrs & (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_MMIO)))
> >   			arch_sync_dma_for_cpu(phys, len, dir);
> >   		swiotlb_tbl_unmap_single(dev, phys, len, dir, attrs);
> > @@ -2032,7 +2032,8 @@ static void __iommu_dma_iova_unlink(struct device *dev,
> >   	size_t unmapped;
> >   	if ((state->__size & DMA_IOVA_USE_SWIOTLB) ||
> > -	    (!dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)))
> > +	    (!dev_is_dma_coherent(dev) &&
> > +	     !(attrs & (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_MMIO))))
> 
> This isn't needed, since there's no way an MMIO mapping could have used
> SWIOTLB.

This "if" is taken even for non-SWIOTLB path, because of "||" operator
in line above.

Thanks

> 
> Thanks,
> Robin.
> 
> >   		iommu_dma_iova_unlink_range_slow(dev, addr, size, dir, attrs);
> >   	iommu_iotlb_gather_init(&iotlb_gather);
> 

  reply	other threads:[~2025-11-24 17:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20251124171014eucas1p21d3a0f2c10b43bfdb7861ee804f09951@eucas1p2.samsung.com>
2025-11-24 17:09 ` [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() Marek Szyprowski
2025-11-24 17:15   ` Robin Murphy
2025-11-24 17:20     ` Leon Romanovsky [this message]
2025-11-24 17:40       ` Robin Murphy
2025-11-24 17:26   ` Leon Romanovsky
2025-11-25 12:20     ` Marek Szyprowski
2025-11-24 18:17   ` Jason Gunthorpe
2025-11-24 18:46     ` Marek Szyprowski

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=20251124172038.GD12483@unreal \
    --to=leon@kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.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