[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YP41zzARXEXESEXE@google.com>
Date: Mon, 26 Jul 2021 13:10:55 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Tomasz Figa <tfiga@...omium.org>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Dafna Hirschfeld <dafna.hirschfeld@...labora.com>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Ricardo Ribalda <ribalda@...omium.org>,
Christoph Hellwig <hch@....de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Collabora Kernel ML <kernel@...labora.com>
Subject: Re: [PATCHv3 8/8] videobuf2: handle non-contiguous DMA allocations
On (21/07/26 13:04), Tomasz Figa wrote:
> On Mon, Jul 26, 2021 at 12:59 PM Sergey Senozhatsky
> <senozhatsky@...omium.org> wrote:
> >
> > On (21/07/22 19:26), Dafna Hirschfeld wrote:
> > > Also, the 'cookie' cb returns buf->dma_addr which is not initialized for
> > > the noncontiguous api. So it is not clear how drivers should use the new api.
> > > Many drivers call vb2_dma_contig_plane_dma_addr which returns the cookie.
> >
> > Hmm, that's a good find. Is ->dma_addr the same as what we have in
> > sgt.sgl->dma_address for non-contig?
>
> Yes. As per [1]:
>
> "The return sg_table is guaranteed to have 1 single DMA mapped segment
> as indicated by sgt->nents, but it might have multiple CPU side
> segments as indicated by sgt->orig_nents."
Thanks. So the fix can look as follows:
---
static int vb2_dc_alloc_non_coherent(struct vb2_dc_buf *buf)
{
struct vb2_queue *q = buf->vb->vb2_queue;
buf->dma_sgt = dma_alloc_noncontiguous(buf->dev,
buf->size,
buf->dma_dir,
GFP_KERNEL | q->gfp_flags,
buf->attrs);
if (!buf->dma_sgt)
return -ENOMEM;
+ buf->dma_addr = sg_dma_address(buf->dma_sgt->sgl);
---
Powered by blists - more mailing lists