2023-09-12 09:54:20

by Hui Fang

[permalink] [raw]
Subject: RE: [EXT] Re: [PATCH] media: videobuf2-dma-sg: limit the sg segment size

On Tue, Sep 12 2023 at 11:22 AM Tomasz Figa <[email protected]>
> On Mon, Sep 11, 2023 at 3:13 PM Hui Fang <[email protected]> wrote:
> >
> > On Wed, Sep 6, 2023 at 18:28 PM Tomasz Figa <[email protected]>
> wrote:
> > > That all makes sense, but it still doesn't answer the real question
> > > on why swiotlb ends up being used. I think you may want to trace
> > > what happens in the DMA mapping ops implementation on your system
> > > causing it to use swiotlb.
> >
> > Add log and feed invalid data to low buffer on purpose, it's confirmed
> > that swiotlb is actually used.
> >
>
> Yes, that we already know. But why?


The physical address of v4l2 buffer is large than 4G (5504139264), so the swiotlb is used.
"[ 846.570271][ T138] software IO TLB: ==== swiotlb_bounce: DMA_TO_DEVICE,
dst 000000004589fa38, src 00000000c6d7e8d8, srcPhy 5504139264, size 4096".

BRs,
Fang Hui


2023-09-13 05:12:22

by Tomasz Figa

[permalink] [raw]
Subject: Re: [EXT] Re: [PATCH] media: videobuf2-dma-sg: limit the sg segment size

On Tue, Sep 12, 2023 at 4:01 PM Hui Fang <[email protected]> wrote:
>
> On Tue, Sep 12 2023 at 11:22 AM Tomasz Figa <[email protected]>
> > On Mon, Sep 11, 2023 at 3:13 PM Hui Fang <[email protected]> wrote:
> > >
> > > On Wed, Sep 6, 2023 at 18:28 PM Tomasz Figa <[email protected]>
> > wrote:
> > > > That all makes sense, but it still doesn't answer the real question
> > > > on why swiotlb ends up being used. I think you may want to trace
> > > > what happens in the DMA mapping ops implementation on your system
> > > > causing it to use swiotlb.
> > >
> > > Add log and feed invalid data to low buffer on purpose, it's confirmed
> > > that swiotlb is actually used.
> > >
> >
> > Yes, that we already know. But why?
>
>
> The physical address of v4l2 buffer is large than 4G (5504139264), so the swiotlb is used.
> "[ 846.570271][ T138] software IO TLB: ==== swiotlb_bounce: DMA_TO_DEVICE,
> dst 000000004589fa38, src 00000000c6d7e8d8, srcPhy 5504139264, size 4096".

Is your DMA device restricted only to the bottom-most 4 GB (32-bit DMA
address)? If yes, would it make sense to also allocate from that area
rather than bouncing the memory?

Best regards,
Tomasz