fbdev: Modularize helpers for struct fb_ops
Subsystems (22)
v2 cover fbdev: Modularize helpers for struct fb_ops
Convert the remaining fbdev drivers to use fbdev's helpers macros for struct fb_ops. Then push the current default code for file-I/O operations into a module and remove it as default. Each driver now selects the helpers its needs for file I/O and drawing to its framebuffer. If no helper has been set for an operation in struct fb_ops, the operation is unsupported. Once applied, fbdev drivers will not include unnecessary helper code. The helpers will also be more robust against mis-use.
The first 2 patches are bug fixes. Patches 3 to 26 modify fbdev drivers to set up their fb_ops structures correctly and select the necessary helpers.
Patches 27 and 28 do a few additional minor cleanups.
Patches 29 to 32 move all helpers for struct fb_ops into modules and drop the default. Helpers also warn if they operate on the wrong type of framebuffer memory. Framebuffers in I/O memory and system memory can only be used with the correct helper functions.
v2:
* warn once if I/O callbacks are missing (Javier)
Thomas Zimmermann (32):
fbdev/acornfb: Fix name of fb_ops initializer macro fbdev/sm712fb: Use correct initializer macros for struct fb_ops fbdev/vfb: Set FBINFO_VIRTFB flag
fbdev/vfb: Initialize fb_ops with fbdev macros fbdev/arcfb: Set FBINFO_VIRTFB flag
fbdev/arcfb: Use generator macros for deferred I/O auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros auxdisplay/ht16k33: Set FBINFO_VIRTFB flag auxdisplay/ht16k33: Initialize fb_ops with fbdev macros hid/picolcd_fb: Set FBINFO_VIRTFB flag fbdev/sh_mobile_lcdcfb: Set FBINFO_VIRTFB flag fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros fbdev/smscufx: Select correct helpers
fbdev/udlfb: Select correct helpers
fbdev/au1200fb: Set FBINFO_VIRTFB flag fbdev/au1200fb: Initialize fb_ops with fbdev macros fbdev/ps3fb: Set FBINFO_VIRTFB flag
fbdev/ps3fb: Initialize fb_ops with fbdev macros media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers fbdev/clps711x-fb: Initialize fb_ops with fbdev macros fbdev/vt8500lcdfb: Initialize fb_ops with fbdev macros fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers fbdev/cyber2000fb: Initialize fb_ops with fbdev macros staging/sm750fb: Declare fb_ops as constant staging/sm750fb: Initialize fb_ops with fbdev macros
fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS
fbdev: Remove trailing whitespaces
fbdev: Push pgprot_decrypted() into mmap implementations
fbdev: Move default fb_mmap code into helper function
fbdev: Warn on incorrect framebuffer access
fbdev: Remove default file-I/O implementations
drivers/auxdisplay/Kconfig | 10 +- drivers/auxdisplay/cfag12864bfb.c | 10 +- drivers/auxdisplay/ht16k33.c | 10 +- drivers/hid/hid-picolcd_fb.c | 1 + drivers/media/pci/ivtv/Kconfig | 4 +- drivers/media/pci/ivtv/ivtvfb.c | 6 +- drivers/staging/sm750fb/sm750.c | 65 ++++++++-- drivers/video/fbdev/Kconfig | 50 ++------ drivers/video/fbdev/acornfb.c | 2 +- drivers/video/fbdev/amba-clcd.c | 2 + drivers/video/fbdev/arcfb.c | 114 +++++------------- drivers/video/fbdev/au1100fb.c | 2 + drivers/video/fbdev/au1200fb.c | 11 +- drivers/video/fbdev/clps711x-fb.c | 4 +- drivers/video/fbdev/core/Kconfig | 7 +- drivers/video/fbdev/core/Makefile | 2 +- drivers/video/fbdev/core/cfbcopyarea.c | 3 + drivers/video/fbdev/core/cfbfillrect.c | 3 + drivers/video/fbdev/core/cfbimgblt.c | 3 + drivers/video/fbdev/core/fb_chrdev.c | 68 ++--------- drivers/video/fbdev/core/fb_defio.c | 2 + drivers/video/fbdev/core/fb_io_fops.c | 36 ++++++ drivers/video/fbdev/core/fb_sys_fops.c | 6 + drivers/video/fbdev/core/syscopyarea.c | 3 + drivers/video/fbdev/core/sysfillrect.c | 3 + drivers/video/fbdev/core/sysimgblt.c | 3 + drivers/video/fbdev/cyber2000fb.c | 9 +- drivers/video/fbdev/ep93xx-fb.c | 2 + drivers/video/fbdev/gbefb.c | 2 + drivers/video/fbdev/omap/omapfb_main.c | 2 + .../video/fbdev/omap2/omapfb/omapfb-main.c | 2 + drivers/video/fbdev/ps3fb.c | 11 +- drivers/video/fbdev/sa1100fb.c | 2 + drivers/video/fbdev/sbuslib.c | 5 +- drivers/video/fbdev/sh_mobile_lcdcfb.c | 16 +-- drivers/video/fbdev/sm712fb.c | 6 +- drivers/video/fbdev/smscufx.c | 2 + drivers/video/fbdev/udlfb.c | 2 + drivers/video/fbdev/vermilion/vermilion.c | 2 + drivers/video/fbdev/vfb.c | 10 +- drivers/video/fbdev/vt8500lcdfb.c | 4 +- drivers/video/fbdev/wm8505fb.c | 2 + include/linux/fb.h | 16 ++- 43 files changed, 259 insertions(+), 266 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/32 fbdev/acornfb: Fix name of fb_ops initializer macro
Fix build by using the correct name for the initializer macro for struct fb_ops.
--- drivers/video/fbdev/acornfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/acornfb.c +1 -1
@@ -605,7 +605,7 @@ acornfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)static const struct fb_ops acornfb_ops = { .owner =THIS_MODULE , -FB_IOMEM_DEFAULT_OPS , +FB_DEFAULT_IOMEM_OPS , .fb_check_var = acornfb_check_var, .fb_set_par = acornfb_set_par, .fb_setcolreg = acornfb_setcolreg,
Signature · 1 line
2.43.0
PATCH v2 2/32 fbdev/sm712fb: Use correct initializer macros for struct fb_ops
In reply to Thomas ZimmermannOnly initialize mmap and draw helpers with macros; leave read/write callbacks to driver implementations. Fixes the following warnings:
CC [M] drivers/video/fbdev/sm712fb.o
sm712fb.c:1355:25: warning: initialized field overwritten [-Woverride-init]
1355 | .fb_fillrect = cfb_fillrect,
| ^~~~~~~~~~~~
sm712fb.c:1355:25: note: (near initialization for 'smtcfb_ops.fb_fillrect')
sm712fb.c:1356:25: warning: initialized field overwritten [-Woverride-init]
1356 | .fb_imageblit = cfb_imageblit,
| ^~~~~~~~~~~~~
sm712fb.c:1356:25: note: (near initialization for 'smtcfb_ops.fb_imageblit')
sm712fb.c:1357:25: warning: initialized field overwritten [-Woverride-init]
1357 | .fb_copyarea = cfb_copyarea,
| ^~~~~~~~~~~~
sm712fb.c:1357:25: note: (near initialization for 'smtcfb_ops.fb_copyarea')
sm712fb.c:1358:25: warning: initialized field overwritten [-Woverride-init]
1358 | .fb_read = smtcfb_read,
| ^~~~~~~~~~~
sm712fb.c:1358:25: note: (near initialization for 'smtcfb_ops.fb_read')
sm712fb.c:1359:25: warning: initialized field overwritten [-Woverride-init]
1359 | .fb_write = smtcfb_write,
| ^~~~~~~~~~~~sm712fb.c:1359:25: note: (near initialization for 'smtcfb_ops.fb_write')
--- drivers/video/fbdev/sm712fb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/video/fbdev/sm712fb.c +2 -4
@@ -1347,16 +1347,14 @@ static int smtc_set_par(struct fb_info *info)static const struct fb_ops smtcfb_ops = { .owner =THIS_MODULE , -FB_DEFAULT_IOMEM_OPS , .fb_check_var = smtc_check_var, .fb_set_par = smtc_set_par, .fb_setcolreg = smtc_setcolreg, .fb_blank = smtc_blank, - .fb_fillrect = cfb_fillrect, - .fb_imageblit = cfb_imageblit, - .fb_copyarea = cfb_copyarea, + __FB_DEFAULT_IOMEM_OPS_DRAW, .fb_read = smtcfb_read, .fb_write = smtcfb_write, + __FB_DEFAULT_IOMEM_OPS_MMAP, };/*
Signature · 1 line
2.43.0
PATCH v2 3/32 fbdev/vfb: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe vfb driver operates on system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/video/fbdev/vfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/vfb.c +1 -0
@@ -440,6 +440,7 @@ static int vfb_probe(struct platform_device *dev)if (!info) goto err; + info->flags |=FBINFO_VIRTFB ; info->screen_buffer = videomemory; info->fbops = &vfb_ops;
Signature · 1 line
2.43.0
PATCH v2 4/32 fbdev/vfb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in virtual address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/video/fbdev/Kconfig | 5 +---- drivers/video/fbdev/vfb.c | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/video/fbdev/Kconfig +1 -4
@@ -1800,10 +1800,7 @@ config FB_DA8XX config FB_VIRTUAL tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" depends on FB - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS + select FB_SYSMEM_HELPERS help This is a `virtual' frame buffer device. It operates on a chunk of unswappable kernel memory instead of on the memory of a graphics
drivers/video/fbdev/vfb.c +2 -5
@@ -80,15 +80,12 @@ static int vfb_mmap(struct fb_info *info,static const struct fb_ops vfb_ops = { .owner =THIS_MODULE , - .fb_read = fb_sys_read, - .fb_write = fb_sys_write, + __FB_DEFAULT_SYSMEM_OPS_RDWR, .fb_check_var = vfb_check_var, .fb_set_par = vfb_set_par, .fb_setcolreg = vfb_setcolreg, .fb_pan_display = vfb_pan_display, - .fb_fillrect = sys_fillrect, - .fb_copyarea = sys_copyarea, - .fb_imageblit = sys_imageblit, + __FB_DEFAULT_SYSMEM_OPS_DRAW, .fb_mmap = vfb_mmap, };
Signature · 1 line
2.43.0
PATCH v2 5/32 fbdev/arcfb: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe arcfb driver operates on system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/video/fbdev/arcfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/arcfb.c +1 -0
@@ -529,6 +529,7 @@ static int arcfb_probe(struct platform_device *dev)if (!info) goto err_fb_alloc; + info->flags |=FBINFO_VIRTFB ; info->screen_buffer = videomemory; info->fbops = &arcfb_ops;
Signature · 1 line
2.43.0
PATCH v2 6/32 fbdev/arcfb: Use generator macros for deferred I/O
In reply to Thomas ZimmermannImplement the driver's fops with the generator macros for deferred I/O. Only requires per-driver code for the on-scren scanout buffer. The generated helpers implement reading, writing and drawing on top of that. Also update the selected Kconfig tokens accordingly.
Actual support for deferred I/O is missing from the driver. So writing to memory-mapped pages does not automatically update the scanout buffer.
--- drivers/video/fbdev/Kconfig | 5 +- drivers/video/fbdev/arcfb.c | 113 +++++++++--------------------------- 2 files changed, 27 insertions(+), 91 deletions(-)
drivers/video/fbdev/Kconfig +1 -4
@@ -272,10 +272,7 @@ config FB_FM2 config FB_ARC tristate "Arc Monochrome LCD board support" depends on FB && (X86 || COMPILE_TEST) - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS + select FB_SYSMEM_HELPERS_DEFERRED help This enables support for the Arc Monochrome LCD board. The board is based on the KS-108 lcd controller and is typically a matrix
drivers/video/fbdev/arcfb.c +26 -87
141 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 7/32 auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe cfag12864bfb driver operates on system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/auxdisplay/cfag12864bfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/auxdisplay/cfag12864bfb.c +1 -0
@@ -72,6 +72,7 @@ static int cfag12864bfb_probe(struct platform_device *device)if (!info) goto none; + info->flags =FBINFO_VIRTFB ; info->screen_buffer = cfag12864b_buffer; info->screen_size =CFAG12864B_SIZE ; info->fbops = &cfag12864bfb_ops;
Signature · 1 line
2.43.0
PATCH v2 8/32 auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in virtual address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/auxdisplay/Kconfig | 5 +---- drivers/auxdisplay/cfag12864bfb.c | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/auxdisplay/Kconfig +1 -4
@@ -112,10 +112,7 @@ config CFAG12864B depends on X86 depends on FB depends on KS0108 - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS + select FB_SYSMEM_HELPERS default n help If you have a Crystalfontz 128x64 2-color LCD, cfag12864b Series,
drivers/auxdisplay/cfag12864bfb.c +2 -5
@@ -56,11 +56,8 @@ static int cfag12864bfb_mmap(struct fb_info *info, struct vm_area_struct *vma)static const struct fb_ops cfag12864bfb_ops = { .owner =THIS_MODULE , - .fb_read = fb_sys_read, - .fb_write = fb_sys_write, - .fb_fillrect = sys_fillrect, - .fb_copyarea = sys_copyarea, - .fb_imageblit = sys_imageblit, + __FB_DEFAULT_SYSMEM_OPS_RDWR, + __FB_DEFAULT_SYSMEM_OPS_DRAW, .fb_mmap = cfag12864bfb_mmap, };
Signature · 1 line
2.43.0
PATCH v2 9/32 auxdisplay/ht16k33: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe ht16k33 driver operates on system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/auxdisplay/ht16k33.c | 1 + 1 file changed, 1 insertion(+)
drivers/auxdisplay/ht16k33.c +1 -0
@@ -640,6 +640,7 @@ static int ht16k33_fbdev_probe(struct device *dev, struct ht16k33_priv *priv,INIT_DELAYED_WORK (&priv->work, ht16k33_fb_update); fbdev->info->fbops = &ht16k33_fb_ops; + fbdev->info->flags |=FBINFO_VIRTFB ; fbdev->info->screen_buffer = fbdev->buffer; fbdev->info->screen_size =HT16K33_FB_SIZE ; fbdev->info->fix = ht16k33_fb_fix;
Signature · 1 line
2.43.0
PATCH v2 10/32 auxdisplay/ht16k33: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in virtual address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/auxdisplay/Kconfig | 5 +---- drivers/auxdisplay/ht16k33.c | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/auxdisplay/Kconfig +1 -4
@@ -167,10 +167,7 @@ config IMG_ASCII_LCD config HT16K33 tristate "Holtek Ht16K33 LED controller with keyscan" depends on FB && I2C && INPUT - select FB_SYS_FOPS - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT + select FB_SYSMEM_HELPERS select INPUT_MATRIXKMAP select FB_BACKLIGHT select NEW_LEDS
drivers/auxdisplay/ht16k33.c +2 -5
@@ -356,12 +356,9 @@ static int ht16k33_mmap(struct fb_info *info, struct vm_area_struct *vma)static const struct fb_ops ht16k33_fb_ops = { .owner =THIS_MODULE , - .fb_read = fb_sys_read, - .fb_write = fb_sys_write, + __FB_DEFAULT_SYSMEM_OPS_RDWR, .fb_blank = ht16k33_blank, - .fb_fillrect = sys_fillrect, - .fb_copyarea = sys_copyarea, - .fb_imageblit = sys_imageblit, + __FB_DEFAULT_SYSMEM_OPS_DRAW, .fb_mmap = ht16k33_mmap, };
Signature · 1 line
2.43.0
PATCH v2 11/32 hid/picolcd_fb: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe picolcd_fb driver operates on system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/hid/hid-picolcd_fb.c | 1 + 1 file changed, 1 insertion(+)
drivers/hid/hid-picolcd_fb.c +1 -0
@@ -505,6 +505,7 @@ int picolcd_init_framebuffer(struct picolcd_data *data)dev_err (dev,"can't get a free page for framebuffer\n" ); goto err_nomem; } + info->flags |=FBINFO_VIRTFB ; info->screen_buffer = fbdata->bitmap; info->fix.smem_start = (unsigned long )fbdata->bitmap;memset (fbdata->vbitmap,0xff ,PICOLCDFB_SIZE );
Signature · 1 line
2.43.0
PATCH v2 12/32 fbdev/sh_mobile_lcdcfb: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe sh_mobile_lcdcfb driver operates on DMA-able system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/video/fbdev/sh_mobile_lcdcfb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/sh_mobile_lcdcfb.c +2 -0
@@ -1567,6 +1567,7 @@ sh_mobile_lcdc_overlay_fb_init(struct sh_mobile_lcdc_overlay *ovl) info->fbops = &sh_mobile_lcdc_overlay_ops; info->device = priv->dev; + info->flags |=FBINFO_VIRTFB ; info->screen_buffer = ovl->fb_mem; info->par = ovl;
@@ -2053,6 +2054,7 @@ sh_mobile_lcdc_channel_fb_init(struct sh_mobile_lcdc_chan *ch, info->fbops = &sh_mobile_lcdc_ops; info->device = priv->dev; + info->flags |=FBINFO_VIRTFB ; info->screen_buffer = ch->fb_mem; info->pseudo_palette = &ch->pseudo_palette; info->par = ch;
Signature · 1 line
2.43.0
PATCH v2 13/32 fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in DMA-able virtual address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
The driver uses a mixture of DMA helpers and deferred I/O. That probably needs fixing by a driver maintainer.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/video/fbdev/Kconfig | 7 ++----- drivers/video/fbdev/sh_mobile_lcdcfb.c | 10 +++------- 2 files changed, 5 insertions(+), 12 deletions(-)
drivers/video/fbdev/Kconfig +2 -5
@@ -1634,12 +1634,9 @@ config FB_SH_MOBILE_LCDC depends on FB && HAVE_CLK && HAS_IOMEM depends on SUPERH || ARCH_RENESAS || COMPILE_TEST depends on FB_DEVICE - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO select FB_BACKLIGHT + select FB_DEFERRED_IO + select FB_DMAMEM_HELPERS help Frame buffer driver for the on-chip SH-Mobile LCD controller.
drivers/video/fbdev/sh_mobile_lcdcfb.c +3 -7
@@ -1488,13 +1488,10 @@ sh_mobile_lcdc_overlay_mmap(struct fb_info *info, struct vm_area_struct *vma)static const struct fb_ops sh_mobile_lcdc_overlay_ops = { .owner =THIS_MODULE , - .fb_read = fb_sys_read, - .fb_write = fb_sys_write, - .fb_fillrect = sys_fillrect, - .fb_copyarea = sys_copyarea, - .fb_imageblit = sys_imageblit, + __FB_DEFAULT_DMAMEM_OPS_RDWR, .fb_blank = sh_mobile_lcdc_overlay_blank, .fb_pan_display = sh_mobile_lcdc_overlay_pan, + __FB_DEFAULT_DMAMEM_OPS_DRAW, .fb_ioctl = sh_mobile_lcdc_overlay_ioctl, .fb_check_var = sh_mobile_lcdc_overlay_check_var, .fb_set_par = sh_mobile_lcdc_overlay_set_par,
@@ -1966,8 +1963,7 @@ sh_mobile_lcdc_mmap(struct fb_info *info, struct vm_area_struct *vma)static const struct fb_ops sh_mobile_lcdc_ops = { .owner =THIS_MODULE , .fb_setcolreg = sh_mobile_lcdc_setcolreg, - .fb_read = fb_sys_read, - .fb_write = fb_sys_write, + __FB_DEFAULT_DMAMEM_OPS_RDWR, .fb_fillrect = sh_mobile_lcdc_fillrect, .fb_copyarea = sh_mobile_lcdc_copyarea, .fb_imageblit = sh_mobile_lcdc_imageblit,
Signature · 1 line
2.43.0
PATCH v2 14/32 fbdev/smscufx: Select correct helpers
In reply to Thomas ZimmermannThe driver uses deferred I/O. Select the correct helpers via FB_SYSMEM_HELPERS_DEFERRED in the Kconfig file.
--- drivers/video/fbdev/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/video/fbdev/Kconfig +1 -5
@@ -1683,11 +1683,7 @@ config FB_SMSCUFX tristate "SMSC UFX6000/7000 USB Framebuffer support" depends on FB && USB select FB_MODE_HELPERS - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO + select FB_SYSMEM_HELPERS_DEFERRED help This is a kernel framebuffer driver for SMSC UFX USB devices. Supports fbdev clients like xf86-video-fbdev, kdrive, fbi, and
Signature · 1 line
2.43.0
PATCH v2 15/32 fbdev/udlfb: Select correct helpers
In reply to Thomas ZimmermannThe driver uses deferred I/O. Select the correct helpers via FB_SYSMEM_HELPERS_DEFERRED in the Kconfig file.
--- drivers/video/fbdev/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/video/fbdev/Kconfig +1 -5
@@ -1696,11 +1696,7 @@ config FB_UDL depends on FB && USB depends on FB_DEVICE select FB_MODE_HELPERS - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO + select FB_SYSMEM_HELPERS_DEFERRED help This is a kernel framebuffer driver for DisplayLink USB devices. Supports fbdev clients like xf86-video-fbdev, kdrive, fbi, and
Signature · 1 line
2.43.0
PATCH v2 16/32 fbdev/au1200fb: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe au1200fb driver operates on DMA-able system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/video/fbdev/au1200fb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/au1200fb.c +2 -0
@@ -1568,6 +1568,8 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev) fbi->fix.mmio_len =0 ; fbi->fix.accel =FB_ACCEL_NONE ; + fbi->flags |=FBINFO_VIRTFB ; + fbi->screen_buffer = fbdev->fb_mem;au1200fb_update_fbinfo (fbi);
Signature · 1 line
2.43.0
PATCH v2 17/32 fbdev/au1200fb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in DMA-able virtual address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/video/fbdev/Kconfig | 5 +---- drivers/video/fbdev/au1200fb.c | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/video/fbdev/Kconfig +1 -4
@@ -1457,10 +1457,7 @@ config FB_AU1100 config FB_AU1200 bool "Au1200/Au1300 LCD Driver" depends on (FB = y) && MIPS_ALCHEMY - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS + select FB_DMAMEM_HELPERS help This is the framebuffer driver for the Au1200/Au1300 SOCs. It can drive various panels and CRTs by passing in kernel cmd line
drivers/video/fbdev/au1200fb.c +2 -5
@@ -1488,15 +1488,12 @@ static int au1200fb_ioctl(struct fb_info *info, unsigned int cmd,static const struct fb_ops au1200fb_fb_ops = { .owner =THIS_MODULE , + __FB_DEFAULT_DMAMEM_OPS_RDWR, .fb_check_var = au1200fb_fb_check_var, .fb_set_par = au1200fb_fb_set_par, .fb_setcolreg = au1200fb_fb_setcolreg, .fb_blank = au1200fb_fb_blank, - .fb_fillrect = sys_fillrect, - .fb_copyarea = sys_copyarea, - .fb_imageblit = sys_imageblit, - .fb_read = fb_sys_read, - .fb_write = fb_sys_write, + __FB_DEFAULT_DMAMEM_OPS_DRAW, .fb_sync =NULL , .fb_ioctl = au1200fb_ioctl, .fb_mmap = au1200fb_fb_mmap,
Signature · 1 line
2.43.0
PATCH v2 18/32 fbdev/ps3fb: Set FBINFO_VIRTFB flag
In reply to Thomas ZimmermannThe ps3fb driver operates on system memory. Mark the framebuffer accordingly. Helpers operating on the framebuffer memory will test for the presence of this flag.
--- drivers/video/fbdev/ps3fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/ps3fb.c +1 -1
@@ -1145,7 +1145,7 @@ static int ps3fb_probe(struct ps3_system_bus_device *dev) info->fix.smem_len = ps3fb_videomemory.size -GPU_FB_START ; info->pseudo_palette = par->pseudo_palette; - info->flags =FBINFO_READS_FAST | + info->flags =FBINFO_VIRTFB |FBINFO_READS_FAST |FBINFO_HWACCEL_XPAN |FBINFO_HWACCEL_YPAN ; retval =fb_alloc_cmap (&info->cmap,256 ,0 );
Signature · 1 line
2.43.0
PATCH v2 19/32 fbdev/ps3fb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in virtual address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/video/fbdev/Kconfig | 5 +---- drivers/video/fbdev/ps3fb.c | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/video/fbdev/Kconfig +1 -4
@@ -1715,10 +1715,7 @@ config FB_IBM_GXT4500 config FB_PS3 tristate "PS3 GPU framebuffer driver" depends on FB && PS3_PS3AV - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS + select FB_SYSMEM_HELPERS help Include support for the virtual frame buffer in the PS3 platform.
drivers/video/fbdev/ps3fb.c +2 -5
@@ -939,15 +939,12 @@ static const struct fb_ops ps3fb_ops = { .owner = THIS_MODULE, .fb_open = ps3fb_open, .fb_release = ps3fb_release, - .fb_read = fb_sys_read, - .fb_write = fb_sys_write, + __FB_DEFAULT_SYSMEM_OPS_RDWR, .fb_check_var = ps3fb_check_var, .fb_set_par = ps3fb_set_par, .fb_setcolreg = ps3fb_setcolreg, .fb_pan_display = ps3fb_pan_display, - .fb_fillrect = sys_fillrect, - .fb_copyarea = sys_copyarea, - .fb_imageblit = sys_imageblit, + __FB_DEFAULT_SYSMEM_OPS_DRAW, .fb_mmap = ps3fb_mmap, .fb_blank = ps3fb_blank, .fb_ioctl = ps3fb_ioctl,
Signature · 1 line
2.43.0
PATCH v2 20/32 media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in I/O address space. This explictily sets the read/write, draw and mmap callbacks to the correct default implementation.
Fbdev drivers sometimes rely on the callbacks being NULL for a default implementation to be invoked; hence requireing the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
Set the callbacks via macros. No functional changes.
--- drivers/media/pci/ivtv/Kconfig | 4 +--- drivers/media/pci/ivtv/ivtvfb.c | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/media/pci/ivtv/Kconfig +1 -3
@@ -48,9 +48,7 @@ config VIDEO_IVTV_ALSA config VIDEO_FB_IVTV tristate "Conexant cx23415 framebuffer support" depends on VIDEO_IVTV && FB - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT + select FB_IOMEM_HELPERS help This is a framebuffer driver for the Conexant cx23415 MPEG encoder/decoder.
drivers/media/pci/ivtv/ivtvfb.c +3 -3
@@ -927,17 +927,17 @@ static int ivtvfb_blank(int blank_mode, struct fb_info *info)static const struct fb_ops ivtvfb_ops = { .owner =THIS_MODULE , + .fb_read = fb_io_read, .fb_write = ivtvfb_write, .fb_check_var = ivtvfb_check_var, .fb_set_par = ivtvfb_set_par, .fb_setcolreg = ivtvfb_setcolreg, - .fb_fillrect = cfb_fillrect, - .fb_copyarea = cfb_copyarea, - .fb_imageblit = cfb_imageblit, + __FB_DEFAULT_IOMEM_OPS_DRAW, .fb_cursor =NULL , .fb_ioctl = ivtvfb_ioctl, .fb_pan_display = ivtvfb_pan_display, .fb_blank = ivtvfb_blank, + __FB_DEFAULT_IOMEM_OPS_MMAP, };/* Restore hardware after firmware restart */
Signature · 1 line
2.43.0
PATCH v2 21/32 fbdev/clps711x-fb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in I/O address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
The driver previously selected drawing ops for system memory although it operates on I/O memory. Fixed now.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/video/fbdev/Kconfig | 4 +--- drivers/video/fbdev/clps711x-fb.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/video/fbdev/Kconfig +1 -3
@@ -146,10 +146,8 @@ config FB_ACORN config FB_CLPS711X tristate "CLPS711X LCD support" depends on FB && (ARCH_CLPS711X || COMPILE_TEST) + select FB_IOMEM_HELPERS select FB_MODE_HELPERS - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT select LCD_CLASS_DEVICE select VIDEOMODE_HELPERS help
drivers/video/fbdev/clps711x-fb.c +1 -3
@@ -155,13 +155,11 @@ static int clps711x_fb_blank(int blank, struct fb_info *info)static const struct fb_ops clps711x_fb_ops = { .owner =THIS_MODULE , +FB_DEFAULT_IOMEM_OPS , .fb_setcolreg = clps711x_fb_setcolreg, .fb_check_var = clps711x_fb_check_var, .fb_set_par = clps711x_fb_set_par, .fb_blank = clps711x_fb_blank, - .fb_fillrect = sys_fillrect, - .fb_copyarea = sys_copyarea, - .fb_imageblit = sys_imageblit, };static int clps711x_lcd_check_fb (struct lcd_device *lcddev,struct fb_info *fi)
Signature · 1 line
2.43.0
PATCH v2 22/32 fbdev/vt8500lcdfb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in DMA-able virtual address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/video/fbdev/Kconfig | 1 + drivers/video/fbdev/vt8500lcdfb.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/video/fbdev/Kconfig +1 -0
@@ -1467,6 +1467,7 @@ config FB_VT8500 select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS) select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS) select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS select FB_MODE_HELPERS select VIDEOMODE_HELPERS help
drivers/video/fbdev/vt8500lcdfb.c +3 -1
@@ -241,6 +241,7 @@ static int vt8500lcd_blank(int blank, struct fb_info *info)static const struct fb_ops vt8500lcd_ops = { .owner =THIS_MODULE , + __FB_DEFAULT_DMAMEM_OPS_RDWR, .fb_set_par = vt8500lcd_set_par, .fb_setcolreg = vt8500lcd_setcolreg, .fb_fillrect = wmt_ge_fillrect,
@@ -250,6 +251,7 @@ static const struct fb_ops vt8500lcd_ops = { .fb_ioctl = vt8500lcd_ioctl, .fb_pan_display = vt8500lcd_pan_display, .fb_blank = vt8500lcd_blank, +// .fb_mmap needs DMA mmap };static irqreturn_t vt8500lcd_handle_irq (int irq,void *dev_id)
@@ -357,7 +359,7 @@ static int vt8500lcd_probe(struct platform_device *pdev) fbi->fb.fix.smem_start = fb_mem_phys; fbi->fb.fix.smem_len = fb_mem_len; - fbi->fb.screen_base = fb_mem_virt; + fbi->fb.screen_buffer = fb_mem_virt; fbi->palette_size =PAGE_ALIGN (512 ); fbi->palette_cpu = dma_alloc_coherent(&pdev->dev,
Signature · 1 line
2.43.0
PATCH v2 23/32 fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in DMA-able address space. This explictily sets the read/write, draw and mmap callbacks to the correct default implementation. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default implementation to be invoked; hence requireing the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
Set the callbacks via macros. No functional changes.
--- drivers/video/fbdev/Kconfig | 1 + drivers/video/fbdev/wm8505fb.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/video/fbdev/Kconfig +1 -0
@@ -1480,6 +1480,7 @@ config FB_WM8505 select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS) select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS) select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS select FB_MODE_HELPERS select VIDEOMODE_HELPERS help
drivers/video/fbdev/wm8505fb.c +2 -0
@@ -248,6 +248,7 @@ static int wm8505fb_blank(int blank, struct fb_info *info)static const struct fb_ops wm8505fb_ops = { .owner =THIS_MODULE , + __FB_DEFAULT_DMAMEM_OPS_RDWR, .fb_set_par = wm8505fb_set_par, .fb_setcolreg = wm8505fb_setcolreg, .fb_fillrect = wmt_ge_fillrect,
@@ -256,6 +257,7 @@ static const struct fb_ops wm8505fb_ops = { .fb_sync = wmt_ge_sync, .fb_pan_display = wm8505fb_pan_display, .fb_blank = wm8505fb_blank, + __FB_DEFAULT_IOMEM_OPS_MMAP, };static int wm8505fb_probe (struct platform_device *pdev)
Signature · 1 line
2.43.0
PATCH v2 24/32 fbdev/cyber2000fb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize the instance of struct fb_ops with fbdev initializer macros for framebuffers in I/O address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/video/fbdev/Kconfig | 5 +---- drivers/video/fbdev/cyber2000fb.c | 9 +-------- 2 files changed, 2 insertions(+), 12 deletions(-)
drivers/video/fbdev/Kconfig +1 -4
@@ -178,10 +178,7 @@ config FB_IMX config FB_CYBER2000 tristate "CyberPro 2000/2010/5000 support" depends on FB && PCI && (BROKEN || !SPARC64) - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - select FB_IOMEM_FOPS + select FB_IOMEM_HELPERS select VIDEO_NOMODESET help This enables support for the Integraphics CyberPro 20x0 and 5000
drivers/video/fbdev/cyber2000fb.c +1 -8
@@ -227,13 +227,6 @@ cyber2000fb_copyarea(struct fb_info *info, const struct fb_copyarea *region) CO_REG_CMD_H, cfb); } -static void -cyber2000fb_imageblit (struct fb_info *info,const struct fb_image *image) -{ -cfb_imageblit (info, image); -return ; -} -static int cyber2000fb_sync (struct fb_info *info) { struct cfb_info *cfb = container_of(info, struct cfb_info, fb);
@@ -1069,7 +1062,7 @@ static const struct fb_ops cyber2000fb_ops = { .fb_pan_display = cyber2000fb_pan_display, .fb_fillrect = cyber2000fb_fillrect, .fb_copyarea = cyber2000fb_copyarea, - .fb_imageblit = cyber2000fb_imageblit, + .fb_imageblit = cfb_imageblit, .fb_sync = cyber2000fb_sync, __FB_DEFAULT_IOMEM_OPS_MMAP, };
Signature · 1 line
2.43.0
PATCH v2 25/32 staging/sm750fb: Declare fb_ops as constant
In reply to Thomas ZimmermannSplit up lynxfb_ops and declare each as constant. The fb_ops instance used to be modified while initializing the driver. It is now constant and the driver picks the correct instance, depending on the settings for acceleration and cursor support.
--- drivers/staging/sm750fb/sm750.c | 59 +++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 10 deletions(-)
drivers/staging/sm750fb/sm750.c +49 -10
@@ -663,16 +663,53 @@ static int sm750fb_set_drv(struct lynxfb_par *par)return ret; } -static struct fb_ops lynxfb_ops = { +static const struct fb_ops lynxfb_ops = { .owner =THIS_MODULE , .fb_check_var = lynxfb_ops_check_var, .fb_set_par = lynxfb_ops_set_par, .fb_setcolreg = lynxfb_ops_setcolreg, .fb_blank = lynxfb_ops_blank, + .fb_pan_display = lynxfb_ops_pan_display, .fb_fillrect = cfb_fillrect, .fb_imageblit = cfb_imageblit, .fb_copyarea = cfb_copyarea, -/* cursor */ +}; + +static const struct fb_ops lynxfb_ops_with_cursor = { + .owner =THIS_MODULE , + .fb_check_var = lynxfb_ops_check_var, + .fb_set_par = lynxfb_ops_set_par, + .fb_setcolreg = lynxfb_ops_setcolreg, + .fb_blank = lynxfb_ops_blank, + .fb_pan_display = lynxfb_ops_pan_display, + .fb_fillrect = cfb_fillrect, + .fb_copyarea = cfb_copyarea, + .fb_imageblit = cfb_imageblit, + .fb_cursor = lynxfb_ops_cursor, +}; + +static const struct fb_ops lynxfb_ops_accel = { + .owner =THIS_MODULE , + .fb_check_var = lynxfb_ops_check_var, + .fb_set_par = lynxfb_ops_set_par, + .fb_setcolreg = lynxfb_ops_setcolreg, + .fb_blank = lynxfb_ops_blank, + .fb_pan_display = lynxfb_ops_pan_display, + .fb_fillrect = lynxfb_ops_fillrect, + .fb_copyarea = lynxfb_ops_copyarea, + .fb_imageblit = lynxfb_ops_imageblit, +}; + +static const struct fb_ops lynxfb_ops_accel_with_cursor = { + .owner =THIS_MODULE , + .fb_check_var = lynxfb_ops_check_var, + .fb_set_par = lynxfb_ops_set_par, + .fb_setcolreg = lynxfb_ops_setcolreg, + .fb_blank = lynxfb_ops_blank, + .fb_pan_display = lynxfb_ops_pan_display, + .fb_fillrect = lynxfb_ops_fillrect, + .fb_copyarea = lynxfb_ops_copyarea, + .fb_imageblit = lynxfb_ops_imageblit, .fb_cursor = lynxfb_ops_cursor, };
@@ -714,7 +751,6 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) par->index = index; output->channel = &crtc->channel;sm750fb_set_drv (par); - lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;/* * set current cursor variable and proc pointer,
@@ -731,19 +767,22 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset;memset_io (crtc->cursor.vstart,0 , crtc->cursor.size); -if (!g_hwcursor) { - lynxfb_ops.fb_cursor =NULL ; +if (!g_hwcursor)sm750_hw_cursor_disable (&crtc->cursor); - }/* set info->fbops, must be set before fb_find_mode */ if (!sm750_dev->accel_off) {/* use 2d acceleration */ - lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect; - lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea; - lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit; +if (!g_hwcursor) + info->fbops = &lynxfb_ops_accel; +else + info->fbops = &lynxfb_ops_accel_with_cursor; + }else { +if (!g_hwcursor) + info->fbops = &lynxfb_ops; +else + info->fbops = &lynxfb_ops_with_cursor; } - info->fbops = &lynxfb_ops;if (!g_fbmode[index]) { g_fbmode[index] = g_def_fbmode;
Signature · 1 line
2.43.0
Re: [PATCH v2 25/32] staging/sm750fb: Declare fb_ops as constant
Quoted 11 lines · Thomas Zimmermann
Split up
lynxfb_opsand declare each as constant. Thefb_opsinstance used to be modified while initializing the driver. It is now constant and the driver picks the correct instance, depending on the settings for acceleration and cursor support.Signed-off-by Thomas Zimmermann <[email protected]>Cc Sudip Mukherjee <[email protected]>Cc Teddy Wang <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Quoted 3 lines
--- drivers/staging/sm750fb/sm750.c | 59 +++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 10 deletions(-)
PATCH v2 26/32 staging/sm750fb: Initialize fb_ops with fbdev macros
In reply to Thomas ZimmermannInitialize all instances of struct fb_ops with fbdev initializer macros for framebuffers in I/O address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers in Kconfig.
Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
--- drivers/staging/sm750fb/sm750.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/sm750fb/sm750.c +6 -6
@@ -665,31 +665,28 @@ static int sm750fb_set_drv(struct lynxfb_par *par)static const struct fb_ops lynxfb_ops = { .owner =THIS_MODULE , +FB_DEFAULT_IOMEM_OPS , .fb_check_var = lynxfb_ops_check_var, .fb_set_par = lynxfb_ops_set_par, .fb_setcolreg = lynxfb_ops_setcolreg, .fb_blank = lynxfb_ops_blank, .fb_pan_display = lynxfb_ops_pan_display, - .fb_fillrect = cfb_fillrect, - .fb_imageblit = cfb_imageblit, - .fb_copyarea = cfb_copyarea, };static const struct fb_ops lynxfb_ops_with_cursor = { .owner =THIS_MODULE , +FB_DEFAULT_IOMEM_OPS , .fb_check_var = lynxfb_ops_check_var, .fb_set_par = lynxfb_ops_set_par, .fb_setcolreg = lynxfb_ops_setcolreg, .fb_blank = lynxfb_ops_blank, .fb_pan_display = lynxfb_ops_pan_display, - .fb_fillrect = cfb_fillrect, - .fb_copyarea = cfb_copyarea, - .fb_imageblit = cfb_imageblit, .fb_cursor = lynxfb_ops_cursor, };static const struct fb_ops lynxfb_ops_accel = { .owner =THIS_MODULE , + __FB_DEFAULT_IOMEM_OPS_RDWR, .fb_check_var = lynxfb_ops_check_var, .fb_set_par = lynxfb_ops_set_par, .fb_setcolreg = lynxfb_ops_setcolreg,
@@ -698,10 +695,12 @@ static const struct fb_ops lynxfb_ops_accel = { .fb_fillrect = lynxfb_ops_fillrect, .fb_copyarea = lynxfb_ops_copyarea, .fb_imageblit = lynxfb_ops_imageblit, + __FB_DEFAULT_IOMEM_OPS_MMAP, };static const struct fb_ops lynxfb_ops_accel_with_cursor = { .owner =THIS_MODULE , + __FB_DEFAULT_IOMEM_OPS_RDWR, .fb_check_var = lynxfb_ops_check_var, .fb_set_par = lynxfb_ops_set_par, .fb_setcolreg = lynxfb_ops_setcolreg,
@@ -711,6 +710,7 @@ static const struct fb_ops lynxfb_ops_accel_with_cursor = { .fb_copyarea = lynxfb_ops_copyarea, .fb_imageblit = lynxfb_ops_imageblit, .fb_cursor = lynxfb_ops_cursor, + __FB_DEFAULT_IOMEM_OPS_MMAP, };static int lynxfb_set_fbinfo (struct fb_info *info,int index)
Signature · 1 line
2.43.0
Re: [PATCH v2 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros
Quoted 12 lines · Thomas Zimmermann
Initialize all instances of struct
fb_opswith fbdev initializer macros for framebuffers in I/O address space. Set the read/write, draw and mmap callbacks to the correct implementation and avoid implicit defaults. Also select the necessary helpers inKconfig.Fbdev drivers sometimes rely on the callbacks being NULL for a default I/O-memory-based implementation to be invoked; hence requiring the I/O helpers to be built in any case. Setting all callbacks in all drivers explicitly will allow to make the I/O helpers optional. This benefits systems that do not use these functions.
Quoted 6 lines
Signed-off-by Thomas Zimmermann <[email protected]>Cc Sudip Mukherjee <[email protected]>Cc Teddy Wang <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Reviewed-by Javier Martinez Canillas <[email protected]>
PATCH v2 27/32 fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS
In reply to Thomas ZimmermannRename the token to harmonize naming among various helpers. For example, I/O-memory helpers use FB_IOMEM_FOPS.
--- drivers/video/fbdev/Kconfig | 4 ++-- drivers/video/fbdev/core/Kconfig | 6 +++--- drivers/video/fbdev/core/Makefile | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/video/fbdev/Kconfig +2 -2
@@ -1464,7 +1464,7 @@ config FB_VT8500 select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS) select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS) select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS + select FB_SYSMEM_FOPS select FB_MODE_HELPERS select VIDEOMODE_HELPERS help
@@ -1477,7 +1477,7 @@ config FB_WM8505 select FB_SYS_FILLRECT if (!FB_WMT_GE_ROPS) select FB_SYS_COPYAREA if (!FB_WMT_GE_ROPS) select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS + select FB_SYSMEM_FOPS select FB_MODE_HELPERS select VIDEOMODE_HELPERS help
drivers/video/fbdev/core/Kconfig +3 -3
@@ -129,7 +129,7 @@ config FB_LITTLE_ENDIAN endchoice -config FB_SYS_FOPS +config FB_SYSMEM_FOPS tristate depends on FB_CORE
@@ -142,8 +142,8 @@ config FB_DMAMEM_HELPERS depends on FB_CORE select FB_SYS_COPYAREA select FB_SYS_FILLRECT - select FB_SYS_FOPS select FB_SYS_IMAGEBLIT + select FB_SYSMEM_FOPS config FB_IOMEM_FOPS tristate
@@ -168,8 +168,8 @@ config FB_SYSMEM_HELPERS depends on FB_CORE select FB_SYS_COPYAREA select FB_SYS_FILLRECT - select FB_SYS_FOPS select FB_SYS_IMAGEBLIT + select FB_SYSMEM_FOPS config FB_SYSMEM_HELPERS_DEFERRED bool
drivers/video/fbdev/core/Makefile +1 -1
@@ -32,6 +32,6 @@ obj-$(CONFIG_FB_IOMEM_FOPS) += fb_io_fops.o obj-$(CONFIG_FB_SYS_FILLRECT) += sysfillrect.o obj-$(CONFIG_FB_SYS_COPYAREA) += syscopyarea.o obj-$(CONFIG_FB_SYS_IMAGEBLIT) += sysimgblt.o -obj-$(CONFIG_FB_SYS_FOPS) += fb_sys_fops.o +obj-$(CONFIG_FB_SYSMEM_FOPS) += fb_sys_fops.o obj-$(CONFIG_FB_SVGALIB) += svgalib.o obj-$(CONFIG_FB_DDC) += fb_ddc.o
Signature · 1 line
2.43.0
PATCH v2 28/32 fbdev: Remove trailing whitespaces
In reply to Thomas ZimmermannFix coding style. No functional changes.
--- drivers/video/fbdev/sbuslib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/sbuslib.c +2 -2
@@ -48,7 +48,7 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,unsigned long map_offset =0 ;unsigned long off;int i; - +if (!(vma->vm_flags & (VM_SHARED |VM_MAYSHARE )))return -EINVAL ;
@@ -72,7 +72,7 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,#define POFF_MASK (PAGE_MASK|0x1UL)#else #define POFF_MASK (PAGE_MASK) -#endif +#endif map_offset = (physbase + map[i].poff) &POFF_MASK ;break ; }
Signature · 1 line
2.43.0
PATCH v2 29/32 fbdev: Push pgprot_decrypted() into mmap implementations
In reply to Thomas ZimmermannIf a driver sets struct fb_ops.fb_mmap, the fbdev core automatically calls pgprot_decrypted(). But the default fb_mmap code doesn't handle pgprot_decrypted().
Move the call to pgprot_decrypted() into each drivers' fb_mmap function. This only concerns fb_mmap functions for system and DMA memory. For I/O memory, which is the default case, nothing changes. The fb_mmap for I/O-memory can later be moved into a helper as well.
DRM's fbdev emulation handles pgprot_decrypted() internally via the Prime helpers. Fbdev doesn't have to do anything in this case. In cases where DRM uses deferred I/O, this patch updates fb_mmap correctly.
--- drivers/auxdisplay/cfag12864bfb.c | 2 ++ drivers/auxdisplay/ht16k33.c | 2 ++ drivers/video/fbdev/amba-clcd.c | 2 ++ drivers/video/fbdev/au1100fb.c | 2 ++ drivers/video/fbdev/au1200fb.c | 2 ++ drivers/video/fbdev/core/fb_chrdev.c | 5 ----- drivers/video/fbdev/core/fb_defio.c | 2 ++ drivers/video/fbdev/ep93xx-fb.c | 2 ++ drivers/video/fbdev/gbefb.c | 2 ++ drivers/video/fbdev/omap/omapfb_main.c | 2 ++ drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 2 ++ drivers/video/fbdev/ps3fb.c | 2 ++ drivers/video/fbdev/sa1100fb.c | 2 ++ drivers/video/fbdev/sbuslib.c | 1 + drivers/video/fbdev/sh_mobile_lcdcfb.c | 4 ++++ drivers/video/fbdev/smscufx.c | 2 ++ drivers/video/fbdev/udlfb.c | 2 ++ drivers/video/fbdev/vermilion/vermilion.c | 2 ++ drivers/video/fbdev/vfb.c | 2 ++ 19 files changed, 37 insertions(+), 5 deletions(-)
drivers/auxdisplay/cfag12864bfb.c +2 -0
@@ -51,6 +51,8 @@ static int cfag12864bfb_mmap(struct fb_info *info, struct vm_area_struct *vma) {struct page *pages =virt_to_page (cfag12864b_buffer); + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +return vm_map_pages_zero (vma, &pages,1 ); }
drivers/auxdisplay/ht16k33.c +2 -0
@@ -351,6 +351,8 @@ static int ht16k33_mmap(struct fb_info *info, struct vm_area_struct *vma)struct ht16k33_priv *priv = info->par;struct page *pages =virt_to_page (priv->fbdev.buffer); + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +return vm_map_pages_zero (vma, &pages,1 ); }
drivers/video/fbdev/amba-clcd.c +2 -0
@@ -829,6 +829,8 @@ static int clcdfb_of_dma_setup(struct clcd_fb *fb)static int clcdfb_of_dma_mmap (struct clcd_fb *fb,struct vm_area_struct *vma) { + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +return dma_mmap_wc (&fb->dev->dev, vma, fb->fb.screen_base, fb->fb.fix.smem_start, fb->fb.fix.smem_len); }
drivers/video/fbdev/au1100fb.c +2 -0
@@ -342,6 +342,8 @@ int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) {struct au1100fb_device *fbdev =to_au1100fb_device (fbi); + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +pgprot_val (vma->vm_page_prot) |= (6 <<9 );//CCA=6 return dma_mmap_coherent(fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys,
drivers/video/fbdev/au1200fb.c +2 -0
@@ -1236,6 +1236,8 @@ static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) {struct au1200fb_device *fbdev = info->par; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +return dma_mmap_coherent (fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys, fbdev->fb_len); }
drivers/video/fbdev/core/fb_chrdev.c +0 -5
@@ -325,11 +325,6 @@ static int fb_mmap(struct file *file, struct vm_area_struct *vma)if (info->fbops->fb_mmap) {int res; -/* -* The framebuffer needs to be accessed decrypted, be sure -* SME protection is removed ahead of the call -*/ - vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); res = info->fbops->fb_mmap (info, vma);mutex_unlock (&info->mm_lock);return res;
drivers/video/fbdev/core/fb_defio.c +2 -0
@@ -227,6 +227,8 @@ static const struct address_space_operations fb_deferred_io_aops = {int fb_deferred_io_mmap (struct fb_info *info,struct vm_area_struct *vma) { + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); + vma->vm_ops = &fb_deferred_io_vm_ops;vm_flags_set (vma,VM_DONTEXPAND |VM_DONTDUMP );if (!(info->flags &FBINFO_VIRTFB ))
drivers/video/fbdev/ep93xx-fb.c +2 -0
@@ -311,6 +311,8 @@ static int ep93xxfb_mmap(struct fb_info *info, struct vm_area_struct *vma) {unsigned int offset = vma->vm_pgoff <<PAGE_SHIFT ; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +if (offset < info->fix.smem_len) {return dma_mmap_wc (info->device, vma, info->screen_base, info->fix.smem_start, info->fix.smem_len);
drivers/video/fbdev/gbefb.c +2 -0
@@ -1000,6 +1000,8 @@ static int gbefb_mmap(struct fb_info *info,unsigned long phys_addr, phys_size;u16 *tile; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +/* check range */ if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT ))return -EINVAL ;
drivers/video/fbdev/omap/omapfb_main.c +2 -0
@@ -1203,6 +1203,8 @@ static int omapfb_mmap(struct fb_info *info, struct vm_area_struct *vma)struct omapfb_device *fbdev = plane->fbdev;int r; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +omapfb_rqueue_lock (fbdev); r = fbdev->ctrl->mmap (info, vma);omapfb_rqueue_unlock (fbdev);
drivers/video/fbdev/omap2/omapfb/omapfb-main.c +2 -0
@@ -1095,6 +1095,8 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)u32 len;int r; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); + rg =omapfb_get_mem_region (ofbi->region); start =omapfb_get_region_paddr (ofbi);
drivers/video/fbdev/ps3fb.c +2 -0
@@ -708,6 +708,8 @@ static int ps3fb_mmap(struct fb_info *info, struct vm_area_struct *vma) {int r; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); + r =vm_iomap_memory (vma, info->fix.smem_start, info->fix.smem_len); dev_dbg(info->device, "ps3fb: mmap framebuffer P(%lx)->V(%lx)\n",
drivers/video/fbdev/sa1100fb.c +2 -0
@@ -562,6 +562,8 @@ static int sa1100fb_mmap(struct fb_info *info, container_of(info, struct sa1100fb_info, fb);unsigned long off = vma->vm_pgoff <<PAGE_SHIFT ; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +if (off < info->fix.smem_len) { vma->vm_pgoff +=1 ;/* skip over the palette */ return dma_mmap_wc(fbi->dev, vma, fbi->map_cpu, fbi->map_dma,
drivers/video/fbdev/sbuslib.c +1 -0
@@ -60,6 +60,7 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot);/* Each page, see which map applies */
drivers/video/fbdev/sh_mobile_lcdcfb.c +4 -0
@@ -1482,6 +1482,8 @@ sh_mobile_lcdc_overlay_mmap(struct fb_info *info, struct vm_area_struct *vma)if (info->fbdefio)return fb_deferred_io_mmap (info, vma); + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +return dma_mmap_coherent (ovl->channel->lcdc->dev, vma, ovl->fb_mem, ovl->dma_handle, ovl->fb_size); }
@@ -1956,6 +1958,8 @@ sh_mobile_lcdc_mmap(struct fb_info *info, struct vm_area_struct *vma)if (info->fbdefio)return fb_deferred_io_mmap (info, vma); + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +return dma_mmap_coherent (ch->lcdc->dev, vma, ch->fb_mem, ch->dma_handle, ch->fb_size); }
drivers/video/fbdev/smscufx.c +2 -0
@@ -783,6 +783,8 @@ static int ufx_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)if (info->fbdefio)return fb_deferred_io_mmap (info, vma); + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT ))return -EINVAL ;if (size > info->fix.smem_len)
drivers/video/fbdev/udlfb.c +2 -0
@@ -331,6 +331,8 @@ static int dlfb_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)if (info->fbdefio)return fb_deferred_io_mmap (info, vma); + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +if (vma->vm_pgoff > (~0UL >>PAGE_SHIFT ))return -EINVAL ;if (size > info->fix.smem_len)
drivers/video/fbdev/vermilion/vermilion.c +2 -0
@@ -998,6 +998,8 @@ static int vmlfb_mmap(struct fb_info *info, struct vm_area_struct *vma)int ret;unsigned long prot; + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); + ret =vmlfb_vram_offset (vinfo, offset);if (ret)return -EINVAL ;
drivers/video/fbdev/vfb.c +2 -0
@@ -382,6 +382,8 @@ static int vfb_pan_display(struct fb_var_screeninfo *var,static int vfb_mmap (struct fb_info *info,struct vm_area_struct *vma) { + vma->vm_page_prot =pgprot_decrypted (vma->vm_page_prot); +return remap_vmalloc_range (vma, (void *)info->fix.smem_start, vma->vm_pgoff); }
Signature · 1 line
2.43.0
PATCH v2 30/32 fbdev: Move default fb_mmap code into helper function
In reply to Thomas ZimmermannMove the default fb_mmap code for I/O address spaces into the helper function fb_io_mmap(). The helper can either be called via struct fb_ops.fb_mmap or as the default if no fb_mmap has been set. Also set the new helper in __FB_DEFAULT_IOMEM_OPS_MMAP.
In the mid-term, fb_io_mmap() is supposed to become optional. Fbdev drivers will initialize their struct fb_ops.fb_mmap to the helper and select a corresponding Kconfig token. The helper can then be made optional at compile time.
--- drivers/video/fbdev/core/fb_chrdev.c | 36 +++++---------------------- drivers/video/fbdev/core/fb_io_fops.c | 27 ++++++++++++++++++++ include/linux/fb.h | 3 ++- 3 files changed, 35 insertions(+), 31 deletions(-)
drivers/video/fbdev/core/fb_chrdev.c +6 -30
@@ -314,20 +314,16 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,static int fb_mmap (struct file *file,struct vm_area_struct *vma) {struct fb_info *info =file_fb_info (file); -unsigned long mmio_pgoff; -unsigned long start; -u32 len; +int res;if (!info)return -ENODEV ; +mutex_lock (&info->mm_lock);if (info->fbops->fb_mmap) { -int res; res = info->fbops->fb_mmap (info, vma); -mutex_unlock (&info->mm_lock); -return res;#if IS_ENABLED (CONFIG_FB_DEFERRED_IO ) } else if (info->fbdefio) {/*
@@ -335,35 +331,15 @@ static int fb_mmap(struct file *file, struct vm_area_struct *vma)* minimum, point struct fb_ops.fb_mmap to fb_deferred_io_mmap(). */ dev_warn_once (info->dev,"fbdev mmap not set up for deferred I/O.\n" ); -mutex_unlock (&info->mm_lock); -return -ENODEV ; + res = -ENODEV ;#endif + }else { + res =fb_io_mmap (info, vma); } -/* -* Ugh. This can be either the frame buffer mapping, or -* if pgoff points past it, the mmio mapping. -*/ - start = info->fix.smem_start; - len = info->fix.smem_len; - mmio_pgoff =PAGE_ALIGN ((start & ~PAGE_MASK ) + len) >>PAGE_SHIFT ; -if (vma->vm_pgoff >= mmio_pgoff) { -if (info->var.accel_flags) { -mutex_unlock (&info->mm_lock); -return -EINVAL ; - } - - vma->vm_pgoff -= mmio_pgoff; - start = info->fix.mmio_start; - len = info->fix.mmio_len; - }mutex_unlock (&info->mm_lock); - vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); - vma->vm_page_prot =pgprot_framebuffer (vma->vm_page_prot, vma->vm_start, - vma->vm_end, start); - -return vm_iomap_memory (vma, start, len); +return res; }static int fb_open (struct inode *inode,struct file *file)
drivers/video/fbdev/core/fb_io_fops.c +27 -0
@@ -132,5 +132,32 @@ ssize_t fb_io_write(struct fb_info *info, const char __user *buf, size_t count, }EXPORT_SYMBOL (fb_io_write); +int fb_io_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +unsigned long start = info->fix.smem_start; +u32 len = info->fix.smem_len; +unsigned long mmio_pgoff =PAGE_ALIGN ((start & ~PAGE_MASK ) + len) >>PAGE_SHIFT ; + +/* +* This can be either the framebuffer mapping, or if pgoff points +* past it, the mmio mapping. +*/ +if (vma->vm_pgoff >= mmio_pgoff) { +if (info->var.accel_flags) +return -EINVAL ; + + vma->vm_pgoff -= mmio_pgoff; + start = info->fix.mmio_start; + len = info->fix.mmio_len; + } + + vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); + vma->vm_page_prot =pgprot_framebuffer (vma->vm_page_prot, vma->vm_start, + vma->vm_end, start); + +return vm_iomap_memory (vma, start, len); +} +EXPORT_SYMBOL (fb_io_mmap); +MODULE_DESCRIPTION ("Fbdev helpers for framebuffers in I/O memory" );MODULE_LICENSE ("GPL" );
include/linux/fb.h +2 -1
@@ -536,6 +536,7 @@ extern ssize_t fb_io_read(struct fb_info *info, char __user *buf, size_t count, loff_t *ppos);extern ssize_t fb_io_write (struct fb_info *info,const char __user *buf,size_t count,loff_t *ppos); +int fb_io_mmap (struct fb_info *info,struct vm_area_struct *vma);#define __FB_DEFAULT_IOMEM_OPS_RDWR \ .fb_read = fb_io_read, \
@@ -547,7 +548,7 @@ extern ssize_t fb_io_write(struct fb_info *info, const char __user *buf, .fb_imageblit = cfb_imageblit#define __FB_DEFAULT_IOMEM_OPS_MMAP \ - .fb_mmap = NULL/* default implementation */ + .fb_mmap = fb_io_mmap#define FB_DEFAULT_IOMEM_OPS \ __FB_DEFAULT_IOMEM_OPS_RDWR, \
Signature · 1 line
2.43.0
PATCH v2 31/32 fbdev: Warn on incorrect framebuffer access
In reply to Thomas ZimmermannTest in framebuffer read, write and drawing helpers if FBINFO_VIRTFB has been set correctly. Framebuffers in I/O memory should only be accessed with the architecture's respective helpers. Framebuffers in system memory should be accessed with the regular load and store operations. Presumably not all drivers get this right, so we now warn about it.
--- drivers/video/fbdev/core/cfbcopyarea.c | 3 +++ drivers/video/fbdev/core/cfbfillrect.c | 3 +++ drivers/video/fbdev/core/cfbimgblt.c | 3 +++ drivers/video/fbdev/core/fb_io_fops.c | 9 +++++++++ drivers/video/fbdev/core/fb_sys_fops.c | 6 ++++++ drivers/video/fbdev/core/syscopyarea.c | 3 +++ drivers/video/fbdev/core/sysfillrect.c | 3 +++ drivers/video/fbdev/core/sysimgblt.c | 3 +++ include/linux/fb.h | 8 +++++++- 9 files changed, 40 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/cfbcopyarea.c +3 -0
@@ -391,6 +391,9 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)if (p->state !=FBINFO_STATE_RUNNING )return ; +if (p->flags &FBINFO_VIRTFB ) +fb_warn_once (p,"Framebuffer is not in I/O address space." ); +/* if the beginning of the target area might overlap with the end of the source area, be have to copy the area reverse. */ if ((dy == sy && dx > sx) || (dy > sy)) {
drivers/video/fbdev/core/cfbfillrect.c +3 -0
@@ -287,6 +287,9 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)if (p->state !=FBINFO_STATE_RUNNING )return ; +if (p->flags &FBINFO_VIRTFB ) +fb_warn_once (p,"Framebuffer is not in I/O address space." ); +if (p->fix.visual ==FB_VISUAL_TRUECOLOR || p->fix.visual ==FB_VISUAL_DIRECTCOLOR ) fg = ((u32 *) (p->pseudo_palette))[rect->color];
drivers/video/fbdev/core/cfbimgblt.c +3 -0
@@ -326,6 +326,9 @@ void cfb_imageblit(struct fb_info *p, const struct fb_image *image)if (p->state !=FBINFO_STATE_RUNNING )return ; +if (p->flags &FBINFO_VIRTFB ) +fb_warn_once (p,"Framebuffer is not in I/O address space." ); + bitstart = (dy * p->fix.line_length *8 ) + (dx * bpp); start_index = bitstart & (32 -1 ); pitch_index = (p->fix.line_length & (bpl -1 )) *8 ;
drivers/video/fbdev/core/fb_io_fops.c +9 -0
@@ -12,6 +12,9 @@ ssize_t fb_io_read(struct fb_info *info, char __user *buf, size_t count, loff_tint c, cnt =0 , err =0 ;unsigned long total_size, trailing; +if (info->flags &FBINFO_VIRTFB ) +fb_warn_once (info,"Framebuffer is not in I/O address space." ); +if (!info->screen_base)return -ENODEV ;
@@ -73,6 +76,9 @@ ssize_t fb_io_write(struct fb_info *info, const char __user *buf, size_t count,int c, cnt =0 , err =0 ;unsigned long total_size, trailing; +if (info->flags &FBINFO_VIRTFB ) +fb_warn_once (info,"Framebuffer is not in I/O address space." ); +if (!info->screen_base)return -ENODEV ;
@@ -138,6 +144,9 @@ int fb_io_mmap(struct fb_info *info, struct vm_area_struct *vma)u32 len = info->fix.smem_len;unsigned long mmio_pgoff =PAGE_ALIGN ((start & ~PAGE_MASK ) + len) >>PAGE_SHIFT ; +if (info->flags &FBINFO_VIRTFB ) +fb_warn_once (info,"Framebuffer is not in I/O address space." ); +/* * This can be either the framebuffer mapping, or if pgoff points * past it, the mmio mapping.
drivers/video/fbdev/core/fb_sys_fops.c +6 -0
@@ -22,6 +22,9 @@ ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count,unsigned long total_size, c;ssize_t ret; +if (!(info->flags &FBINFO_VIRTFB )) +fb_warn_once (info,"Framebuffer is not in virtual address space." ); +if (!info->screen_buffer)return -ENODEV ;
@@ -64,6 +67,9 @@ ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,unsigned long total_size, c;size_t ret; +if (!(info->flags &FBINFO_VIRTFB )) +fb_warn_once (info,"Framebuffer is not in virtual address space." ); +if (!info->screen_buffer)return -ENODEV ;
drivers/video/fbdev/core/syscopyarea.c +3 -0
@@ -324,6 +324,9 @@ void sys_copyarea(struct fb_info *p, const struct fb_copyarea *area)if (p->state !=FBINFO_STATE_RUNNING )return ; +if (!(p->flags &FBINFO_VIRTFB )) +fb_warn_once (p,"Framebuffer is not in virtual address space." ); +/* if the beginning of the target area might overlap with the end of the source area, be have to copy the area reverse. */ if ((dy == sy && dx > sx) || (dy > sy)) {
drivers/video/fbdev/core/sysfillrect.c +3 -0
@@ -242,6 +242,9 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)if (p->state !=FBINFO_STATE_RUNNING )return ; +if (!(p->flags &FBINFO_VIRTFB )) +fb_warn_once (p,"Framebuffer is not in virtual address space." ); +if (p->fix.visual ==FB_VISUAL_TRUECOLOR || p->fix.visual ==FB_VISUAL_DIRECTCOLOR ) fg = ((u32 *) (p->pseudo_palette))[rect->color];
drivers/video/fbdev/core/sysimgblt.c +3 -0
@@ -296,6 +296,9 @@ void sys_imageblit(struct fb_info *p, const struct fb_image *image)if (p->state !=FBINFO_STATE_RUNNING )return ; +if (!(p->flags &FBINFO_VIRTFB )) +fb_warn_once (p,"Framebuffer is not in virtual address space." ); + bitstart = (dy * p->fix.line_length *8 ) + (dx * bpp); start_index = bitstart & (32 -1 ); pitch_index = (p->fix.line_length & (bpl -1 )) *8 ;
include/linux/fb.h +7 -1
@@ -849,7 +849,10 @@ static inline bool fb_modesetting_disabled(const char *drvname) }#endif -/* Convenience logging macros */ +/* +* Convenience logging macros +*/ +#define fb_err (fb_info, fmt, ...) \ pr_err("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)#define fb_notice (info, fmt, ...) \
@@ -861,4 +864,7 @@ static inline bool fb_modesetting_disabled(const char *drvname)#define fb_dbg (fb_info, fmt, ...) \ pr_debug("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) +#define fb_warn_once (fb_info, fmt, ...) \ + pr_warn_once("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) +#endif /* _LINUX_FB_H */
Signature · 1 line
2.43.0
PATCH v2 32/32 fbdev: Remove default file-I/O implementations
In reply to Thomas ZimmermannDrop the default implementations for file read, write and mmap operations. Each fbdev driver must now provide an implementation and select any necessary helpers. If no implementation has been set, fbdev returns an errno code to user space. The code is the same as if the operation had not been set in the file_operations struct.
This change makes the fbdev helpers for I/O memory optional. Most systems only use system-memory framebuffers via DRM's fbdev emulation.
v2:
* warn once if I/O callbacks are missing (Javier)
--- drivers/video/fbdev/core/Kconfig | 1 - drivers/video/fbdev/core/fb_chrdev.c | 37 +++++++++------------------- include/linux/fb.h | 5 ++++ 3 files changed, 17 insertions(+), 26 deletions(-)
drivers/video/fbdev/core/Kconfig +0 -1
@@ -4,7 +4,6 @@ # config FB_CORE - select FB_IOMEM_FOPS select VIDEO_CMDLINE tristate
drivers/video/fbdev/core/fb_chrdev.c +12 -25
@@ -34,13 +34,13 @@ static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_tif (!info)return -ENODEV ; +if (fb_WARN_ON_ONCE (info, !info->fbops->fb_read)) +return -EINVAL ; +if (info->state !=FBINFO_STATE_RUNNING )return -EPERM ; -if (info->fbops->fb_read) -return info->fbops->fb_read (info, buf, count, ppos); - -return fb_io_read (info, buf, count, ppos); +return info->fbops->fb_read (info, buf, count, ppos); }static ssize_t fb_write (struct file *file,const char __user *buf,size_t count,loff_t *ppos)
@@ -50,13 +50,13 @@ static ssize_t fb_write(struct file *file, const char __user *buf, size_t count,if (!info)return -ENODEV ; +if (fb_WARN_ON_ONCE (info, !info->fbops->fb_write)) +return -EINVAL ; +if (info->state !=FBINFO_STATE_RUNNING )return -EPERM ; -if (info->fbops->fb_write) -return info->fbops->fb_write (info, buf, count, ppos); - -return fb_io_write (info, buf, count, ppos); +return info->fbops->fb_write (info, buf, count, ppos); } static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
@@ -319,24 +319,11 @@ static int fb_mmap(struct file *file, struct vm_area_struct *vma)if (!info)return -ENODEV ; -mutex_lock (&info->mm_lock); - -if (info->fbops->fb_mmap) { - - res = info->fbops->fb_mmap (info, vma); -#if IS_ENABLED (CONFIG_FB_DEFERRED_IO ) - } else if (info->fbdefio) { -/* -* FB deferred I/O wants you to handle mmap in your drivers. At a -* minimum, point struct fb_ops.fb_mmap to fb_deferred_io_mmap(). -*/ -dev_warn_once (info->dev,"fbdev mmap not set up for deferred I/O.\n" ); - res = -ENODEV ; -#endif - }else { - res =fb_io_mmap (info, vma); - } +if (fb_WARN_ON_ONCE (info, !info->fbops->fb_mmap)) +return -ENODEV ; +mutex_lock (&info->mm_lock); + res = info->fbops->fb_mmap (info, vma);mutex_unlock (&info->mm_lock);return res;
include/linux/fb.h +5 -0
@@ -867,4 +867,9 @@ static inline bool fb_modesetting_disabled(const char *drvname)#define fb_warn_once (fb_info, fmt, ...) \ pr_warn_once("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) +#define fb_WARN_ONCE (fb_info, condition, fmt, ...) \ + WARN_ONCE(condition, "fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) +#define fb_WARN_ON_ONCE (fb_info, x) \ + fb_WARN_ONCE(fb_info, (x), "%s", "fb_WARN_ON_ONCE(" __stringify(x) ")") +#endif /* _LINUX_FB_H */
Signature · 1 line
2.43.0