[PATCH] Video/UVC: Port mainlined uvc video driver to NOMMU - Kernel

This is a discussion on [PATCH] Video/UVC: Port mainlined uvc video driver to NOMMU - Kernel ; From: Michael Hennerich Add NOMMU mmap support. Signed-off-by: Michael Hennerich Signed-off-by: Bryan Wu --- drivers/media/video/uvc/uvc_v4l2.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c index 758dfef..2237f5e 100644 --- a/drivers/media/video/uvc/uvc_v4l2.c +++ b/drivers/media/video/uvc/uvc_v4l2.c @@ -1050,6 +1050,7 @@ ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: [PATCH] Video/UVC: Port mainlined uvc video driver to NOMMU

  1. [PATCH] Video/UVC: Port mainlined uvc video driver to NOMMU

    From: Michael Hennerich

    Add NOMMU mmap support.

    Signed-off-by: Michael Hennerich
    Signed-off-by: Bryan Wu
    ---
    drivers/media/video/uvc/uvc_v4l2.c | 14 ++++++++++++++
    1 files changed, 14 insertions(+), 0 deletions(-)

    diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
    index 758dfef..2237f5e 100644
    --- a/drivers/media/video/uvc/uvc_v4l2.c
    +++ b/drivers/media/video/uvc/uvc_v4l2.c
    @@ -1050,6 +1050,7 @@ static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
    break;
    }

    +#ifdef CONFIG_MMU
    if (i == video->queue.count || size != video->queue.buf_size) {
    ret = -EINVAL;
    goto done;
    @@ -1071,7 +1072,20 @@ static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
    addr += PAGE_SIZE;
    size -= PAGE_SIZE;
    }
    +#else
    + if (i == video->queue.count ||
    + PAGE_ALIGN(size) != video->queue.buf_size) {
    + ret = -EINVAL;
    + goto done;
    + }
    +
    + vma->vm_flags |= VM_IO | VM_MAYSHARE; /* documentation/nommu-mmap.txt */
    +
    + addr = (unsigned long)video->queue.mem + buffer->buf.m.offset;

    + vma->vm_start = addr;
    + vma->vm_end = addr + video->queue.buf_size;
    +#endif
    vma->vm_ops = &uvc_vm_ops;
    vma->vm_private_data = buffer;
    uvc_vm_open(vma);
    --
    1.5.6.3
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH] Video/UVC: Port mainlined uvc video driver to NOMMU

    Hi Bryan, Michael,

    On Thursday 06 November 2008, Bryan Wu wrote:
    > From: Michael Hennerich
    >
    > Add NOMMU mmap support.
    >
    > Signed-off-by: Michael Hennerich
    > Signed-off-by: Bryan Wu
    > ---
    > drivers/media/video/uvc/uvc_v4l2.c | 14 ++++++++++++++
    > 1 files changed, 14 insertions(+), 0 deletions(-)
    >
    > diff --git a/drivers/media/video/uvc/uvc_v4l2.c
    > b/drivers/media/video/uvc/uvc_v4l2.c index 758dfef..2237f5e 100644
    > --- a/drivers/media/video/uvc/uvc_v4l2.c
    > +++ b/drivers/media/video/uvc/uvc_v4l2.c
    > @@ -1050,6 +1050,7 @@ static int uvc_v4l2_mmap(struct file *file, struct
    > vm_area_struct *vma) break;
    > }
    >
    > +#ifdef CONFIG_MMU
    > if (i == video->queue.count || size != video->queue.buf_size) {
    > ret = -EINVAL;
    > goto done;
    > @@ -1071,7 +1072,20 @@ static int uvc_v4l2_mmap(struct file *file, struct
    > vm_area_struct *vma) addr += PAGE_SIZE;
    > size -= PAGE_SIZE;
    > }
    > +#else
    > + if (i == video->queue.count ||
    > + PAGE_ALIGN(size) != video->queue.buf_size) {


    Just out of curiosity, why do you need to PAGE_ALIGN size for non-MMU
    platforms ?

    > + ret = -EINVAL;
    > + goto done;
    > + }
    > +
    > + vma->vm_flags |= VM_IO | VM_MAYSHARE; /* documentation/nommu-mmap.txt */


    VM_MAYSHARE is not documented anywhere in Documentation/ in Linux 2.6.28-rc3.
    Why is it needed for non-MMU architectures only ?

    > +
    > + addr = (unsigned long)video->queue.mem + buffer->buf.m.offset;
    >
    > + vma->vm_start = addr;
    > + vma->vm_end = addr + video->queue.buf_size;
    > +#endif
    > vma->vm_ops = &uvc_vm_ops;
    > vma->vm_private_data = buffer;
    > uvc_vm_open(vma);


    Best regards,

    Laurent Pinchart
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. RE: [PATCH] Video/UVC: Port mainlined uvc video driver to NOMMU



    >-----Original Message-----
    >From: Laurent Pinchart [mailto:laurent.pinchart@skynet.be]
    >Sent: Sunday, November 09, 2008 10:22 PM
    >To: Bryan Wu
    >Cc: linux-uvc-devel@lists.berlios.de; video4linux-list@redhat.com;

    linux-
    >kernel@vger.kernel.org; Michael Hennerich
    >Subject: Re: [PATCH] Video/UVC: Port mainlined uvc video driver to

    NOMMU
    >
    >Hi Bryan, Michael,
    >
    >On Thursday 06 November 2008, Bryan Wu wrote:
    >> From: Michael Hennerich
    >>
    >> Add NOMMU mmap support.
    >>
    >> Signed-off-by: Michael Hennerich
    >> Signed-off-by: Bryan Wu
    >> ---
    >> drivers/media/video/uvc/uvc_v4l2.c | 14 ++++++++++++++
    >> 1 files changed, 14 insertions(+), 0 deletions(-)
    >>
    >> diff --git a/drivers/media/video/uvc/uvc_v4l2.c
    >> b/drivers/media/video/uvc/uvc_v4l2.c index 758dfef..2237f5e 100644
    >> --- a/drivers/media/video/uvc/uvc_v4l2.c
    >> +++ b/drivers/media/video/uvc/uvc_v4l2.c
    >> @@ -1050,6 +1050,7 @@ static int uvc_v4l2_mmap(struct file *file,

    struct
    >> vm_area_struct *vma) break;
    >> }
    >>
    >> +#ifdef CONFIG_MMU
    >> if (i == video->queue.count || size != video->queue.buf_size) {
    >> ret = -EINVAL;
    >> goto done;
    >> @@ -1071,7 +1072,20 @@ static int uvc_v4l2_mmap(struct file *file,

    struct
    >> vm_area_struct *vma) addr += PAGE_SIZE;
    >> size -= PAGE_SIZE;
    >> }
    >> +#else
    >> + if (i == video->queue.count ||
    >> + PAGE_ALIGN(size) != video->queue.buf_size) {

    >
    >Just out of curiosity, why do you need to PAGE_ALIGN size for non-MMU
    >platforms ?


    Size and video->queue.buf_size is not the 100% same size (off by a few
    bytes < pagesize), I think it's because on NOMMU the kernel calls
    kmalloc() to allocate the buffer, not get_free_page().


    >
    >> + ret = -EINVAL;
    >> + goto done;
    >> + }
    >> +
    >> + vma->vm_flags |= VM_IO | VM_MAYSHARE; /*

    documentation/nommu-mmap.txt
    >*/
    >
    >VM_MAYSHARE is not documented anywhere in Documentation/ in Linux

    2.6.28-
    >rc3.
    >Why is it needed for non-MMU architectures only ?


    mmap on NOMMU is a bit tricky and very restricted.
    In case user does a MAP_SHARED with some combination of the PROT_###
    Flags the mmap fails. What's allowed and what's not is documented in
    documentation/nommu-mmap.txt
    Setting VM_MAYSHARE allows user MAP_PRIVATE mappings.

    -Michael

    >
    >> +
    >> + addr = (unsigned long)video->queue.mem + buffer->buf.m.offset;
    >>
    >> + vma->vm_start = addr;
    >> + vma->vm_end = addr + video->queue.buf_size;
    >> +#endif
    >> vma->vm_ops = &uvc_vm_ops;
    >> vma->vm_private_data = buffer;
    >> uvc_vm_open(vma);

    >
    >Best regards,
    >
    >Laurent Pinchart

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread