Re: [PATCH v8 12/23] dma: swiotlb: pass mapping attributes by reference

From: Aneesh Kumar K . V

Date: Wed Jul 29 2026 - 05:16:41 EST


Mostafa Saleh <smostafa@xxxxxxxxxx> writes:

> On Fri, Jul 17, 2026 at 11:34:30PM +0530, Aneesh Kumar K.V (Arm) wrote:
>> Change swiotlb_tbl_map_single() to take the DMA mapping attributes by
>> reference and update the direct callers accordingly.
>>
>> This is a preparatory change for a follow-up patch which updates the
>> attributes based on the selected swiotlb pool. Keeping the signature change
>> separate makes the follow-up patch easier to review.
>>
>
> I do not understand the point of this, why would
> swiotlb_tbl_map_single() force attrs over the caller which should
> already know the context (whether DMA is shared or not) which case
> would this be useful to force from the SWIOTLB code?
>

The mapping request was for private memory, but the device could not use
it because the dma_capable() (force_dma_unencrypted() == true) check
failed. As a result, dma_direct_map_phys() allocated a swiotlb bounce
buffer, which is shared. Since the DMA now targets the shared bounce
buffer rather than the original private memory, the attributes must be
updated to reflect the new shared mapping.

dma_addr = phys_to_dma(dev, phys);
if (unlikely(!dma_capable(dev, dma_addr, size, true)))
if (is_swiotlb_active(dev))
return swiotlb_map(dev, phys, size, dir, attrs);


-aneesh