Re: [PATCH v2 6/8] dma-direct: make dma_direct_map_phys() honor DMA_ATTR_CC_SHARED
From: Jason Gunthorpe
Date: Fri Apr 24 2026 - 18:45:40 EST
On Wed, Apr 22, 2026 at 11:46:06AM +0530, Aneesh Kumar K.V wrote:
> Also note that if a DMA_ATTR_CC_SHARED DMA address is not dma_capable,
> then swiotlb_map() will most likely fail as well.
Well, thats OK, frankly the platform is broken if it can't provide low
addresses that pass the dma mask check through swiotlb.
> We do check the resulting SWIOTLB-mapped address again in
> swiotlb_map(). That is, if a DMA_ATTR_CC_SHARED physical address
> fails because the resulting DMA address exceeds the DMA mask (due to
> phys_to_dma_unencrypted() adding the top bit), then the
> SWIOTLB-mapped DMA address will likely fail the capability check for
> the same reason, as it would also include the top bit.
Yes, platform is broken, no option but to fail.
> So, if we want, we could avoid moving that if condition. However,
> IMHO, we could make it more generic to indicate that if any address
> is not DMA-capable, and if a SWIOTLB is active, we should attempt
> swiotlb_map()
Yes that is how it should flow, the task falls to swiotlb to find a
usable address.
Hopefully platform people have done smart things and T=0 devices have
low addresses for unprotected memory and T=1 devices have low address
for private memory.
To make this work swiotlb will have to bounce into low address private
memory to achieve working DMA.
Jason