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

fbdev: Replace fb_pgprotect() with pgprot_framebuffer()

Rename the fbdev mmap helper fb_pgprotect() to pgprot_framebuffer().
The helper sets VMA page-access flags for framebuffers in device I/O
memory.

Also clean up the helper's parameters and return value. Instead of
the VMA instance, pass the individial parameters separately: existing
page-access flags, the VMAs start and end addresses and the offset
in the underlying device memory rsp file. Return the new page-access
flags. These changes align pgprot_framebuffer() with other pgprot_()
functions.

v4:
* fix commit message (Christophe)
v3:
* rename fb_pgprotect() to pgprot_framebuffer() (Arnd)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230922080636.26762-3-tzimmermann@suse.de

+59 -56
+7 -8
arch/ia64/include/asm/fb.h
··· 8 8 9 9 #include <asm/page.h> 10 10 11 - struct file; 12 - 13 - static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, 14 - unsigned long off) 11 + static inline pgprot_t pgprot_framebuffer(pgprot_t prot, 12 + unsigned long vm_start, unsigned long vm_end, 13 + unsigned long offset) 15 14 { 16 - if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start)) 17 - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 15 + if (efi_range_is_wc(vm_start, vm_end - vm_start)) 16 + return pgprot_writecombine(prot); 18 17 else 19 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 18 + return pgprot_noncached(prot); 20 19 } 21 - #define fb_pgprotect fb_pgprotect 20 + #define pgprot_framebuffer pgprot_framebuffer 22 21 23 22 static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n) 24 23 {
+10 -9
arch/m68k/include/asm/fb.h
··· 5 5 #include <asm/page.h> 6 6 #include <asm/setup.h> 7 7 8 - struct file; 9 - 10 - static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, 11 - unsigned long off) 8 + static inline pgprot_t pgprot_framebuffer(pgprot_t prot, 9 + unsigned long vm_start, unsigned long vm_end, 10 + unsigned long offset) 12 11 { 13 12 #ifdef CONFIG_MMU 14 13 #ifdef CONFIG_SUN3 15 - pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE; 14 + pgprot_val(prot) |= SUN3_PAGE_NOCACHE; 16 15 #else 17 16 if (CPU_IS_020_OR_030) 18 - pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE030; 17 + pgprot_val(prot) |= _PAGE_NOCACHE030; 19 18 if (CPU_IS_040_OR_060) { 20 - pgprot_val(vma->vm_page_prot) &= _CACHEMASK040; 19 + pgprot_val(prot) &= _CACHEMASK040; 21 20 /* Use no-cache mode, serialized */ 22 - pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE_S; 21 + pgprot_val(prot) |= _PAGE_NOCACHE_S; 23 22 } 24 23 #endif /* CONFIG_SUN3 */ 25 24 #endif /* CONFIG_MMU */ 25 + 26 + return prot; 26 27 } 27 - #define fb_pgprotect fb_pgprotect 28 + #define pgprot_framebuffer pgprot_framebuffer 28 29 29 30 #include <asm-generic/fb.h> 30 31
+5 -6
arch/mips/include/asm/fb.h
··· 3 3 4 4 #include <asm/page.h> 5 5 6 - struct file; 7 - 8 - static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, 9 - unsigned long off) 6 + static inline pgprot_t pgprot_framebuffer(pgprot_t prot, 7 + unsigned long vm_start, unsigned long vm_end, 8 + unsigned long offset) 10 9 { 11 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 10 + return pgprot_noncached(prot); 12 11 } 13 - #define fb_pgprotect fb_pgprotect 12 + #define pgprot_framebuffer pgprot_framebuffer 14 13 15 14 /* 16 15 * MIPS doesn't define __raw_ I/O macros, so the helpers
+5 -8
arch/powerpc/include/asm/fb.h
··· 2 2 #ifndef _ASM_FB_H_ 3 3 #define _ASM_FB_H_ 4 4 5 - #include <linux/fs.h> 6 - 7 5 #include <asm/page.h> 8 6 9 - static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, 10 - unsigned long off) 7 + static inline pgprot_t pgprot_framebuffer(pgprot_t prot, 8 + unsigned long vm_start, unsigned long vm_end, 9 + unsigned long offset) 11 10 { 12 11 /* 13 12 * PowerPC's implementation of phys_mem_access_prot() does 14 13 * not use the file argument. Set it to NULL in preparation 15 14 * of later updates to the interface. 16 15 */ 17 - vma->vm_page_prot = phys_mem_access_prot(NULL, PHYS_PFN(off), 18 - vma->vm_end - vma->vm_start, 19 - vma->vm_page_prot); 16 + return phys_mem_access_prot(NULL, PHYS_PFN(offset), vm_end - vm_start, prot); 20 17 } 21 - #define fb_pgprotect fb_pgprotect 18 + #define pgprot_framebuffer pgprot_framebuffer 22 19 23 20 #include <asm-generic/fb.h> 24 21
+9 -6
arch/sparc/include/asm/fb.h
··· 4 4 5 5 #include <linux/io.h> 6 6 7 + #include <asm/page.h> 8 + 7 9 struct fb_info; 8 - struct file; 9 - struct vm_area_struct; 10 10 11 11 #ifdef CONFIG_SPARC32 12 - static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, 13 - unsigned long off) 14 - { } 15 - #define fb_pgprotect fb_pgprotect 12 + static inline pgprot_t pgprot_framebuffer(pgprot_t prot, 13 + unsigned long vm_start, unsigned long vm_end, 14 + unsigned long offset) 15 + { 16 + return prot; 17 + } 18 + #define pgprot_framebuffer pgprot_framebuffer 16 19 #endif 17 20 18 21 int fb_is_primary_device(struct fb_info *info);
+7 -5
arch/x86/include/asm/fb.h
··· 2 2 #ifndef _ASM_X86_FB_H 3 3 #define _ASM_X86_FB_H 4 4 5 - struct fb_info; 6 - struct file; 7 - struct vm_area_struct; 5 + #include <asm/page.h> 8 6 9 - void fb_pgprotect(struct file *file, struct vm_area_struct *vma, unsigned long off); 10 - #define fb_pgprotect fb_pgprotect 7 + struct fb_info; 8 + 9 + pgprot_t pgprot_framebuffer(pgprot_t prot, 10 + unsigned long vm_start, unsigned long vm_end, 11 + unsigned long offset); 12 + #define pgprot_framebuffer pgprot_framebuffer 11 13 12 14 int fb_is_primary_device(struct fb_info *info); 13 15 #define fb_is_primary_device fb_is_primary_device
+8 -7
arch/x86/video/fbdev.c
··· 13 13 #include <linux/vgaarb.h> 14 14 #include <asm/fb.h> 15 15 16 - void fb_pgprotect(struct file *file, struct vm_area_struct *vma, unsigned long off) 16 + pgprot_t pgprot_framebuffer(pgprot_t prot, 17 + unsigned long vm_start, unsigned long vm_end, 18 + unsigned long offset) 17 19 { 18 - unsigned long prot; 19 - 20 - prot = pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK; 20 + pgprot_val(prot) &= ~_PAGE_CACHE_MASK; 21 21 if (boot_cpu_data.x86 > 3) 22 - pgprot_val(vma->vm_page_prot) = 23 - prot | cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS); 22 + pgprot_val(prot) |= cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS); 23 + 24 + return prot; 24 25 } 25 - EXPORT_SYMBOL(fb_pgprotect); 26 + EXPORT_SYMBOL(pgprot_framebuffer); 26 27 27 28 int fb_is_primary_device(struct fb_info *info) 28 29 {
+2 -1
drivers/video/fbdev/core/fb_chrdev.c
··· 365 365 mutex_unlock(&info->mm_lock); 366 366 367 367 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); 368 - fb_pgprotect(file, vma, start); 368 + vma->vm_page_prot = pgprot_framebuffer(vma->vm_page_prot, vma->vm_start, 369 + vma->vm_end, start); 369 370 370 371 return vm_iomap_memory(vma, start, len); 371 372 }
+6 -6
include/asm-generic/fb.h
··· 12 12 #include <linux/pgtable.h> 13 13 14 14 struct fb_info; 15 - struct file; 16 15 17 - #ifndef fb_pgprotect 18 - #define fb_pgprotect fb_pgprotect 19 - static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma, 20 - unsigned long off) 16 + #ifndef pgprot_framebuffer 17 + #define pgprot_framebuffer pgprot_framebuffer 18 + static inline pgprot_t pgprot_framebuffer(pgprot_t prot, 19 + unsigned long vm_start, unsigned long vm_end, 20 + unsigned long offset) 21 21 { 22 - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 22 + return pgprot_writecombine(prot); 23 23 } 24 24 #endif 25 25