From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Subash Patel <subashrp@gmail.com>
Cc: Tomasz Stanislawski <t.stanislaws@samsung.com>,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
airlied@redhat.com, m.szyprowski@samsung.com,
kyungmin.park@samsung.com, sumit.semwal@ti.com,
daeinki@gmail.com, daniel.vetter@ffwll.ch, robdclark@gmail.com,
pawel@osciak.com, linaro-mm-sig@lists.linaro.org,
hverkuil@xs4all.nl, remi@remlab.net, mchehab@redhat.com,
linux-doc@vger.kernel.org, g.liakhovetski@gmx.de,
Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
Kamil Debski <k.debski@samsung.com>
Subject: Re: [PATCHv5 08/13] v4l: vb2-dma-contig: add support for scatterlist in userptr mode
Date: Tue, 08 May 2012 11:14:44 +0200 [thread overview]
Message-ID: <4675433.ieio0xx0Y0@avalon> (raw)
In-Reply-To: <4FA7DE61.7000705@gmail.com>
Hi Subash,
On Monday 07 May 2012 20:08:25 Subash Patel wrote:
> Hello Thomasz, Laurent,
>
> I found an issue in the function vb2_dc_pages_to_sgt() below. I saw that
> during the attach, the size of the SGT and size requested mis-matched
> (by atleast 8k bytes). Hence I made a small correction to the code as
> below. I could then attach the importer properly.
Thank you for the report.
Could you print the content of the sglist (number of chunks and size of each
chunk) before and after your modifications, as well as the values of n_pages,
offset and size ?
> On 04/20/2012 08:15 PM, Tomasz Stanislawski wrote:
[snip]
> > +static struct sg_table *vb2_dc_pages_to_sgt(struct page **pages,
> > + unsigned int n_pages, unsigned long offset, unsigned long size)
> > +{
> > + struct sg_table *sgt;
> > + unsigned int chunks;
> > + unsigned int i;
> > + unsigned int cur_page;
> > + int ret;
> > + struct scatterlist *s;
> > +
> > + sgt = kzalloc(sizeof *sgt, GFP_KERNEL);
> > + if (!sgt)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + /* compute number of chunks */
> > + chunks = 1;
> > + for (i = 1; i< n_pages; ++i)
> > + if (pages[i] != pages[i - 1] + 1)
> > + ++chunks;
> > +
> > + ret = sg_alloc_table(sgt, chunks, GFP_KERNEL);
> > + if (ret) {
> > + kfree(sgt);
> > + return ERR_PTR(-ENOMEM);
> > + }
> > +
> > + /* merging chunks and putting them into the scatterlist */
> > + cur_page = 0;
> > + for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
> > + unsigned long chunk_size;
> > + unsigned int j;
>
> size = PAGE_SIZE;
>
> > +
> > + for (j = cur_page + 1; j< n_pages; ++j)
>
> for (j = cur_page + 1; j < n_pages; ++j) {
>
> > + if (pages[j] != pages[j - 1] + 1)
> > + break;
>
> size += PAGE
> }
>
> > +
> > + chunk_size = ((j - cur_page)<< PAGE_SHIFT) - offset;
> > + sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);
>
> [DELETE] size -= chunk_size;
>
> > + offset = 0;
> > + cur_page = j;
> > + }
> > +
> > + return sgt;
> > +}
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2012-05-08 9:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-20 14:45 [PATCHv5 00/13] Integration of videobuf2 with dmabuf Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 01/13] v4l: Add DMABUF as a memory type Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 02/13] Documentation: media: description of DMABUF importing in V4L2 Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 03/13] v4l: vb2: add support for shared buffer (dma_buf) Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 04/13] v4l: vb: remove warnings about MEMORY_DMABUF Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 05/13] v4l: vb2-dma-contig: Shorten vb2_dma_contig prefix to vb2_dc Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 06/13] v4l: vb2-dma-contig: Remove unneeded allocation context structure Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 07/13] v4l: vb2-dma-contig: Reorder functions Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 08/13] v4l: vb2-dma-contig: add support for scatterlist in userptr mode Tomasz Stanislawski
2012-04-21 17:24 ` Laurent Pinchart
2012-05-07 14:38 ` Subash Patel
2012-05-07 15:11 ` Tomasz Stanislawski
2012-05-08 5:41 ` Subash Patel
2012-05-08 9:14 ` Laurent Pinchart [this message]
2012-05-08 11:15 ` Subash Patel
2012-05-09 6:46 ` Subash Patel
2012-05-09 9:58 ` Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 09/13] v4l: vb2: add prepare/finish callbacks to allocators Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 10/13] v4l: vb2-dma-contig: add prepare/finish to dma-contig allocator Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 11/13] v4l: vb2-dma-contig: add support for dma_buf importing Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 12/13] v4l: s5p-tv: mixer: support for dmabuf importing Tomasz Stanislawski
2012-04-20 14:45 ` [PATCHv5 13/13] v4l: s5p-fimc: " Tomasz Stanislawski
2012-04-21 15:59 ` [PATCHv5 00/13] Integration of videobuf2 with dmabuf Rob Landley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4675433.ieio0xx0Y0@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=airlied@redhat.com \
--cc=andrzej.p@samsung.com \
--cc=daeinki@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=g.liakhovetski@gmx.de \
--cc=hverkuil@xs4all.nl \
--cc=k.debski@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@redhat.com \
--cc=pawel@osciak.com \
--cc=remi@remlab.net \
--cc=robdclark@gmail.com \
--cc=subashrp@gmail.com \
--cc=sumit.semwal@ti.com \
--cc=t.stanislaws@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).