From: "Christian König" <christian.koenig@amd.com>
To: Huan Yang <link@vivo.com>, Gerd Hoffmann <kraxel@redhat.com>,
Sumit Semwal <sumit.semwal@linaro.org>,
dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: Re: [PATCH 3/5] udmabuf: fix vmap_udmabuf error page set
Date: Thu, 1 Aug 2024 12:55:29 +0200 [thread overview]
Message-ID: <59df9815-577a-4449-b17f-72a6b78d373b@amd.com> (raw)
In-Reply-To: <20240801104512.4056860-4-link@vivo.com>
Am 01.08.24 um 12:45 schrieb Huan Yang:
> Currently vmap_udmabuf set page's array by each folio.
> But, ubuf->folios is only contain's the folio's head page.
>
> That mean we repeatedly mapped the folio head page to the vmalloc area.
>
> This patch fix it, set each folio's page correct, so that pages array
> contains right page, and then map into vmalloc area
>
> Signed-off-by: Huan Yang <link@vivo.com>
> ---
> drivers/dma-buf/udmabuf.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
> index a915714c5dce..7ed532342d7f 100644
> --- a/drivers/dma-buf/udmabuf.c
> +++ b/drivers/dma-buf/udmabuf.c
> @@ -77,18 +77,27 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
> static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
> {
> struct udmabuf *ubuf = buf->priv;
> - struct page **pages;
> + struct page **pages, **tmp;
> + struct sg_table *sg = ubuf->sg;
> + struct sg_page_iter piter;
> void *vaddr;
> - pgoff_t pg;
>
> dma_resv_assert_held(buf->resv);
>
> + if (!sg) {
> + sg = get_sg_table(NULL, buf, 0);
> + if (IS_ERR(sg))
> + return PTR_ERR(sg);
> + ubuf->sg = sg;
> + }
> +
> pages = kvmalloc_array(ubuf->pagecount, sizeof(*pages), GFP_KERNEL);
> if (!pages)
> return -ENOMEM;
> + tmp = pages;
>
> - for (pg = 0; pg < ubuf->pagecount; pg++)
> - pages[pg] = &ubuf->folios[pg]->page;
> + for_each_sgtable_page(sg, &piter, 0)
> + *tmp++ = sg_page_iter_page(&piter);
Again don't abuse the sg table for that!
Regards,
Christian.
>
> vaddr = vm_map_ram(pages, ubuf->pagecount, -1);
> kvfree(pages);
next prev parent reply other threads:[~2024-08-01 10:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 10:45 [PATCH 0/5] udmbuf bug fix and some improvements Huan Yang
2024-08-01 10:45 ` [PATCH 1/5] udmabuf: cancel mmap page fault, direct map it Huan Yang
2024-08-01 10:50 ` Christian König
2024-08-01 11:08 ` Huan Yang
2024-08-01 10:45 ` [PATCH 2/5] udmabuf: change folios array from kmalloc to kvmalloc Huan Yang
2024-08-01 10:54 ` Christian König
2024-08-01 10:45 ` [PATCH 3/5] udmabuf: fix vmap_udmabuf error page set Huan Yang
2024-08-01 10:55 ` Christian König [this message]
2024-08-01 10:45 ` [PATCH 4/5] udmabuf: add get_sg_table helper function Huan Yang
2024-08-01 10:56 ` Christian König
2024-08-01 10:45 ` [PATCH 5/5] udmabuf: remove folio pin list Huan Yang
2024-08-01 18:32 ` [PATCH 0/5] udmbuf bug fix and some improvements Kasireddy, Vivek
2024-08-02 1:16 ` Huan Yang
2024-08-02 15:26 ` Michel Dänzer
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=59df9815-577a-4449-b17f-72a6b78d373b@amd.com \
--to=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=link@vivo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=sumit.semwal@linaro.org \
/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
all inboxes | Powered by JetHome®