RE: [PATCH] MA-21654 Use dma_alloc_pages in vb2_dma_sg_alloc_compacted

From: Hui Fang
Date: Thu Sep 14 2023 - 03:52:08 EST


On Thu, Sep 14, 2023 at 15:41 PM Fang Hui <hui.fang@xxxxxxx> wrote:
> On system with "CONFIG_ZONE_DMA32=y", if the allocated physical address is
> greater than 4G, swiotlb will be used. It will lead below defects.
> 1) Impact performance due to an extra memcpy.
> 2) May meet below error due to swiotlb_max_mapping_size()
> is 256K (IO_TLB_SIZE * IO_TLB_SEGSIZE).
> "swiotlb buffer is full (sz: 393216 bytes), total 65536 (slots), used 2358 (slots)"
>
> To avoid those defects, use dma_alloc_pages() instead of alloc_pages() in
> vb2_dma_sg_alloc_compacted().
>
> Suggested-by: Tomasz Figa <tfiga@xxxxxxxxxxxx>
> Signed-off-by: Fang Hui <hui.fang@xxxxxxx>
---
Two things.
1. For dma_data_direction para (DMA_BIDIRECTIONAL is used) of dma_alloc_pages(),
maybe better pass from callers? In DeviceAsWebcam case, it's DMA_TO_DEVICE.

2. "MA-21654" (NXP ticket number) should be removed in the comment, need I
re-push or it will be done on your side, thanks!

BRs,
Fang Hui