Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Blackfin: fix framebuffer mmap bug for nommu

The patch added a special get_unmapped_area for framebuffer which
was hooked to the file ops in drivers/video/fbmem.c.

This is needed since v2.6.29-rc1 where nommu vma management was
updated, and mmap of framebuffer caused kernel BUG panic. You may turn
on "Debug the global anon/private NOMMU mapping region tree" config to
such message.

As Documentation/nommu-mmap.txt said,
"To provide shareable character device support, a driver must provide
a file->f_op->get_unmapped_area() operation. The mmap() routines will
call this to get a proposed address for the mapping."

With this change, user space should call mmap for framebuffer using
shared map. Or it can try shared map first, then private map if
failed. This shared map usage is now consistent between mmu and nommu.

The sys_ file may not be a good place for this patch. But there is a
similar one for sparc. I tested a similar patch on nios2nommu, though
I don't have a blackfin board to test.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Signed-off-by: Graf Yang <graf.yang@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>

authored by

Thomas Chou and committed by
Mike Frysinger
59bd00c8 4a7bcb4f

+17
+6
arch/blackfin/include/asm/pgtable.h
··· 98 98 #define VMALLOC_START 0 99 99 #define VMALLOC_END 0xffffffff 100 100 101 + /* provide a special get_unmapped_area for framebuffer mmaps of nommu */ 102 + extern unsigned long get_fb_unmapped_area(struct file *filp, unsigned long, 103 + unsigned long, unsigned long, 104 + unsigned long); 105 + #define HAVE_ARCH_FB_UNMAPPED_AREA 106 + 101 107 #include <asm-generic/pgtable.h> 102 108 103 109 #endif /* _BLACKFIN_PGTABLE_H */
+11
arch/blackfin/kernel/sys_bfin.c
··· 69 69 { 70 70 return safe_dma_memcpy(dest, src, len); 71 71 } 72 + 73 + #if defined(CONFIG_FB) || defined(CONFIG_FB_MODULE) 74 + #include <linux/fb.h> 75 + unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, 76 + unsigned long len, unsigned long pgoff, unsigned long flags) 77 + { 78 + struct fb_info *info = filp->private_data; 79 + return (unsigned long)info->screen_base; 80 + } 81 + EXPORT_SYMBOL(get_fb_unmapped_area); 82 + #endif