* [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() [not found] <CGME20251124171014eucas1p21d3a0f2c10b43bfdb7861ee804f09951@eucas1p2.samsung.com> @ 2025-11-24 17:09 ` Marek Szyprowski 2025-11-24 17:15 ` Robin Murphy ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Marek Szyprowski @ 2025-11-24 17:09 UTC (permalink / raw) To: iommu, linux-kernel Cc: Marek Szyprowski, Robin Murphy, Joerg Roedel, Will Deacon, Leon Romanovsky, Jason Gunthorpe 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)))) iommu_dma_iova_unlink_range_slow(dev, addr, size, dir, attrs); iommu_iotlb_gather_init(&iotlb_gather); -- 2.34.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() 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 2025-11-24 17:26 ` Leon Romanovsky 2025-11-24 18:17 ` Jason Gunthorpe 2 siblings, 1 reply; 8+ messages in thread From: Robin Murphy @ 2025-11-24 17:15 UTC (permalink / raw) To: Marek Szyprowski, iommu, linux-kernel Cc: Joerg Roedel, Will Deacon, Leon Romanovsky, Jason Gunthorpe 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. Thanks, Robin. > iommu_dma_iova_unlink_range_slow(dev, addr, size, dir, attrs); > > iommu_iotlb_gather_init(&iotlb_gather); ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() 2025-11-24 17:15 ` Robin Murphy @ 2025-11-24 17:20 ` Leon Romanovsky 2025-11-24 17:40 ` Robin Murphy 0 siblings, 1 reply; 8+ messages in thread From: Leon Romanovsky @ 2025-11-24 17:20 UTC (permalink / raw) To: Robin Murphy Cc: Marek Szyprowski, iommu, linux-kernel, Joerg Roedel, Will Deacon, Jason Gunthorpe 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); > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() 2025-11-24 17:20 ` Leon Romanovsky @ 2025-11-24 17:40 ` Robin Murphy 0 siblings, 0 replies; 8+ messages in thread From: Robin Murphy @ 2025-11-24 17:40 UTC (permalink / raw) To: Leon Romanovsky Cc: Marek Szyprowski, iommu, linux-kernel, Joerg Roedel, Will Deacon, Jason Gunthorpe On 2025-11-24 5:20 pm, Leon Romanovsky wrote: > 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. Oof, clearly it's already time to stop trying to read code and go home... :) Thanks, Robin. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() 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:26 ` Leon Romanovsky 2025-11-25 12:20 ` Marek Szyprowski 2025-11-24 18:17 ` Jason Gunthorpe 2 siblings, 1 reply; 8+ messages in thread From: Leon Romanovsky @ 2025-11-24 17:26 UTC (permalink / raw) To: Marek Szyprowski Cc: iommu, linux-kernel, Robin Murphy, Joerg Roedel, Will Deacon, Jason Gunthorpe On Mon, Nov 24, 2025 at 06:09:55PM +0100, 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(-) > Thanks, Reviewed-by: Leon Romanovsky <leon@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() 2025-11-24 17:26 ` Leon Romanovsky @ 2025-11-25 12:20 ` Marek Szyprowski 0 siblings, 0 replies; 8+ messages in thread From: Marek Szyprowski @ 2025-11-25 12:20 UTC (permalink / raw) To: Leon Romanovsky Cc: iommu, linux-kernel, Robin Murphy, Joerg Roedel, Will Deacon, Jason Gunthorpe On 24.11.2025 18:26, Leon Romanovsky wrote: > On Mon, Nov 24, 2025 at 06:09:55PM +0100, 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(-) > Reviewed-by: Leon Romanovsky <leon@kernel.org> Applied to dma-mapping-fixes. Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() 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:26 ` Leon Romanovsky @ 2025-11-24 18:17 ` Jason Gunthorpe 2025-11-24 18:46 ` Marek Szyprowski 2 siblings, 1 reply; 8+ messages in thread From: Jason Gunthorpe @ 2025-11-24 18:17 UTC (permalink / raw) To: Marek Szyprowski Cc: iommu, linux-kernel, Robin Murphy, Joerg Roedel, Will Deacon, Leon Romanovsky On Mon, Nov 24, 2025 at 06:09:55PM +0100, 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(-) Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Did you find it by code inspection? Jason ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommu/dma: add missing support for DMA_ATTR_MMIO for dma_iova_unlink() 2025-11-24 18:17 ` Jason Gunthorpe @ 2025-11-24 18:46 ` Marek Szyprowski 0 siblings, 0 replies; 8+ messages in thread From: Marek Szyprowski @ 2025-11-24 18:46 UTC (permalink / raw) To: Jason Gunthorpe Cc: iommu, linux-kernel, Robin Murphy, Joerg Roedel, Will Deacon, Leon Romanovsky On 24.11.2025 19:17, Jason Gunthorpe wrote: > On Mon, Nov 24, 2025 at 06:09:55PM +0100, 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(-) > Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> > > Did you find it by code inspection? Yes, I checked how the batched CPu sync will fit there and noticed the unlink path, see https://lore.kernel.org/all/f8a0b873-b93c-4a91-b47d-2d11bfcf36b4@samsung.com/ Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-11-25 12:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox