On Tue, Sep 6, 2022 at 8:59 PM Jason Gunthorpe jgg@nvidia.com wrote:
On Tue, Sep 06, 2022 at 03:34:02PM +0300, Oded Gabbay wrote:
- /*
- Since the memory being mapped is a device memory it could never be in
- CPU caches.
- */
DMA_ATTR_SKIP_CPU_SYNC doesn't even apply to dma_map_resource, not sure where this wisdom comes from.
Habana driver
I hate to throw the ball at someone else, but I actually copied the code from the amdgpu driver, from amdgpu_vram_mgr_alloc_sgt() iirc. And if you remember Jason, you asked why we use this specific define in the original review you did and I replied the following (to which you agreed and that's why we added the comment):
Yes, I remember, but Christophs remark is that DMA_ATTR_SKIP_CPU_SYNC doesn't even do anything when passed to dma_map_resource().
The only attr that seems to be used is DMA_ATTR_PRIVILEGED from what I can see.
Jason
Yes, it appears he is correct. Probably what happened is that either this was originally copied from a use of dma_map_page or something similar that does check this attribute, or maybe dma_map_resource used it in the past and the underlying code has changed.
Regardless, it seems we can remove it from the calls to dma_map_resource. I went over the kernel code and it seems only habana and amdgpu (and amdkfd) are passing this property to dma_map_resource. All other callers just pass 0.
Oded