From: Huan Yang <link@vivo.com>
To: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "opensource.kernel@vivo.com" <opensource.kernel@vivo.com>
Subject: Re: [PATCH v6 3/7] udmabuf: fix vmap_udmabuf error page set
Date: Fri, 13 Sep 2024 14:31:36 +0800 [thread overview]
Message-ID: <37e1f8a7-aa94-4a2b-9cd0-cb788a4f0b01@vivo.com> (raw)
In-Reply-To: <IA0PR11MB718549B45FCA4C85C1C99CA4F8642@IA0PR11MB7185.namprd11.prod.outlook.com>
在 2024/9/13 6:37, Kasireddy, Vivek 写道:
> Hi Huan,
>
>> Subject: [PATCH v6 3/7] udmabuf: fix vmap_udmabuf error page set
>>
>> 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.
>>
>> Due to udmabuf can use hugetlb, if HVO enabled, tail page may not exist,
>> so, we can't use page array to map, instead, use pfn array.
>>
>> By this, we removed page usage in udmabuf totally.
>>
> I think this would probably need a Fixes tag:
> Fixes: 5e72b2b41a21 ("udmabuf: convert udmabuf driver to use folios")
OK, I'll update it
>
> Thanks,
> Vivek
>
>> Suggested-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
>> Signed-off-by: Huan Yang <link@vivo.com>
>> Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
>> ---
>> drivers/dma-buf/Kconfig | 1 +
>> drivers/dma-buf/udmabuf.c | 22 +++++++++++++++-------
>> 2 files changed, 16 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig
>> index b46eb8a552d7..fee04fdb0822 100644
>> --- a/drivers/dma-buf/Kconfig
>> +++ b/drivers/dma-buf/Kconfig
>> @@ -36,6 +36,7 @@ config UDMABUF
>> depends on DMA_SHARED_BUFFER
>> depends on MEMFD_CREATE || COMPILE_TEST
>> depends on MMU
>> + select VMAP_PFN
>> help
>> A driver to let userspace turn memfd regions into dma-bufs.
>> Qemu can use this to create host dmabufs for guest framebuffers.
>> diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
>> index ba9dbc7caf71..aa182a9dcdfa 100644
>> --- a/drivers/dma-buf/udmabuf.c
>> +++ b/drivers/dma-buf/udmabuf.c
>> @@ -103,21 +103,29 @@ 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;
>> + unsigned long *pfns;
>> void *vaddr;
>> pgoff_t pg;
>>
>> dma_resv_assert_held(buf->resv);
>>
>> - pages = kvmalloc_array(ubuf->pagecount, sizeof(*pages),
>> GFP_KERNEL);
>> - if (!pages)
>> + /**
>> + * HVO may free tail pages, so just use pfn to map each folio
>> + * into vmalloc area.
>> + */
>> + pfns = kvmalloc_array(ubuf->pagecount, sizeof(*pfns), GFP_KERNEL);
>> + if (!pfns)
>> return -ENOMEM;
>>
>> - for (pg = 0; pg < ubuf->pagecount; pg++)
>> - pages[pg] = &ubuf->folios[pg]->page;
>> + for (pg = 0; pg < ubuf->pagecount; pg++) {
>> + unsigned long pfn = folio_pfn(ubuf->folios[pg]);
>>
>> - vaddr = vm_map_ram(pages, ubuf->pagecount, -1);
>> - kvfree(pages);
>> + pfn += ubuf->offsets[pg] >> PAGE_SHIFT;
>> + pfns[pg] = pfn;
>> + }
>> +
>> + vaddr = vmap_pfn(pfns, ubuf->pagecount, PAGE_KERNEL);
>> + kvfree(pfns);
>> if (!vaddr)
>> return -EINVAL;
>>
>> --
>> 2.45.2
next prev parent reply other threads:[~2024-09-13 6:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 9:18 [PATCH v6 0/7] udmabuf bug fix and some improvements Huan Yang
2024-09-09 9:18 ` [PATCH v6 1/7] udmabuf: pre-fault when first page fault Huan Yang
2024-09-09 9:18 ` [PATCH v6 2/7] udmabuf: change folios array from kmalloc to kvmalloc Huan Yang
2024-09-09 9:18 ` [PATCH v6 3/7] udmabuf: fix vmap_udmabuf error page set Huan Yang
2024-09-12 22:37 ` Kasireddy, Vivek
2024-09-13 6:31 ` Huan Yang [this message]
2024-09-09 9:18 ` [PATCH v6 4/7] udmabuf: udmabuf_create pin folio codestyle cleanup Huan Yang
2024-09-12 22:43 ` Kasireddy, Vivek
2024-09-13 6:33 ` Huan Yang
2024-09-09 9:18 ` [PATCH v6 5/7] udmabuf: introduce udmabuf init and deinit helper Huan Yang
2024-09-09 9:18 ` [PATCH v6 6/7] udmabuf: remove udmabuf_folio Huan Yang
2024-09-12 22:50 ` Kasireddy, Vivek
2024-09-09 9:18 ` [PATCH v6 7/7] udmabuf: reuse folio array when pin folios Huan Yang
2024-09-12 23:09 ` Kasireddy, Vivek
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=37e1f8a7-aa94-4a2b-9cd0-cb788a4f0b01@vivo.com \
--to=link@vivo.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=sumit.semwal@linaro.org \
--cc=vivek.kasireddy@intel.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
all inboxes | Powered by JetHome®