Re: [PATCH 1/2] iommu/dma: Add helper for coherent devs without swiotlb

From: Joe Damato

Date: Wed Dec 02 2026 - 10:18:36 EST


On Tue, Dec 01, 2026 at 08:30:38PM +0000, Robin Murphy wrote:
> On 2026-11-06 5:57 pm, Joe Damato wrote:
> > Factor out some repeated logic which checks if a device is coherent and
> > if there is a swiotlb.
> >
> > Replace repeated instances of this logic with a call to the helper
> > instead.
>
> dev_use_swiotlb() itself already contains a frankly confusing number of
> levels of indirection. I guess I can buy the argument for patch #2, but
> please just make it the trivial 2-liner that doesn't obfuscate the
> conditions (and thus correlates even more clearly to those same
> conditions in the map path) i.e.:
>
> @@ -1280,7 +1280,8 @@ void iommu_dma_unmap_phys(struct device *dev, dma_addr_t dma_handle,
> {
> phys_addr_t phys;
> - if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)) {
> + if ((attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)) ||
> + (dev_is_dma_coherent(dev) && !dev_use_swiotlb(dev, size, dir))) {
> __iommu_dma_unmap(dev, dma_handle, size);
> return;
> }

OK, will do. I'll respin this as a single patch. Thanks a lot for the review,
I appreciate your time!