@@ -152,29 +152,28 @@ static void *udmabuf_vmap_pfn(unsigned long *pfns, unsigned int count,
static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
{
struct udmabuf *ubuf = buf->priv;
- unsigned long *pfns;
+ struct vmap_folios_struct folios;
+ struct vmap_folios_range *ranges;
void *vaddr;
pgoff_t pg;
dma_resv_assert_held(buf->resv);
- /**
- * 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)
+ ranges = kvmalloc_array(ubuf->pagecount, sizeof(*ranges), GFP_KERNEL);
+ if (!ranges)
return -ENOMEM;
for (pg = 0; pg < ubuf->pagecount; pg++) {
- unsigned long pfn = folio_pfn(ubuf->folios[pg]);
-
- pfn += ubuf->offsets[pg] >> PAGE_SHIFT;
- pfns[pg] = pfn;
+ ranges[pg].folio = ubuf->folios[pg];
+ ranges[pg].pgoff = ubuf->offsets[pg] >> PAGE_SHIFT;
+ ranges[pg].nr_pages = 1;
}
- vaddr = udmabuf_vmap_pfn(pfns, ubuf->pagecount, PAGE_KERNEL);
- kvfree(pfns);
+ folios._range_folios = ranges;
+ folios.range = true;
+
+ vaddr = vmap_range_folios(&folios, ubuf->pagecount, 0, PAGE_KERNEL);
+ kvfree(ranges);
if (!vaddr)
return -EINVAL;
This patch change udmabuf from use pfn based into folio based vmap. Signed-off-by: Huan Yang <link@vivo.com> --- drivers/dma-buf/udmabuf.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)