diff options
author | Nick Piggin <npiggin@suse.de> | 2008-02-06 04:39:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:15 -0500 |
commit | 529e55b6a57bda6df9e45eb268589efc70f63303 (patch) | |
tree | 6f9424043fa47f4c0a6f59e79fa7094ec10da6d1 | |
parent | 8c85fd89be565e7b7ff48d66b3544b320c129475 (diff) |
fb: defio nopage
Convert fb defio from nopage to fault.
Switch from OOM to SIGBUS if the resource is not available.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Jaya Kumar <jayakumar.lkml@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Documentation/fb/deferred_io.txt | 6 | ||||
-rw-r--r-- | drivers/video/fb_defio.c | 17 |
2 files changed, 11 insertions, 12 deletions
diff --git a/Documentation/fb/deferred_io.txt b/Documentation/fb/deferred_io.txt index 63883a892120..748328370250 100644 --- a/Documentation/fb/deferred_io.txt +++ b/Documentation/fb/deferred_io.txt | |||
@@ -7,10 +7,10 @@ IO. The following example may be a useful explanation of how one such setup | |||
7 | works: | 7 | works: |
8 | 8 | ||
9 | - userspace app like Xfbdev mmaps framebuffer | 9 | - userspace app like Xfbdev mmaps framebuffer |
10 | - deferred IO and driver sets up nopage and page_mkwrite handlers | 10 | - deferred IO and driver sets up fault and page_mkwrite handlers |
11 | - userspace app tries to write to mmaped vaddress | 11 | - userspace app tries to write to mmaped vaddress |
12 | - we get pagefault and reach nopage handler | 12 | - we get pagefault and reach fault handler |
13 | - nopage handler finds and returns physical page | 13 | - fault handler finds and returns physical page |
14 | - we get page_mkwrite where we add this page to a list | 14 | - we get page_mkwrite where we add this page to a list |
15 | - schedule a workqueue task to be run after a delay | 15 | - schedule a workqueue task to be run after a delay |
16 | - app continues writing to that page with no additional cost. this is | 16 | - app continues writing to that page with no additional cost. this is |
diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c index a0c5d9d90d74..0f8cfb988c90 100644 --- a/drivers/video/fb_defio.c +++ b/drivers/video/fb_defio.c | |||
@@ -25,8 +25,8 @@ | |||
25 | #include <linux/pagemap.h> | 25 | #include <linux/pagemap.h> |
26 | 26 | ||
27 | /* this is to find and return the vmalloc-ed fb pages */ | 27 | /* this is to find and return the vmalloc-ed fb pages */ |
28 | static struct page* fb_deferred_io_nopage(struct vm_area_struct *vma, | 28 | static int fb_deferred_io_fault(struct vm_area_struct *vma, |
29 | unsigned long vaddr, int *type) | 29 | struct vm_fault *vmf) |
30 | { | 30 | { |
31 | unsigned long offset; | 31 | unsigned long offset; |
32 | struct page *page; | 32 | struct page *page; |
@@ -34,18 +34,17 @@ static struct page* fb_deferred_io_nopage(struct vm_area_struct *vma, | |||
34 | /* info->screen_base is in System RAM */ | 34 | /* info->screen_base is in System RAM */ |
35 | void *screen_base = (void __force *) info->screen_base; | 35 | void *screen_base = (void __force *) info->screen_base; |
36 | 36 | ||
37 | offset = (vaddr - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); | 37 | offset = vmf->pgoff << PAGE_SHIFT; |
38 | if (offset >= info->fix.smem_len) | 38 | if (offset >= info->fix.smem_len) |
39 | return NOPAGE_SIGBUS; | 39 | return VM_FAULT_SIGBUS; |
40 | 40 | ||
41 | page = vmalloc_to_page(screen_base + offset); | 41 | page = vmalloc_to_page(screen_base + offset); |
42 | if (!page) | 42 | if (!page) |
43 | return NOPAGE_OOM; | 43 | return VM_FAULT_SIGBUS; |
44 | 44 | ||
45 | get_page(page); | 45 | get_page(page); |
46 | if (type) | 46 | vmf->page = page; |
47 | *type = VM_FAULT_MINOR; | 47 | return 0; |
48 | return page; | ||
49 | } | 48 | } |
50 | 49 | ||
51 | int fb_deferred_io_fsync(struct file *file, struct dentry *dentry, int datasync) | 50 | int fb_deferred_io_fsync(struct file *file, struct dentry *dentry, int datasync) |
@@ -84,7 +83,7 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma, | |||
84 | } | 83 | } |
85 | 84 | ||
86 | static struct vm_operations_struct fb_deferred_io_vm_ops = { | 85 | static struct vm_operations_struct fb_deferred_io_vm_ops = { |
87 | .nopage = fb_deferred_io_nopage, | 86 | .fault = fb_deferred_io_fault, |
88 | .page_mkwrite = fb_deferred_io_mkwrite, | 87 | .page_mkwrite = fb_deferred_io_mkwrite, |
89 | }; | 88 | }; |
90 | 89 | ||