2023-09-14 08:52:56

by Hui Fang

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

On Thu, Sep 14, 2023 at 15:41 PM Fang Hui <[email protected]> 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 <[email protected]>
> Signed-off-by: Fang Hui <[email protected]>
---
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


2023-09-18 02:21:12

by Hui Fang

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

On Thu, Sep 14, 2023 at 15:52 PM Fang Hui <[email protected]> wrote:
> 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!

Keep google friends in the loop.

BRs,
Fang Hui

2023-09-18 15:13:07

by Hui Fang

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

> On Thu, Sep 14, 2023 at 15:52 PM Fang Hui <[email protected]> wrote:
> ---
> 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!

Another concern is that DMA memory is used up. Maybe first try allocating
low buffer, if failed, fall back to high buffer.

BRs,
Fang Hui