Re: [PATCH] staging: ion: Rework ion_map_dma_buf() to minimize re-mapping
From: John Stultz
Date: Mon Oct 15 2018 - 12:31:38 EST
On Sat, Oct 13, 2018 at 11:01 PM, Liam Mark <lmark@xxxxxxxxxxxxxx> wrote:
> On Fri, 12 Oct 2018, Laura Abbott wrote:
>> I thought there might have been some Qualcomm
>> stuff that did that (Liam? Todd?)
>
> Yes we have a form of "lazy mapping", which clients can opt into using,
> which results in iommu page table mapping not being unmaped on dma-unamp.
> Instead they are unmapped when the buffer is destroyed.
>
> It is important to note that in our "lazy mapping" implementation cache
> maintenance is still applied on dma-map and dma-unmap.
> If you need a full description of this feature I can provide it.
>
>>
>> I suspect most of the cost of the dma_map/dma_unmap is from the
>> cache flushing and not the actual mapping operations. If this
>> is the case, another option might be to figure out how to
>> incorporate dma_attrs so drivers can use DMA_ATTR_SKIP_CPU_SYNC
>> to decide when they actually want to sync.
>
> We have support for this locally on our 4.14 branch.
>
> We have added a dma_map_attrs field to the dma_buf_attachment struct,
> clients can then specify dma-attributes here such as
> DMA_ATTR_SKIP_CPU_SYNC before dma-mapping the buffer, then we ensure that
> these dma attributes are passed to dma_map_sg_attrs when ion_map_dma_buf
> is called (same for ion_unmap_dma_buf).
Do you happen to have a pointer to the tree if its public?
thanks
-john