Hello Mathias Memory managing is definately not my topic. I have done the same as in vb2-dmacontig, and it has worked on my driver (out of tree).
I think that if there is something wrong it will also be wrong on the dmacontig part, and much more drivers would be affected, so please also take a look to videobuf2-dma-contig.c and check if there is something wrong there. Best Regards! On Mon, Nov 11, 2013 at 12:36 PM, Matthias Wächter <matthias.waech...@tttech.com> wrote: >> @@ -180,7 +186,26 @@ static void *vb2_dma_sg_get_userptr(void >> *alloc_ctx, unsigned long vaddr, >> if (!buf->pages) >> return NULL; >> >> - num_pages_from_user = get_user_pages(current, current->mm, >> + buf->vma = find_vma(current->mm, vaddr); >> + if (!buf->vma) { >> + dprintk(1, "no vma for address %lu\n", vaddr); >> + return NULL; >> + } >> + >> + if (vma_is_io(buf->vma)) { >> + for (num_pages_from_user = 0; >> + num_pages_from_user < buf->num_pages; >> + ++num_pages_from_user, vaddr += PAGE_SIZE) { >> + unsigned long pfn; >> + >> + if (follow_pfn(buf->vma, vaddr, &pfn)) { >> + dprintk(1, "no page for address %lu\n", vaddr); >> + break; >> + } >> + buf->pages[num_pages_from_user] = pfn_to_page(pfn); >> + } >> + } else >> + num_pages_from_user = get_user_pages(current, current->mm, >> vaddr & PAGE_MASK, >> buf->num_pages, >> write, > > Can you safely assume that your userptr will cover only one vma? At least, > get_user_pages (calling __get_user_pages) does not assume that and calls > find_vma() whenever vma->vm_end is reached. > > – Matthias > > CONFIDENTIALITY: The contents of this e-mail are confidential and intended > only for the above addressee(s). If you are not the intended recipient, or > the person responsible for delivering it to the intended recipient, copying > or delivering it to anyone else or using it in any unauthorized manner is > prohibited and may be unlawful. If you receive this e-mail by mistake, please > notify the sender and the systems administrator at straym...@tttech.com > immediately. -- Ricardo Ribalda -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html