[patch 00/18] remove nopage - Kernel

This is a discussion on [patch 00/18] remove nopage - Kernel ; On Wed, Dec 05, 2007 at 02:15:35PM +0100, Stefan Richter wrote: > > npiggin@suse.de wrote: > >> @@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *d > >> if (!dma->kvirt) > >> return -EINVAL; > >> > >> - /* must ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 21 to 34 of 34

Thread: [patch 00/18] remove nopage

  1. Re: [patch 06/18] ieee1394: nopage

    On Wed, Dec 05, 2007 at 02:15:35PM +0100, Stefan Richter wrote:
    > > npiggin@suse.de wrote:
    > >> @@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *d
    > >> if (!dma->kvirt)
    > >> return -EINVAL;
    > >>
    > >> - /* must be page-aligned */
    > >> + /* must be page-aligned (XXX: comment is wrong, we could allow pgoff) */
    > >> if (vma->vm_pgoff != 0)
    > >> return -EINVAL;
    > >>

    > >
    > > Are you sure that the comment is wrong? Could it be that there are
    > > assumptions elsewhere which require page alignment? (I should be able
    > > to answer that, but I'm not.)

    >
    > PS: Assumed the comment is wrong, is the code wrong then too?


    The mmap / fault code _seems_ OK. The check here is only wrong in that it
    doesn't prevent non-page-aligned mappings (the core VM code already does).
    --
    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 06/18] ieee1394: nopage

    On Wed, Dec 05, 2007 at 02:09:48PM +0100, Stefan Richter wrote:
    > npiggin@suse.de wrote:
    > > Convert ieee1394 from nopage to fault.
    > > Remove redundant vma range checks (correct resource range check is retained).

    >
    > I never really looked into that part of the 1394 drivers and I'm too
    > lazy to figure this out myself, so I ask: What would trip the .fault
    > handler? Would be good if I could runtime-test it.


    mmap()ing a device file for that driver, and accessing the memory.


    > > Signed-off-by: Nick Piggin
    > > Cc: krh@redhat.com

    >
    > It's an obscure and unimportant detail but I mention it nevertheless:
    > It's not necessary to Cc krh on drivers/ieee1394 stuff. He is more into
    > drivers/firewire. :-)


    OK, I'll try to keep it straight

    > > + if (vmf->pgoff >= dma->n_pages)
    > > + goto error;
    > > +
    > > + kernel_virt_addr = (unsigned long)dma->kvirt + (vmf->pgoff << PAGE_SHIFT);
    > > + vmf->page = vmalloc_to_page((void *)kernel_virt_addr);
    > > + get_page(vmf->page);
    > > + return 0;
    > > +
    > > + error:
    > > + return VM_FAULT_SIGBUS;
    > > }

    >
    > Why not replacing the two 'goto error' by 'return VM_FAULT_SIGBUS'? If
    > there is no cleanup after that error jump, I find it sensible to return
    > early.


    Fair enough, I just didn't want to gamut of reactions from maintainers
    to my cleanups


    > > static struct vm_operations_struct dma_region_vm_ops = {
    > > - .nopage = dma_region_pagefault,
    > > + .fault = dma_region_pagefault,
    > > };
    > >
    > > /**
    > > @@ -275,7 +270,7 @@ int dma_region_mmap(struct dma_region *d
    > > if (!dma->kvirt)
    > > return -EINVAL;
    > >
    > > - /* must be page-aligned */
    > > + /* must be page-aligned (XXX: comment is wrong, we could allow pgoff) */
    > > if (vma->vm_pgoff != 0)
    > > return -EINVAL;
    > >

    >
    > Are you sure that the comment is wrong? Could it be that there are
    > assumptions elsewhere which require page alignment? (I should be able
    > to answer that, but I'm not.)


    The file offset given to mmap must be page size multiple, and thus vm_pgoff
    is in units of page size (see the fault handler, where it gets shifted).
    Removing this restriction would allow the use of offset in mmap(), but if
    you want to disallow it for other reasons, then I guess the comment
    should be changed to explain why.

    --
    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 12/18] usb: mon nopage

    On Wed, Dec 05, 2007 at 08:39:25AM -0800, Pete Zaitcev wrote:
    > On Wed, 05 Dec 2007 18:15:59 +1100, npiggin@suse.de wrote:
    >
    > > Convert USB mon driver from nopage to fault.

    >
    > > if (offset >= rp->b_size)
    > > - return NOPAGE_SIGBUS;
    > > + return VM_FAULT_SIGBUS;
    > > chunk_idx = offset / CHUNK_SIZE;
    > > pageptr = rp->b_vec[chunk_idx].pg;
    > > get_page(pageptr);
    > > - if (type)
    > > - *type = VM_FAULT_MINOR;
    > > - return pageptr;
    > > + vmf->page = pageptr;
    > > + return 0;

    >
    > Looks like a trivial change, I ack this. It's a rarely used API, I have
    > to run tests to see how it works. I'll collect any failing pieces later
    > if any.


    That would be great, thanks.


    > Signed-off-by: Pete Zaitcev
    >
    > -- Pete

    --
    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/

  4. Re: [patch 07/18] v4l: nopage

    On Wed, 05 Dec 2007 18:15:54 +1100
    npiggin@suse.de wrote:

    > +static int
    > +videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > {
    > struct page *page;
    >
    > - dprintk(3,"nopage: fault @ %08lx [vma %08lx-%08lx]\n",
    > - vaddr,vma->vm_start,vma->vm_end);
    > - if (vaddr > vma->vm_end)
    > - return NOPAGE_SIGBUS;
    > + dprintk(3,"fault: fault @ %08lx [vma %08lx-%08lx]\n",
    > + (unsigned long)vmf->virtual_address,vma->vm_start,vma->vm_end);
    > page = alloc_page(GFP_USER | __GFP_DMA32);
    > if (!page)
    > - return NOPAGE_OOM;
    > + return VM_FAULT_OOM;
    > clear_user_page(page_address(page), vaddr, page);


    This didn't compile on sparc64 because `vaddr' is undefined.


    Let us see why:

    #define clear_user_page(page, vaddr, pg) clear_page(page)
    #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)

    #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
    alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)

    root cause: lack of argument checking on x86 due to stupid macros.


    Could someone *please* start a little project of extirpating this utter
    brain damage? Convert those macros to typechecked static inlines on x86
    (at least) so this sort of thing (which happens again and again and again)
    is lessened?


    macros are such miserable things. I wonder if we could get checkpatch to
    help out here?
    --
    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/

  5. Re: [patch 07/18] v4l: nopage


    * Andrew Morton wrote:

    > On Wed, 05 Dec 2007 18:15:54 +1100
    > npiggin@suse.de wrote:
    >
    > > +static int
    > > +videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > > {
    > > struct page *page;
    > >
    > > - dprintk(3,"nopage: fault @ %08lx [vma %08lx-%08lx]\n",
    > > - vaddr,vma->vm_start,vma->vm_end);
    > > - if (vaddr > vma->vm_end)
    > > - return NOPAGE_SIGBUS;
    > > + dprintk(3,"fault: fault @ %08lx [vma %08lx-%08lx]\n",
    > > + (unsigned long)vmf->virtual_address,vma->vm_start,vma->vm_end);
    > > page = alloc_page(GFP_USER | __GFP_DMA32);
    > > if (!page)
    > > - return NOPAGE_OOM;
    > > + return VM_FAULT_OOM;
    > > clear_user_page(page_address(page), vaddr, page);

    >
    > This didn't compile on sparc64 because `vaddr' is undefined.
    >
    >
    > Let us see why:
    >
    > #define clear_user_page(page, vaddr, pg) clear_page(page)
    > #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
    >
    > #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
    > alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
    >
    > root cause: lack of argument checking on x86 due to stupid macros.
    >
    >
    > Could someone *please* start a little project of extirpating this
    > utter brain damage? Convert those macros to typechecked static
    > inlines on x86 (at least) so this sort of thing (which happens again
    > and again and again) is lessened?


    i wanted to write a reply to suggest a checkpatch policy for this. When
    i noticed this sentence at the end of your mail:

    > macros are such miserable things. I wonder if we could get checkpatch
    > to help out here?


    /me too :-)

    any policy that gets into checkpatch.pl's default output is a policy for
    arch/x86 patch merging. (as long as it's not a false positive) And
    because we do all these unifications the effects of checkpatch.pl
    permeate basically every aspect of arch/x86.

    one approach would be to make new macros in include/* a no-no. That
    would hurt a few of the legitimate uses though, so maybe a useful
    refinement would be to check the structure of macros: are arguments used
    twice (side-effect), are arguments unused (typechecking dager), are
    arguments cast (type-loss danger), etc. Looks very hard to implement
    though :-/ Andy, what do you think?

    Ingo
    --
    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/

  6. Re: [patch 07/18] v4l: nopage

    On Sat, 8 Dec 2007 10:15:08 +0100 Ingo Molnar wrote:

    >
    > * Andrew Morton wrote:
    >
    > > On Wed, 05 Dec 2007 18:15:54 +1100
    > > npiggin@suse.de wrote:
    > >
    > > > +static int
    > > > +videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > > > {
    > > > struct page *page;
    > > >
    > > > - dprintk(3,"nopage: fault @ %08lx [vma %08lx-%08lx]\n",
    > > > - vaddr,vma->vm_start,vma->vm_end);
    > > > - if (vaddr > vma->vm_end)
    > > > - return NOPAGE_SIGBUS;
    > > > + dprintk(3,"fault: fault @ %08lx [vma %08lx-%08lx]\n",
    > > > + (unsigned long)vmf->virtual_address,vma->vm_start,vma->vm_end);
    > > > page = alloc_page(GFP_USER | __GFP_DMA32);
    > > > if (!page)
    > > > - return NOPAGE_OOM;
    > > > + return VM_FAULT_OOM;
    > > > clear_user_page(page_address(page), vaddr, page);

    > >
    > > This didn't compile on sparc64 because `vaddr' is undefined.
    > >
    > >
    > > Let us see why:
    > >
    > > #define clear_user_page(page, vaddr, pg) clear_page(page)
    > > #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
    > >
    > > #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
    > > alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
    > >
    > > root cause: lack of argument checking on x86 due to stupid macros.
    > >
    > >
    > > Could someone *please* start a little project of extirpating this
    > > utter brain damage? Convert those macros to typechecked static
    > > inlines on x86 (at least) so this sort of thing (which happens again
    > > and again and again) is lessened?


    We should fix existing stuff, like this.

    > i wanted to write a reply to suggest a checkpatch policy for this. When
    > i noticed this sentence at the end of your mail:
    >
    > > macros are such miserable things. I wonder if we could get checkpatch
    > > to help out here?

    >
    > /me too :-)
    >
    > any policy that gets into checkpatch.pl's default output is a policy for
    > arch/x86 patch merging. (as long as it's not a false positive) And
    > because we do all these unifications the effects of checkpatch.pl
    > permeate basically every aspect of arch/x86.
    >
    > one approach would be to make new macros in include/* a no-no. That
    > would hurt a few of the legitimate uses though, so maybe a useful
    > refinement would be to check the structure of macros: are arguments used
    > twice (side-effect), are arguments unused (typechecking dager), are
    > arguments cast (type-loss danger), etc. Looks very hard to implement
    > though :-/ Andy, what do you think?


    I think whining about anything which matches

    #define foo(...) bar(

    would be a decent start.

    grep '^[ ]*#[ ]*define[ ][ ]*[^(]*[(][^)]*[)][ ]*[a-zA-Z]' include/asm-x86/*.h

    (hey, that worked on the first attempt)

    Lots of falsies tho.
    --
    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/

  7. Re: [patch 07/18] v4l: nopage

    On Fri, 7 Dec 2007 16:31:42 -0800 Andrew Morton wrote:

    > On Wed, 05 Dec 2007 18:15:54 +1100
    > npiggin@suse.de wrote:
    >
    > > +static int
    > > +videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    > > {
    > > struct page *page;
    > >
    > > - dprintk(3,"nopage: fault @ %08lx [vma %08lx-%08lx]\n",
    > > - vaddr,vma->vm_start,vma->vm_end);
    > > - if (vaddr > vma->vm_end)
    > > - return NOPAGE_SIGBUS;
    > > + dprintk(3,"fault: fault @ %08lx [vma %08lx-%08lx]\n",
    > > + (unsigned long)vmf->virtual_address,vma->vm_start,vma->vm_end);
    > > page = alloc_page(GFP_USER | __GFP_DMA32);
    > > if (!page)
    > > - return NOPAGE_OOM;
    > > + return VM_FAULT_OOM;
    > > clear_user_page(page_address(page), vaddr, page);

    >
    > This didn't compile on sparc64 because `vaddr' is undefined.
    >
    >
    > Let us see why:
    >
    > #define clear_user_page(page, vaddr, pg) clear_page(page)
    > #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
    >
    > #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
    > alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
    >
    > root cause: lack of argument checking on x86 due to stupid macros.


    Hm, I would have said that the root cause was that Nick removed the
    vaddr parameter from the function parameters:

    -static struct page*
    -videobuf_vm_nopage(struct vm_area_struct *vma, unsigned long vaddr,
    - int *type)
    +static int
    +videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    {

    Should the function now produce 'vaddr' internally?


    > Could someone *please* start a little project of extirpating this utter
    > brain damage? Convert those macros to typechecked static inlines on x86
    > (at least) so this sort of thing (which happens again and again and again)
    > is lessened?


    Yep, unless someone else is already doing so...

    > macros are such miserable things. I wonder if we could get checkpatch to
    > help out here?



    ---
    ~Randy
    Features and documentation: http://lwn.net/Articles/260136/
    --
    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/

  8. [patch] x64/page.h: convert some macros to inlines

    On Fri, 7 Dec 2007 16:31:42 -0800 Andrew Morton wrote:

    > Could someone *please* start a little project of extirpating this utter
    > brain damage? Convert those macros to typechecked static inlines on x86
    > (at least) so this sort of thing (which happens again and again and again)
    > is lessened?


    Here's a start on it. x86 only and only 4 functions so far.
    Builds cleanly for i386 and x86_64.

    ---

    From: Randy Dunlap

    Convert clear_page/copy_page macros to inline functions for type-checking.
    Andrew wants to extirpate these ugly macros.

    Signed-off-by: Randy Dunlap
    ---
    include/asm-x86/page_32.h | 39 +++++++++++++++++++++++++++++++++------
    include/asm-x86/page_64.h | 19 +++++++++++++++----
    2 files changed, 48 insertions(+), 10 deletions(-)

    --- linux-2.6.24-rc4-git6.orig/include/asm-x86/page_32.h
    +++ linux-2.6.24-rc4-git6/include/asm-x86/page_32.h
    @@ -12,12 +12,21 @@
    #ifdef __KERNEL__
    #ifndef __ASSEMBLY__

    +#include
    +
    #ifdef CONFIG_X86_USE_3DNOW

    #include

    -#define clear_page(page) mmx_clear_page((void *)(page))
    -#define copy_page(to,from) mmx_copy_page(to,from)
    +static inline void clear_page(void *page)
    +{
    + mmx_clear_page(page);
    +}
    +
    +static inline void copy_page(void *to, void *from)
    +{
    + mmx_copy_page(to, from);
    +}

    #else

    @@ -26,13 +35,31 @@
    * Maybe the K6-III ?
    */

    -#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
    -#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
    +static inline void clear_page(void *page)
    +{
    + memset(page, 0, PAGE_SIZE);
    +}
    +
    +static inline void copy_page(void *to, void *from)
    +{
    + memcpy(to, from, PAGE_SIZE);
    +}

    #endif

    -#define clear_user_page(page, vaddr, pg) clear_page(page)
    -#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
    +struct page;
    +
    +static void inline clear_user_page(void *page, unsigned long vaddr,
    + struct page *pg)
    +{
    + clear_page(page);
    +}
    +
    +static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
    + struct page *topage)
    +{
    + copy_page(to, from);
    +}

    #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
    alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
    --- linux-2.6.24-rc4-git6.orig/include/asm-x86/page_64.h
    +++ linux-2.6.24-rc4-git6/include/asm-x86/page_64.h
    @@ -42,11 +42,22 @@

    extern unsigned long end_pfn;

    -void clear_page(void *);
    -void copy_page(void *, void *);
    +void clear_page(void *page);
    +void copy_page(void *to, void *from);

    -#define clear_user_page(page, vaddr, pg) clear_page(page)
    -#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
    +struct page;
    +
    +static void inline clear_user_page(void *page, unsigned long vaddr,
    + struct page *pg)
    +{
    + clear_page(page);
    +}
    +
    +static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
    + struct page *topage)
    +{
    + copy_page(to, from);
    +}

    #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
    alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
    --
    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/

  9. Re: [patch] x64/page.h: convert some macros to inlines


    * Randy Dunlap wrote:

    > > Could someone *please* start a little project of extirpating this
    > > utter brain damage? Convert those macros to typechecked static
    > > inlines on x86 (at least) so this sort of thing (which happens again
    > > and again and again) is lessened?

    >
    > Here's a start on it. x86 only and only 4 functions so far. Builds
    > cleanly for i386 and x86_64.


    great - applied.

    Ingo
    --
    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/

  10. Re: [patch 13/18] alsa: nopage

    At Wed, 05 Dec 2007 18:16:00 +1100,
    npiggin@suse.de wrote:
    >
    > Convert ALSA from nopage to fault.
    > Switch from OOM to SIGBUS if the resource is not available.
    >
    > Signed-off-by: Nick Piggin
    > Cc: perex@perex.cz
    > Cc: tiwai@suse.de
    > Cc: alsa-devel@alsa-project.org
    > Cc: linux-kernel@vger.kernel.org


    I applied this to ALSA HG tree.


    thanks,

    Takashi

    > ---
    > sound/core/pcm_native.c | 59 ++++++++++++++++++++----------------------------
    > 1 file changed, 25 insertions(+), 34 deletions(-)
    >
    > Index: linux-2.6/sound/core/pcm_native.c
    > ================================================== =================
    > --- linux-2.6.orig/sound/core/pcm_native.c
    > +++ linux-2.6/sound/core/pcm_native.c
    > @@ -3018,26 +3018,23 @@ static unsigned int snd_pcm_capture_poll
    > /*
    > * mmap status record
    > */
    > -static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
    > - unsigned long address, int *type)
    > +static int snd_pcm_mmap_status_fault(struct vm_area_struct *area,
    > + struct vm_fault *vmf)
    > {
    > struct snd_pcm_substream *substream = area->vm_private_data;
    > struct snd_pcm_runtime *runtime;
    > - struct page * page;
    >
    > if (substream == NULL)
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > runtime = substream->runtime;
    > - page = virt_to_page(runtime->status);
    > - get_page(page);
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return page;
    > + vmf->page = virt_to_page(runtime->status);
    > + get_page(vmf->page);
    > + return 0;
    > }
    >
    > static struct vm_operations_struct snd_pcm_vm_ops_status =
    > {
    > - .nopage = snd_pcm_mmap_status_nopage,
    > + .fault = snd_pcm_mmap_status_fault,
    > };
    >
    > static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file,
    > @@ -3061,26 +3058,23 @@ static int snd_pcm_mmap_status(struct sn
    > /*
    > * mmap control record
    > */
    > -static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
    > - unsigned long address, int *type)
    > +static int snd_pcm_mmap_control_fault(struct vm_area_struct *area,
    > + struct vm_fault *vmf)
    > {
    > struct snd_pcm_substream *substream = area->vm_private_data;
    > struct snd_pcm_runtime *runtime;
    > - struct page * page;
    >
    > if (substream == NULL)
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > runtime = substream->runtime;
    > - page = virt_to_page(runtime->control);
    > - get_page(page);
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return page;
    > + vmf->page = virt_to_page(runtime->control);
    > + get_page(vmf->page);
    > + return 0;
    > }
    >
    > static struct vm_operations_struct snd_pcm_vm_ops_control =
    > {
    > - .nopage = snd_pcm_mmap_control_nopage,
    > + .fault = snd_pcm_mmap_control_fault,
    > };
    >
    > static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file,
    > @@ -3117,10 +3111,10 @@ static int snd_pcm_mmap_control(struct s
    > #endif /* coherent mmap */
    >
    > /*
    > - * nopage callback for mmapping a RAM page
    > + * fault callback for mmapping a RAM page
    > */
    > -static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
    > - unsigned long address, int *type)
    > +static int snd_pcm_mmap_data_fault(struct vm_area_struct *area,
    > + struct vm_fault *vmf)
    > {
    > struct snd_pcm_substream *substream = area->vm_private_data;
    > struct snd_pcm_runtime *runtime;
    > @@ -3130,33 +3124,30 @@ static struct page *snd_pcm_mmap_data_no
    > size_t dma_bytes;
    >
    > if (substream == NULL)
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > runtime = substream->runtime;
    > - offset = area->vm_pgoff << PAGE_SHIFT;
    > - offset += address - area->vm_start;
    > - snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
    > + offset = vmf->pgoff << PAGE_SHIFT;
    > dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
    > if (offset > dma_bytes - PAGE_SIZE)
    > - return NOPAGE_SIGBUS;
    > + return VM_FAULT_SIGBUS;
    > if (substream->ops->page) {
    > page = substream->ops->page(substream, offset);
    > - if (! page)
    > - return NOPAGE_OOM; /* XXX: is this really due to OOM? */
    > + if (!page)
    > + return VM_FAULT_SIGBUS;
    > } else {
    > vaddr = runtime->dma_area + offset;
    > page = virt_to_page(vaddr);
    > }
    > get_page(page);
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > - return page;
    > + vmf->page = page;
    > + return 0;
    > }
    >
    > static struct vm_operations_struct snd_pcm_vm_ops_data =
    > {
    > .open = snd_pcm_mmap_data_open,
    > .close = snd_pcm_mmap_data_close,
    > - .nopage = snd_pcm_mmap_data_nopage,
    > + .fault = snd_pcm_mmap_data_fault,
    > };
    >
    > /*
    >
    > --
    >

    --
    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/

  11. Re: [patch 15/18] alsa: usx2y nopage

    At Wed, 05 Dec 2007 18:16:02 +1100,
    npiggin@suse.de wrote:
    >
    > Convert alsa usx2y driver from nopage to fault.
    >
    > Signed-off-by: Nick Piggin
    > Cc: tiwai@suse.de
    > Cc: annabellesgarden@yahoo.de
    > Cc: linux-kernel@vger.kernel.org


    Applied this one to ALSA tree, too.


    thanks,

    Takashi

    > ---
    > sound/usb/usx2y/usX2Yhwdep.c | 21 ++++++++-------------
    > sound/usb/usx2y/usx2yhwdeppcm.c | 19 ++++++-------------
    > 2 files changed, 14 insertions(+), 26 deletions(-)
    >
    > Index: linux-2.6/sound/usb/usx2y/usX2Yhwdep.c
    > ================================================== =================
    > --- linux-2.6.orig/sound/usb/usx2y/usX2Yhwdep.c
    > +++ linux-2.6/sound/usb/usx2y/usX2Yhwdep.c
    > @@ -34,34 +34,29 @@
    > int usX2Y_hwdep_pcm_new(struct snd_card *card);
    >
    >
    > -static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type)
    > +static int snd_us428ctls_vm_fault(struct vm_area_struct *area, struct vm_fault *vmf)
    > {
    > unsigned long offset;
    > struct page * page;
    > void *vaddr;
    >
    > - snd_printdd("ENTER, start %lXh, ofs %lXh, pgoff %ld, addr %lXh\n",
    > + snd_printdd("ENTER, start %lXh, pgoff %ld\n",
    > area->vm_start,
    > - address - area->vm_start,
    > - (address - area->vm_start) >> PAGE_SHIFT,
    > - address);
    > + vmf->pgoff);
    >
    > - offset = area->vm_pgoff << PAGE_SHIFT;
    > - offset += address - area->vm_start;
    > - snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
    > + offset = vmf->pgoff << PAGE_SHIFT;
    > vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset;
    > page = virt_to_page(vaddr);
    > get_page(page);
    > - snd_printdd( "vaddr=%p made us428ctls_vm_nopage() return %p; offset=%lX\n", vaddr, page, offset);
    > + vmf->page = page;
    >
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > + snd_printdd( "vaddr=%p made us428ctls_vm_fault() page %p\n", vaddr, page);
    >
    > - return page;
    > + return 0;
    > }
    >
    > static struct vm_operations_struct us428ctls_vm_ops = {
    > - .nopage = snd_us428ctls_vm_nopage,
    > + .fault = snd_us428ctls_vm_fault,
    > };
    >
    > static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area)
    > Index: linux-2.6/sound/usb/usx2y/usx2yhwdeppcm.c
    > ================================================== =================
    > --- linux-2.6.orig/sound/usb/usx2y/usx2yhwdeppcm.c
    > +++ linux-2.6/sound/usb/usx2y/usx2yhwdeppcm.c
    > @@ -683,30 +683,23 @@ static void snd_usX2Y_hwdep_pcm_vm_close
    > }
    >
    >
    > -static struct page * snd_usX2Y_hwdep_pcm_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type)
    > +static int snd_usX2Y_hwdep_pcm_vm_fault(struct vm_area_struct *area, struct vm_fault *vmf)
    > {
    > unsigned long offset;
    > - struct page *page;
    > void *vaddr;
    >
    > - offset = area->vm_pgoff << PAGE_SHIFT;
    > - offset += address - area->vm_start;
    > - snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);
    > + offset = vmf->pgoff << PAGE_SHIFT;
    > vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->hwdep_pcm_shm + offset;
    > - page = virt_to_page(vaddr);
    > - get_page(page);
    > -
    > - if (type)
    > - *type = VM_FAULT_MINOR;
    > -
    > - return page;
    > + vmf->page = virt_to_page(vaddr);
    > + get_page(vmf->page);
    > + return 0;
    > }
    >
    >
    > static struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = {
    > .open = snd_usX2Y_hwdep_pcm_vm_open,
    > .close = snd_usX2Y_hwdep_pcm_vm_close,
    > - .nopage = snd_usX2Y_hwdep_pcm_vm_nopage,
    > + .fault = snd_usX2Y_hwdep_pcm_vm_fault,
    > };
    >
    >
    >
    > --
    >

    --
    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/

  12. Re: [patch 06/18] ieee1394: nopage

    On 5 Dec, npiggin@suse.de wrote:
    > Convert ieee1394 from nopage to fault.
    > Remove redundant vma range checks (correct resource range check is retained).


    I finally did a brief runtime test. Works for me with coriander,
    dvgrab, and kino on x86-64. Committed to linux1394-2.6.git.
    --
    Stefan Richter
    -=====-=-=== ==-- -====
    http://arcgraph.de/sr/

    --
    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/

  13. Re: [patch 06/18] ieee1394: nopage

    On 6 Dec, Nick Piggin wrote:
    > On Wed, Dec 05, 2007 at 02:09:48PM +0100, Stefan Richter wrote:
    >> npiggin@suse.de wrote:
    >> > + if (vmf->pgoff >= dma->n_pages)
    >> > + goto error;
    >> > +
    >> > + kernel_virt_addr = (unsigned long)dma->kvirt + (vmf->pgoff << PAGE_SHIFT);
    >> > + vmf->page = vmalloc_to_page((void *)kernel_virt_addr);
    >> > + get_page(vmf->page);
    >> > + return 0;
    >> > +
    >> > + error:
    >> > + return VM_FAULT_SIGBUS;
    >> > }

    >>
    >> Why not replacing the two 'goto error' by 'return VM_FAULT_SIGBUS'? If
    >> there is no cleanup after that error jump, I find it sensible to return
    >> early.

    >
    > Fair enough, I just didn't want to gamut of reactions from maintainers
    > to my cleanups



    Subject: ieee1394: small cleanup after "nopage"

    Signed-off-by: Stefan Richter
    ---
    drivers/ieee1394/dma.c | 16 ++++------------
    1 file changed, 4 insertions(+), 12 deletions(-)

    Index: linux/drivers/ieee1394/dma.c
    ================================================== =================
    --- linux.orig/drivers/ieee1394/dma.c
    +++ linux/drivers/ieee1394/dma.c
    @@ -231,28 +231,20 @@ void dma_region_sync_for_device(struct d

    #ifdef CONFIG_MMU

    -/* fault() handler for mmap access */
    -
    static int dma_region_pagefault(struct vm_area_struct *vma,
    - struct vm_fault *vmf)
    + struct vm_fault *vmf)
    {
    - unsigned long kernel_virt_addr;
    -
    struct dma_region *dma = (struct dma_region *)vma->vm_private_data;

    if (!dma->kvirt)
    - goto error;
    + return VM_FAULT_SIGBUS;

    if (vmf->pgoff >= dma->n_pages)
    - goto error;
    + return VM_FAULT_SIGBUS;

    - kernel_virt_addr = (unsigned long)dma->kvirt + (vmf->pgoff << PAGE_SHIFT);
    - vmf->page = vmalloc_to_page((void *)kernel_virt_addr);
    + vmf->page = vmalloc_to_page(dma->kvirt + (vmf->pgoff << PAGE_SHIFT));
    get_page(vmf->page);
    return 0;
    -
    - error:
    - return VM_FAULT_SIGBUS;
    }

    static struct vm_operations_struct dma_region_vm_ops = {


    --
    Stefan Richter
    -=====-=-=== ==-- -====
    http://arcgraph.de/sr/

    --
    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/

  14. Re: [patch 10/18] sg: nopage

    For the patch shown below:

    Signed-off-by: Douglas Gilbert



    npiggin@suse.de wrote:
    Convert SG from nopage to fault.

    Signed-off-by: Nick Piggin
    Cc: dgilbert@interlog.com
    Cc: linux-scsi@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    ---
    drivers/scsi/sg.c | 23 +++++++++++------------
    1 file changed, 11 insertions(+), 12 deletions(-)

    Index: linux-2.6/drivers/scsi/sg.c
    ================================================== =================
    --- linux-2.6.orig/drivers/scsi/sg.c
    +++ linux-2.6/drivers/scsi/sg.c
    @@ -1144,23 +1144,22 @@ sg_fasync(int fd, struct file *filp, int
    return (retval < 0) ? retval : 0;
    }

    -static struct page *
    -sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type)
    +static int
    +sg_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    {
    Sg_fd *sfp;
    - struct page *page = NOPAGE_SIGBUS;
    unsigned long offset, len, sa;
    Sg_scatter_hold *rsv_schp;
    struct scatterlist *sg;
    int k;

    if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data)))
    - return page;
    + return VM_FAULT_SIGBUS;
    rsv_schp = &sfp->reserve;
    - offset = addr - vma->vm_start;
    + offset = vmf->pgoff << PAGE_SHIFT;
    if (offset >= rsv_schp->bufflen)
    - return page;
    - SCSI_LOG_TIMEOUT(3, printk("sg_vma_nopage: offset=%lu, scatg=%d\n",
    + return VM_FAULT_SIGBUS;
    + SCSI_LOG_TIMEOUT(3, printk("sg_vma_fault: offset=%lu, scatg=%d\n",
    offset, rsv_schp->k_use_sg));
    sg = rsv_schp->buffer;
    sa = vma->vm_start;
    @@ -1169,21 +1168,21 @@ sg_vma_nopage(struct vm_area_struct *vma
    len = vma->vm_end - sa;
    len = (len < sg->length) ? len : sg->length;
    if (offset < len) {
    + struct page *page;
    page = virt_to_page(page_address(sg_page(sg)) + offset);
    get_page(page); /* increment page count */
    - break;
    + vmf->page = page;
    + return 0; /* success */
    }
    sa += len;
    offset -= len;
    }

    - if (type)
    - *type = VM_FAULT_MINOR;
    - return page;
    + return VM_FAULT_SIGBUS;
    }

    static struct vm_operations_struct sg_mmap_vm_ops = {
    - .nopage = sg_vma_nopage,
    + .fault = sg_vma_fault,
    };

    static int


    --
    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
Page 2 of 2 FirstFirst 1 2