Re: [PATCH] RDMA/irdma: Use dma_alloc_coherent() instead of kmalloc/dma_map_single()

From: Jason Gunthorpe
Date: Mon Sep 27 2021 - 08:02:40 EST


On Sun, Sep 26, 2021 at 02:11:23PM +0800, Cai Huoqing wrote:
> Replacing kmalloc/kfree/dma_map_single/dma_unmap_single()
> with dma_alloc_coherent/dma_free_coherent() helps to reduce
> code size, and simplify the code, and coherent DMA will not
> clear the cache every time.
>
> Signed-off-by: Cai Huoqing <caihuoqing@xxxxxxxxx>
> ---
> drivers/infiniband/hw/irdma/puda.c | 19 ++++---------------
> 1 file changed, 4 insertions(+), 15 deletions(-)

This I'm not sure about, I see lots of calls to dma_sync_single_* for
this memory and it is not unconditionally true that using coherent
memory is better than doing the cache flushes. It depends very much
on the access pattern.

At the very least if you convert to coherent memory I expect to see
the sync's removed too..

Jason