The patch titled Subject: media: omap_vout: convert omap_vout_uservirt_to_phys() to use get_vaddr_pfns() has been added to the -mm tree. Its filename is media-omap_vout-convert-omap_vout_uservirt_to_phys-to-use-get_vaddr_pfns.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/media-omap_vout-convert-omap_vout_uservirt_to_phys-to-use-get_vaddr_pfns.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/media-omap_vout-convert-omap_vout_uservirt_to_phys-to-use-get_vaddr_pfns.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jan Kara <jack@xxxxxxx> Subject: media: omap_vout: convert omap_vout_uservirt_to_phys() to use get_vaddr_pfns() Convert omap_vout_uservirt_to_phys() to use get_vaddr_pfns() instead of hand made mapping of virtual address to physical address. Also the function leaked page reference from get_user_pages() so fix that by properly release the reference when omap_vout_buffer_release() is called. [hans.verkuil@xxxxxxxxx: remove unused struct omap_vout_device *vout variable] Signed-off-by: Jan Kara <jack@xxxxxxx> Signed-off-by: Hans Verkuil <hans.verkuil@xxxxxxxxx> Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxx> Cc: "Prabhakar Lad" <prabhakar.csengg@xxxxxxxxx> Cc: David Airlie <airlied@xxxxxxxx> Cc: Fabian Frederick <fabf@xxxxxxxxx> Cc: Inki Dae <inki.dae@xxxxxxxxxxx> Cc: Joonyoung Shim <jy0922.shim@xxxxxxxxxxx> Cc: Kukjin Kim <kgene@xxxxxxxxxx> Cc: Kyungmin Park <kyungmin.park@xxxxxxxxxxx> Cc: Laurent Pinchart <laurent.pinchart+renesas@xxxxxxxxxxxxxxxx> Cc: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxx> Cc: Pawel Osciak <pawel@xxxxxxxxxx> Cc: Seung-Woo Kim <sw0312.kim@xxxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/media/platform/omap/omap_vout.c | 71 +++++++++------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff -puN drivers/media/platform/omap/omap_vout.c~media-omap_vout-convert-omap_vout_uservirt_to_phys-to-use-get_vaddr_pfns drivers/media/platform/omap/omap_vout.c --- a/drivers/media/platform/omap/omap_vout.c~media-omap_vout-convert-omap_vout_uservirt_to_phys-to-use-get_vaddr_pfns +++ a/drivers/media/platform/omap/omap_vout.c @@ -195,46 +195,34 @@ static int omap_vout_try_format(struct v } /* - * omap_vout_uservirt_to_phys: This inline function is used to convert user - * space virtual address to physical address. + * omap_vout_get_userptr: Convert user space virtual address to physical + * address. */ -static unsigned long omap_vout_uservirt_to_phys(unsigned long virtp) +static int omap_vout_get_userptr(struct videobuf_buffer *vb, u32 virtp, + u32 *physp) { - unsigned long physp = 0; - struct vm_area_struct *vma; - struct mm_struct *mm = current->mm; + struct frame_vector *vec; + int ret; /* For kernel direct-mapped memory, take the easy way */ - if (virtp >= PAGE_OFFSET) - return virt_to_phys((void *) virtp); + if (virtp >= PAGE_OFFSET) { + *physp = virt_to_phys((void *)virtp); + return 0; + } - down_read(¤t->mm->mmap_sem); - vma = find_vma(mm, virtp); - if (vma && (vma->vm_flags & VM_IO) && vma->vm_pgoff) { - /* this will catch, kernel-allocated, mmaped-to-usermode - addresses */ - physp = (vma->vm_pgoff << PAGE_SHIFT) + (virtp - vma->vm_start); - up_read(¤t->mm->mmap_sem); - } else { - /* otherwise, use get_user_pages() for general userland pages */ - int res, nr_pages = 1; - struct page *pages; - - res = get_user_pages(current, current->mm, virtp, nr_pages, 1, - 0, &pages, NULL); - up_read(¤t->mm->mmap_sem); - - if (res == nr_pages) { - physp = __pa(page_address(&pages[0]) + - (virtp & ~PAGE_MASK)); - } else { - printk(KERN_WARNING VOUT_NAME - "get_user_pages failed\n"); - return 0; - } + vec = frame_vector_create(1); + if (!vec) + return -ENOMEM; + + ret = get_vaddr_frames(virtp, 1, true, false, vec); + if (ret != 1) { + frame_vector_destroy(vec); + return -EINVAL; } + *physp = __pfn_to_phys(frame_vector_pfns(vec)[0]); + vb->priv = vec; - return physp; + return 0; } /* @@ -784,11 +772,15 @@ static int omap_vout_buffer_prepare(stru * address of the buffer */ if (V4L2_MEMORY_USERPTR == vb->memory) { + int ret; + if (0 == vb->baddr) return -EINVAL; /* Physical address */ - vout->queued_buf_addr[vb->i] = (u8 *) - omap_vout_uservirt_to_phys(vb->baddr); + ret = omap_vout_get_userptr(vb, vb->baddr, + (u32 *)&vout->queued_buf_addr[vb->i]); + if (ret < 0) + return ret; } else { unsigned long addr, dma_addr; unsigned long size; @@ -834,12 +826,13 @@ static void omap_vout_buffer_queue(struc static void omap_vout_buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) { - struct omap_vout_device *vout = q->priv_data; - vb->state = VIDEOBUF_NEEDS_INIT; + if (vb->memory == V4L2_MEMORY_USERPTR && vb->priv) { + struct frame_vector *vec = vb->priv; - if (V4L2_MEMORY_MMAP != vout->memory) - return; + put_vaddr_frames(vec); + frame_vector_destroy(vec); + } } /* _ Patches currently in -mm which might be from jack@xxxxxxx are revert-ufs-fix-deadlocks-introduced-by-sb-mutex-merge.patch ufs-restore-s_lock-mutex.patch fsnotify-remove-obsolete-documentation.patch fs-ext4-fsyncc-generic_file_fsync-call-based-on-barrier-flag.patch fs-mpagec-forgotten-write_sync-in-case-of-data-integrity-write.patch linux-next.patch mm-provide-new-get_vaddr_frames-helper.patch media-omap_vout-convert-omap_vout_uservirt_to_phys-to-use-get_vaddr_pfns.patch vb2-provide-helpers-for-mapping-virtual-addresses.patch media-vb2-convert-vb2_dma_sg_get_userptr-to-use-frame-vector.patch media-vb2-convert-vb2_vmalloc_get_userptr-to-use-frame-vector.patch media-vb2-convert-vb2_dc_get_userptr-to-use-frame-vector.patch media-vb2-remove-unused-functions.patch drm-exynos-convert-g2d_userptr_get_dma_addr-to-use-get_vaddr_frames.patch mm-move-get_vaddr_frames-behind-a-config-option.patch mm-add-strictlimit-knob-v2.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html