dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops
@ 2023-11-15 10:19 Thomas Zimmermann
  2023-11-15 10:19 ` [PATCH 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro Thomas Zimmermann
                   ` (31 more replies)
  0 siblings, 32 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

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.

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                            |  11 +-
 43 files changed, 254 insertions(+), 266 deletions(-)


base-commit: ab54663d6cd21c6748f91c1cc0fe3456d4e38ce6
-- 
2.42.0


^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16  9:45   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 02/32] fbdev/sm712fb: Use correct initializer macros for struct fb_ops Thomas Zimmermann
                   ` (30 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Arnd Bergmann, stable, dri-devel, Thomas Zimmermann,
	Sam Ravnborg

Fix build by using the correct name for the initializer macro
for struct fb_ops.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 9037afde8b9d ("fbdev/acornfb: Use fbdev I/O helpers")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: <stable@vger.kernel.org> # v6.6+
---
 drivers/video/fbdev/acornfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/acornfb.c b/drivers/video/fbdev/acornfb.c
index 163d2c9f951c3..f0600f6ca2548 100644
--- a/drivers/video/fbdev/acornfb.c
+++ b/drivers/video/fbdev/acornfb.c
@@ -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,
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 02/32] fbdev/sm712fb: Use correct initializer macros for struct fb_ops
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
  2023-11-15 10:19 ` [PATCH 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16  9:46   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 03/32] fbdev/vfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
                   ` (29 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Teddy Wang, Arnd Bergmann, dri-devel,
	Thomas Zimmermann, Sam Ravnborg, Sudip Mukherjee

Only 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')

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 586132cf1d38 ("fbdev/sm712fb: Initialize fb_ops to fbdev I/O-memory helpers")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Teddy Wang <teddy.wang@siliconmotion.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-fbdev@vger.kernel.org
---
 drivers/video/fbdev/sm712fb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
index 3f8ef50e32095..104f122e0f273 100644
--- a/drivers/video/fbdev/sm712fb.c
+++ b/drivers/video/fbdev/sm712fb.c
@@ -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,
 };
 
 /*
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 03/32] fbdev/vfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
  2023-11-15 10:19 ` [PATCH 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro Thomas Zimmermann
  2023-11-15 10:19 ` [PATCH 02/32] fbdev/sm712fb: Use correct initializer macros for struct fb_ops Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:00   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 04/32] fbdev/vfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (28 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

The vfb driver operates on system memory. Mark the framebuffer
accordingly. Helpers operating on the framebuffer memory will test
for the presence of this flag.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/vfb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c
index 1b7c338f99560..c748b9311fb12 100644
--- a/drivers/video/fbdev/vfb.c
+++ b/drivers/video/fbdev/vfb.c
@@ -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;
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 04/32] fbdev/vfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 03/32] fbdev/vfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:04   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 05/32] fbdev/arcfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
                   ` (27 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig | 5 +----
 drivers/video/fbdev/vfb.c   | 7 ++-----
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 20e0167bf20c9..e897bf3976bc2 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c
index c748b9311fb12..f6140f247e4b0 100644
--- a/drivers/video/fbdev/vfb.c
+++ b/drivers/video/fbdev/vfb.c
@@ -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,
 };
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 05/32] fbdev/arcfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (3 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 04/32] fbdev/vfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:05   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 06/32] fbdev/arcfb: Use generator macros for deferred I/O Thomas Zimmermann
                   ` (26 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel, Jaya Kumar

The arcfb driver operates on system memory. Mark the framebuffer
accordingly. Helpers operating on the framebuffer memory will test
for the presence of this flag.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jaya Kumar <jayalk@intworks.biz>
---
 drivers/video/fbdev/arcfb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
index cff11cb04a551..7344e825543af 100644
--- a/drivers/video/fbdev/arcfb.c
+++ b/drivers/video/fbdev/arcfb.c
@@ -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;
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 06/32] fbdev/arcfb: Use generator macros for deferred I/O
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (4 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 05/32] fbdev/arcfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:16   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
                   ` (25 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel, Jaya Kumar

Implement 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jaya Kumar <jayalk@intworks.biz>
---
 drivers/video/fbdev/Kconfig |   5 +-
 drivers/video/fbdev/arcfb.c | 113 +++++++++---------------------------
 2 files changed, 27 insertions(+), 91 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index e897bf3976bc2..e789e5c1973cb 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
index 7344e825543af..b2408543277ce 100644
--- a/drivers/video/fbdev/arcfb.c
+++ b/drivers/video/fbdev/arcfb.c
@@ -363,39 +363,6 @@ static void arcfb_lcd_update(struct arcfb_par *par, unsigned int dx,
 	}
 }
 
-static void arcfb_fillrect(struct fb_info *info,
-			   const struct fb_fillrect *rect)
-{
-	struct arcfb_par *par = info->par;
-
-	sys_fillrect(info, rect);
-
-	/* update the physical lcd */
-	arcfb_lcd_update(par, rect->dx, rect->dy, rect->width, rect->height);
-}
-
-static void arcfb_copyarea(struct fb_info *info,
-			   const struct fb_copyarea *area)
-{
-	struct arcfb_par *par = info->par;
-
-	sys_copyarea(info, area);
-
-	/* update the physical lcd */
-	arcfb_lcd_update(par, area->dx, area->dy, area->width, area->height);
-}
-
-static void arcfb_imageblit(struct fb_info *info, const struct fb_image *image)
-{
-	struct arcfb_par *par = info->par;
-
-	sys_imageblit(info, image);
-
-	/* update the physical lcd */
-	arcfb_lcd_update(par, image->dx, image->dy, image->width,
-				image->height);
-}
-
 static int arcfb_ioctl(struct fb_info *info,
 			  unsigned int cmd, unsigned long arg)
 {
@@ -436,76 +403,48 @@ static int arcfb_ioctl(struct fb_info *info,
 	}
 }
 
-/*
- * this is the access path from userspace. they can seek and write to
- * the fb. it's inefficient for them to do anything less than 64*8
- * writes since we update the lcd in each write() anyway.
- */
-static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
-			   size_t count, loff_t *ppos)
+static void arcfb_damage_range(struct fb_info *info, off_t off, size_t len)
 {
-	/* modded from epson 1355 */
-
-	unsigned long p;
-	int err;
-	unsigned int fbmemlength,x,y,w,h, bitppos, startpos, endpos, bitcount;
-	struct arcfb_par *par;
-	unsigned int xres;
-
-	if (!info->screen_buffer)
-		return -ENODEV;
-
-	p = *ppos;
-	par = info->par;
-	xres = info->var.xres;
-	fbmemlength = (xres * info->var.yres)/8;
-
-	if (p > fbmemlength)
-		return -ENOSPC;
-
-	err = 0;
-	if ((count + p) > fbmemlength) {
-		count = fbmemlength - p;
-		err = -ENOSPC;
-	}
-
-	if (count) {
-		char *base_addr;
-
-		base_addr = info->screen_buffer;
-		count -= copy_from_user(base_addr + p, buf, count);
-		*ppos += count;
-		err = -EFAULT;
-	}
-
+	struct arcfb_par *par = info->par;
+	unsigned int xres = info->var.xres;
+	unsigned int bitppos, startpos, endpos, bitcount;
+	unsigned int x, y, width, height;
 
-	bitppos = p*8;
+	bitppos = off * 8;
 	startpos = floorXres(bitppos, xres);
-	endpos = ceilXres((bitppos + (count*8)), xres);
+	endpos = ceilXres((bitppos + (len * 8)), xres);
 	bitcount = endpos - startpos;
 
 	x = startpos % xres;
 	y = startpos / xres;
-	w = xres;
-	h = bitcount / xres;
-	arcfb_lcd_update(par, x, y, w, h);
+	width = xres;
+	height = bitcount / xres;
+
+	arcfb_lcd_update(par, x, y, width, height);
+}
 
-	if (count)
-		return count;
-	return err;
+static void arcfb_damage_area(struct fb_info *info, u32 x, u32 y,
+			      u32 width, u32 height)
+{
+	struct arcfb_par *par = info->par;
+
+	/* update the physical lcd */
+	arcfb_lcd_update(par, x, y, width, height);
 }
 
+FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(arcfb,
+				   arcfb_damage_range,
+				   arcfb_damage_area)
+
 static const struct fb_ops arcfb_ops = {
 	.owner		= THIS_MODULE,
 	.fb_open	= arcfb_open,
-	.fb_read        = fb_sys_read,
-	.fb_write	= arcfb_write,
+	__FB_DEFAULT_DEFERRED_OPS_RDWR(arcfb),
 	.fb_release	= arcfb_release,
 	.fb_pan_display	= arcfb_pan_display,
-	.fb_fillrect	= arcfb_fillrect,
-	.fb_copyarea	= arcfb_copyarea,
-	.fb_imageblit	= arcfb_imageblit,
+	__FB_DEFAULT_DEFERRED_OPS_DRAW(arcfb),
 	.fb_ioctl 	= arcfb_ioctl,
+	// .fb_mmap reqires deferred I/O
 };
 
 static int arcfb_probe(struct platform_device *dev)
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (5 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 06/32] fbdev/arcfb: Use generator macros for deferred I/O Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:16   ` Javier Martinez Canillas
  2023-11-21 23:44   ` Miguel Ojeda
  2023-11-15 10:19 ` [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (24 subsequent siblings)
  31 siblings, 2 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: Miguel Ojeda, linux-fbdev, Thomas Zimmermann, dri-devel

The cfag12864bfb driver operates on system memory. Mark the framebuffer
accordingly. Helpers operating on the framebuffer memory will test for
the presence of this flag.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Miguel Ojeda <ojeda@kernel.org>
---
 drivers/auxdisplay/cfag12864bfb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
index 729845bcc803a..c0ba693845aaf 100644
--- a/drivers/auxdisplay/cfag12864bfb.c
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -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;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (6 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:22   ` Javier Martinez Canillas
  2023-11-21 23:45   ` Miguel Ojeda
  2023-11-15 10:19 ` [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag Thomas Zimmermann
                   ` (23 subsequent siblings)
  31 siblings, 2 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: Miguel Ojeda, linux-fbdev, Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Miguel Ojeda <ojeda@kernel.org>
---
 drivers/auxdisplay/Kconfig        | 5 +----
 drivers/auxdisplay/cfag12864bfb.c | 7 ++-----
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index 64012cda4d126..4377e53f8f572 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -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,
diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
index c0ba693845aaf..ede0f9a513110 100644
--- a/drivers/auxdisplay/cfag12864bfb.c
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -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,
 };
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (7 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:23   ` Javier Martinez Canillas
                     ` (2 more replies)
  2023-11-15 10:19 ` [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (22 subsequent siblings)
  31 siblings, 3 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: Miguel Ojeda, Robin van der Gracht, linux-fbdev,
	Thomas Zimmermann, dri-devel

The ht16k33 driver operates on system memory. Mark the framebuffer
accordingly. Helpers operating on the framebuffer memory will test
for the presence of this flag.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Robin van der Gracht <robin@protonic.nl>
---
 drivers/auxdisplay/ht16k33.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
index 3a2d883872249..f1716e3ce6a92 100644
--- a/drivers/auxdisplay/ht16k33.c
+++ b/drivers/auxdisplay/ht16k33.c
@@ -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;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (8 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:23   ` Javier Martinez Canillas
                     ` (2 more replies)
  2023-11-15 10:19 ` [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
                   ` (21 subsequent siblings)
  31 siblings, 3 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: Miguel Ojeda, Robin van der Gracht, linux-fbdev,
	Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Robin van der Gracht <robin@protonic.nl>
---
 drivers/auxdisplay/Kconfig   | 5 +----
 drivers/auxdisplay/ht16k33.c | 7 ++-----
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index 4377e53f8f572..d944d5298eca8 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -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
diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
index f1716e3ce6a92..2f1dc6b4e2765 100644
--- a/drivers/auxdisplay/ht16k33.c
+++ b/drivers/auxdisplay/ht16k33.c
@@ -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,
 };
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (9 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:27   ` Javier Martinez Canillas
  2023-11-21  8:42   ` Jiri Kosina
  2023-11-15 10:19 ` [PATCH 12/32] fbdev/sh_mobile_lcdcfb: " Thomas Zimmermann
                   ` (20 subsequent siblings)
  31 siblings, 2 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Jiri Kosina, dri-devel, Bruno Prémont,
	Benjamin Tissoires, Thomas Zimmermann, linux-input

The 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: "Bruno Prémont" <bonbons@linux-vserver.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
---
 drivers/hid/hid-picolcd_fb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c
index a4dccdcda26fc..d7dddd99d325e 100644
--- a/drivers/hid/hid-picolcd_fb.c
+++ b/drivers/hid/hid-picolcd_fb.c
@@ -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);
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 12/32] fbdev/sh_mobile_lcdcfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (10 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:29   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 13/32] fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (19 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

The 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/sh_mobile_lcdcfb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index 1364dafaadb1d..5c99fc8a409fd 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -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;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 13/32] fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (11 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 12/32] fbdev/sh_mobile_lcdcfb: " Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:45   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 14/32] fbdev/smscufx: Select correct helpers Thomas Zimmermann
                   ` (18 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig            |  7 ++-----
 drivers/video/fbdev/sh_mobile_lcdcfb.c | 10 +++-------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index e789e5c1973cb..409e02130be0f 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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.
 
diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index 5c99fc8a409fd..d84628de51893 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -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,
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 14/32] fbdev/smscufx: Select correct helpers
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (12 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 13/32] fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:46   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 15/32] fbdev/udlfb: " Thomas Zimmermann
                   ` (17 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

The driver uses deferred I/O. Select the correct helpers via
FB_SYSMEM_HELPERS_DEFERRED in the Kconfig file.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 409e02130be0f..e234e90d06b83 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 15/32] fbdev/udlfb: Select correct helpers
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (13 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 14/32] fbdev/smscufx: Select correct helpers Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:46   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 16/32] fbdev/au1200fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
                   ` (16 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

The driver uses deferred I/O. Select the correct helpers via
FB_SYSMEM_HELPERS_DEFERRED in the Kconfig file.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index e234e90d06b83..8c38969e9468a 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 16/32] fbdev/au1200fb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (14 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 15/32] fbdev/udlfb: " Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:47   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 17/32] fbdev/au1200fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (15 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

The 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/au1200fb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index 98afd385c49cd..817c1ebb625b6 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -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);
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 17/32] fbdev/au1200fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (15 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 16/32] fbdev/au1200fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:48   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 18/32] fbdev/ps3fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
                   ` (14 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig    | 5 +----
 drivers/video/fbdev/au1200fb.c | 7 ++-----
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 8c38969e9468a..2445cbca85579 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index 817c1ebb625b6..16ebbab500972 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -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,
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 18/32] fbdev/ps3fb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (16 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 17/32] fbdev/au1200fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:48   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 19/32] fbdev/ps3fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (13 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Michael Ellerman, dri-devel, Christophe Leroy,
	Nicholas Piggin, Thomas Zimmermann, linuxppc-dev

The ps3fb driver operates on system memory. Mark the framebuffer
accordingly. Helpers operating on the framebuffer memory will test
for the presence of this flag.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/video/fbdev/ps3fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
index 64d291d6b1532..de81ad3a5d1ed 100644
--- a/drivers/video/fbdev/ps3fb.c
+++ b/drivers/video/fbdev/ps3fb.c
@@ -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);
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 19/32] fbdev/ps3fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (17 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 18/32] fbdev/ps3fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 10:53   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
                   ` (12 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Michael Ellerman, dri-devel, Christophe Leroy,
	Nicholas Piggin, Thomas Zimmermann, linuxppc-dev

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/video/fbdev/Kconfig | 5 +----
 drivers/video/fbdev/ps3fb.c | 7 ++-----
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 2445cbca85579..812b3a9a49507 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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.
 
diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
index de81ad3a5d1ed..de8d78bf070a0 100644
--- a/drivers/video/fbdev/ps3fb.c
+++ b/drivers/video/fbdev/ps3fb.c
@@ -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,
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (18 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 19/32] fbdev/ps3fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:26   ` Javier Martinez Canillas
  2023-11-20  8:52   ` Hans Verkuil
  2023-11-15 10:19 ` [PATCH 21/32] fbdev/clps711x-fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (11 subsequent siblings)
  31 siblings, 2 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Andy Walls, dri-devel, Thomas Zimmermann,
	Mauro Carvalho Chehab, linux-media

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
---
 drivers/media/pci/ivtv/Kconfig  | 4 +---
 drivers/media/pci/ivtv/ivtvfb.c | 6 +++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ivtv/Kconfig b/drivers/media/pci/ivtv/Kconfig
index 9be52101bc4f2..2498f9079b756 100644
--- a/drivers/media/pci/ivtv/Kconfig
+++ b/drivers/media/pci/ivtv/Kconfig
@@ -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.
diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
index 23c8c094e791b..410477e3e6216 100644
--- a/drivers/media/pci/ivtv/ivtvfb.c
+++ b/drivers/media/pci/ivtv/ivtvfb.c
@@ -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 */
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 21/32] fbdev/clps711x-fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (19 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:28   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 22/32] fbdev/vt8500lcdfb: " Thomas Zimmermann
                   ` (10 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig       | 4 +---
 drivers/video/fbdev/clps711x-fb.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 812b3a9a49507..76dc1a0081c17 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/clps711x-fb.c b/drivers/video/fbdev/clps711x-fb.c
index e956c90efcdcc..dcfd1fbbc7e10 100644
--- a/drivers/video/fbdev/clps711x-fb.c
+++ b/drivers/video/fbdev/clps711x-fb.c
@@ -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)
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 22/32] fbdev/vt8500lcdfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (20 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 21/32] fbdev/clps711x-fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:30   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 23/32] fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
                   ` (9 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig       | 1 +
 drivers/video/fbdev/vt8500lcdfb.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 76dc1a0081c17..658848475fa7a 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/vt8500lcdfb.c b/drivers/video/fbdev/vt8500lcdfb.c
index 42d39a9d5130f..42c25dc851976 100644
--- a/drivers/video/fbdev/vt8500lcdfb.c
+++ b/drivers/video/fbdev/vt8500lcdfb.c
@@ -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,
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 23/32] fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (21 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 22/32] fbdev/vt8500lcdfb: " Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:34   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 24/32] fbdev/cyber2000fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (8 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig    | 1 +
 drivers/video/fbdev/wm8505fb.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 658848475fa7a..357c125c11204 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/wm8505fb.c b/drivers/video/fbdev/wm8505fb.c
index 5833147aa43d1..00952e9c88028 100644
--- a/drivers/video/fbdev/wm8505fb.c
+++ b/drivers/video/fbdev/wm8505fb.c
@@ -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)
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 24/32] fbdev/cyber2000fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (22 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 23/32] fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:35   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 25/32] staging/sm750fb: Declare fb_ops as constant Thomas Zimmermann
                   ` (7 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-arm-kernel, linux-fbdev, Thomas Zimmermann, dri-devel,
	Russell King

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/video/fbdev/Kconfig       | 5 +----
 drivers/video/fbdev/cyber2000fb.c | 9 +--------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 357c125c11204..07eccd05390f2 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/cyber2000fb.c b/drivers/video/fbdev/cyber2000fb.c
index 52105dc1a72f3..abb87d3576db0 100644
--- a/drivers/video/fbdev/cyber2000fb.c
+++ b/drivers/video/fbdev/cyber2000fb.c
@@ -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,
 };
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 25/32] staging/sm750fb: Declare fb_ops as constant
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (23 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 24/32] fbdev/cyber2000fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:44   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
                   ` (6 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Teddy Wang, Greg Kroah-Hartman, linux-staging,
	dri-devel, Thomas Zimmermann, Sudip Mukherjee

Split 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Teddy Wang <teddy.wang@siliconmotion.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev
---
 drivers/staging/sm750fb/sm750.c | 59 +++++++++++++++++++++++++++------
 1 file changed, 49 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 79bcd5bd49380..35098516f53c9 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -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;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (24 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 25/32] staging/sm750fb: Declare fb_ops as constant Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:57   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 27/32] fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS Thomas Zimmermann
                   ` (5 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm
  Cc: linux-fbdev, Teddy Wang, Greg Kroah-Hartman, linux-staging,
	dri-devel, Thomas Zimmermann, Sudip Mukherjee

Initialize 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Teddy Wang <teddy.wang@siliconmotion.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev
---
 drivers/staging/sm750fb/sm750.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 35098516f53c9..04c1b32a22c5e 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -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)
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 27/32] fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (25 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 12:05   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 28/32] fbdev: Remove trailing whitespaces Thomas Zimmermann
                   ` (4 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Rename the token to harmonize naming among various helpers. For
example, I/O-memory helpers use FB_IOMEM_FOPS.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/Kconfig       | 4 ++--
 drivers/video/fbdev/core/Kconfig  | 6 +++---
 drivers/video/fbdev/core/Makefile | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 07eccd05390f2..63600497dc330 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/core/Kconfig b/drivers/video/fbdev/core/Kconfig
index 7a3ed13bed708..faab5d50cac3c 100644
--- a/drivers/video/fbdev/core/Kconfig
+++ b/drivers/video/fbdev/core/Kconfig
@@ -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
diff --git a/drivers/video/fbdev/core/Makefile b/drivers/video/fbdev/core/Makefile
index c1d657601b2be..d159747590869 100644
--- a/drivers/video/fbdev/core/Makefile
+++ b/drivers/video/fbdev/core/Makefile
@@ -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
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 28/32] fbdev: Remove trailing whitespaces
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (26 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 27/32] fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 11:57   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 29/32] fbdev: Push pgprot_decrypted() into mmap implementations Thomas Zimmermann
                   ` (3 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Fix coding style. No functional changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/sbuslib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/sbuslib.c b/drivers/video/fbdev/sbuslib.c
index 21e9fd8e69e26..4d524db5c4f26 100644
--- a/drivers/video/fbdev/sbuslib.c
+++ b/drivers/video/fbdev/sbuslib.c
@@ -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;
 			}
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 29/32] fbdev: Push pgprot_decrypted() into mmap implementations
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (27 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 28/32] fbdev: Remove trailing whitespaces Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 13:04   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 30/32] fbdev: Move default fb_mmap code into helper function Thomas Zimmermann
                   ` (2 subsequent siblings)
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

If 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 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(-)

diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
index ede0f9a513110..5ba19c339f088 100644
--- a/drivers/auxdisplay/cfag12864bfb.c
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -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);
 }
 
diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
index 2f1dc6b4e2765..a90430b7d07ba 100644
--- a/drivers/auxdisplay/ht16k33.c
+++ b/drivers/auxdisplay/ht16k33.c
@@ -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);
 }
 
diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index 0399db369e709..47d373f04f3f0 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -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);
 }
diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c
index a9c8d33a6ef71..08109ce535cd4 100644
--- a/drivers/video/fbdev/au1100fb.c
+++ b/drivers/video/fbdev/au1100fb.c
@@ -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,
diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index 16ebbab500972..6f20efc663d7e 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -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);
 }
diff --git a/drivers/video/fbdev/core/fb_chrdev.c b/drivers/video/fbdev/core/fb_chrdev.c
index 32a7315b4b6dd..b73a122950a94 100644
--- a/drivers/video/fbdev/core/fb_chrdev.c
+++ b/drivers/video/fbdev/core/fb_chrdev.c
@@ -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;
diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index 274f5d0fa2471..1b0b85e59e5e1 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -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))
diff --git a/drivers/video/fbdev/ep93xx-fb.c b/drivers/video/fbdev/ep93xx-fb.c
index cae00deee0014..3e378874ccc79 100644
--- a/drivers/video/fbdev/ep93xx-fb.c
+++ b/drivers/video/fbdev/ep93xx-fb.c
@@ -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);
diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c
index e89e5579258ef..8463de833d1e1 100644
--- a/drivers/video/fbdev/gbefb.c
+++ b/drivers/video/fbdev/gbefb.c
@@ -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;
diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c
index 42c96f1cfc93c..e35c8dbc5a535 100644
--- a/drivers/video/fbdev/omap/omapfb_main.c
+++ b/drivers/video/fbdev/omap/omapfb_main.c
@@ -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);
diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
index c9fd0ad352d7f..0db9c55fce5a2 100644
--- a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
@@ -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);
diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
index de8d78bf070a0..dbcda307f6a67 100644
--- a/drivers/video/fbdev/ps3fb.c
+++ b/drivers/video/fbdev/ps3fb.c
@@ -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",
diff --git a/drivers/video/fbdev/sa1100fb.c b/drivers/video/fbdev/sa1100fb.c
index befd3fe2f6596..0d362d2bf0e38 100644
--- a/drivers/video/fbdev/sa1100fb.c
+++ b/drivers/video/fbdev/sa1100fb.c
@@ -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,
diff --git a/drivers/video/fbdev/sbuslib.c b/drivers/video/fbdev/sbuslib.c
index 4d524db5c4f26..634e3d159452c 100644
--- a/drivers/video/fbdev/sbuslib.c
+++ b/drivers/video/fbdev/sbuslib.c
@@ -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 */
diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index d84628de51893..eb2297b37504c 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -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);
 }
diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 90a77d19b236b..35d682b110c42 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -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)
diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 2460ff4ac86b4..1514ddac4cafc 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -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)
diff --git a/drivers/video/fbdev/vermilion/vermilion.c b/drivers/video/fbdev/vermilion/vermilion.c
index 840ead69654b8..a087b42ca652f 100644
--- a/drivers/video/fbdev/vermilion/vermilion.c
+++ b/drivers/video/fbdev/vermilion/vermilion.c
@@ -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;
diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c
index f6140f247e4b0..f86149ba38352 100644
--- a/drivers/video/fbdev/vfb.c
+++ b/drivers/video/fbdev/vfb.c
@@ -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);
 }
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 30/32] fbdev: Move default fb_mmap code into helper function
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (28 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 29/32] fbdev: Push pgprot_decrypted() into mmap implementations Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 13:10   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 31/32] fbdev: Warn on incorrect framebuffer access Thomas Zimmermann
  2023-11-15 10:19 ` [PATCH 32/32] fbdev: Remove default file-I/O implementations Thomas Zimmermann
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Move 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 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(-)

diff --git a/drivers/video/fbdev/core/fb_chrdev.c b/drivers/video/fbdev/core/fb_chrdev.c
index b73a122950a94..089441c9d810f 100644
--- a/drivers/video/fbdev/core/fb_chrdev.c
+++ b/drivers/video/fbdev/core/fb_chrdev.c
@@ -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)
diff --git a/drivers/video/fbdev/core/fb_io_fops.c b/drivers/video/fbdev/core/fb_io_fops.c
index 871b829521af3..60805e43914e5 100644
--- a/drivers/video/fbdev/core/fb_io_fops.c
+++ b/drivers/video/fbdev/core/fb_io_fops.c
@@ -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");
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 94e2c44c65699..a36d05b576b0c 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -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, \
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 31/32] fbdev: Warn on incorrect framebuffer access
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (29 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 30/32] fbdev: Move default fb_mmap code into helper function Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 13:12   ` Javier Martinez Canillas
  2023-11-15 10:19 ` [PATCH 32/32] fbdev: Remove default file-I/O implementations Thomas Zimmermann
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Test 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 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(-)

diff --git a/drivers/video/fbdev/core/cfbcopyarea.c b/drivers/video/fbdev/core/cfbcopyarea.c
index 5b80bf3dae504..a271f57d9c6c1 100644
--- a/drivers/video/fbdev/core/cfbcopyarea.c
+++ b/drivers/video/fbdev/core/cfbcopyarea.c
@@ -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)) {
diff --git a/drivers/video/fbdev/core/cfbfillrect.c b/drivers/video/fbdev/core/cfbfillrect.c
index ba9f58b2a5e86..cbaa4c9e2355a 100644
--- a/drivers/video/fbdev/core/cfbfillrect.c
+++ b/drivers/video/fbdev/core/cfbfillrect.c
@@ -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];
diff --git a/drivers/video/fbdev/core/cfbimgblt.c b/drivers/video/fbdev/core/cfbimgblt.c
index 9ebda4e0dc7ab..7d1d2f1a627dc 100644
--- a/drivers/video/fbdev/core/cfbimgblt.c
+++ b/drivers/video/fbdev/core/cfbimgblt.c
@@ -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;
diff --git a/drivers/video/fbdev/core/fb_io_fops.c b/drivers/video/fbdev/core/fb_io_fops.c
index 60805e43914e5..3408ff1b2b7a0 100644
--- a/drivers/video/fbdev/core/fb_io_fops.c
+++ b/drivers/video/fbdev/core/fb_io_fops.c
@@ -12,6 +12,9 @@ ssize_t fb_io_read(struct fb_info *info, char __user *buf, size_t count, loff_t
 	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;
 
@@ -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.
diff --git a/drivers/video/fbdev/core/fb_sys_fops.c b/drivers/video/fbdev/core/fb_sys_fops.c
index 0cb0989abda61..a9aa6519a5b30 100644
--- a/drivers/video/fbdev/core/fb_sys_fops.c
+++ b/drivers/video/fbdev/core/fb_sys_fops.c
@@ -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;
 
diff --git a/drivers/video/fbdev/core/syscopyarea.c b/drivers/video/fbdev/core/syscopyarea.c
index 7b8bd3a2bedc5..75e7001e8450f 100644
--- a/drivers/video/fbdev/core/syscopyarea.c
+++ b/drivers/video/fbdev/core/syscopyarea.c
@@ -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)) {
diff --git a/drivers/video/fbdev/core/sysfillrect.c b/drivers/video/fbdev/core/sysfillrect.c
index bcdcaeae6538c..e49221a88ccc7 100644
--- a/drivers/video/fbdev/core/sysfillrect.c
+++ b/drivers/video/fbdev/core/sysfillrect.c
@@ -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];
diff --git a/drivers/video/fbdev/core/sysimgblt.c b/drivers/video/fbdev/core/sysimgblt.c
index 665ef7a0a2495..6949bbd51d920 100644
--- a/drivers/video/fbdev/core/sysimgblt.c
+++ b/drivers/video/fbdev/core/sysimgblt.c
@@ -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;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index a36d05b576b0c..24f0ec3662352 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -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 */
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 32/32] fbdev: Remove default file-I/O implementations
  2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
                   ` (30 preceding siblings ...)
  2023-11-15 10:19 ` [PATCH 31/32] fbdev: Warn on incorrect framebuffer access Thomas Zimmermann
@ 2023-11-15 10:19 ` Thomas Zimmermann
  2023-11-16 13:15   ` Javier Martinez Canillas
  31 siblings, 1 reply; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-15 10:19 UTC (permalink / raw)
  To: deller, javierm; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Drop 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/core/Kconfig     |  1 -
 drivers/video/fbdev/core/fb_chrdev.c | 37 +++++++++-------------------
 2 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/video/fbdev/core/Kconfig b/drivers/video/fbdev/core/Kconfig
index faab5d50cac3c..21053bf00dc58 100644
--- a/drivers/video/fbdev/core/Kconfig
+++ b/drivers/video/fbdev/core/Kconfig
@@ -4,7 +4,6 @@
 #
 
 config FB_CORE
-	select FB_IOMEM_FOPS
 	select VIDEO_CMDLINE
 	tristate
 
diff --git a/drivers/video/fbdev/core/fb_chrdev.c b/drivers/video/fbdev/core/fb_chrdev.c
index 089441c9d810f..118ab7884285a 100644
--- a/drivers/video/fbdev/core/fb_chrdev.c
+++ b/drivers/video/fbdev/core/fb_chrdev.c
@@ -34,13 +34,13 @@ static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_t
 	if (!info)
 		return -ENODEV;
 
+	if (!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 (!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 (!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;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* Re: [PATCH 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro
  2023-11-15 10:19 ` [PATCH 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro Thomas Zimmermann
@ 2023-11-16  9:45   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16  9:45 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Arnd Bergmann, stable, dri-devel, Thomas Zimmermann,
	Sam Ravnborg

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Fix build by using the correct name for the initializer macro
> for struct fb_ops.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: 9037afde8b9d ("fbdev/acornfb: Use fbdev I/O helpers")
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Javier Martinez Canillas <javierm@redhat.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: <stable@vger.kernel.org> # v6.6+
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 02/32] fbdev/sm712fb: Use correct initializer macros for struct fb_ops
  2023-11-15 10:19 ` [PATCH 02/32] fbdev/sm712fb: Use correct initializer macros for struct fb_ops Thomas Zimmermann
@ 2023-11-16  9:46   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16  9:46 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Teddy Wang, Arnd Bergmann, dri-devel,
	Thomas Zimmermann, Sam Ravnborg, Sudip Mukherjee

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Only 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')
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: 586132cf1d38 ("fbdev/sm712fb: Initialize fb_ops to fbdev I/O-memory helpers")
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Javier Martinez Canillas <javierm@redhat.com>
> Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> Cc: Teddy Wang <teddy.wang@siliconmotion.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-fbdev@vger.kernel.org
> ---
>  drivers/video/fbdev/sm712fb.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 03/32] fbdev/vfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 03/32] fbdev/vfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-16 10:00   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:00 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The vfb driver operates on system memory. Mark the framebuffer
> accordingly. Helpers operating on the framebuffer memory will test
> for the presence of this flag.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/32] fbdev/vfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 04/32] fbdev/vfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 10:04   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:04 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 05/32] fbdev/arcfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 05/32] fbdev/arcfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-16 10:05   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:05 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Thomas Zimmermann, dri-devel, Jaya Kumar

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The arcfb driver operates on system memory. Mark the framebuffer
> accordingly. Helpers operating on the framebuffer memory will test
> for the presence of this flag.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Jaya Kumar <jayalk@intworks.biz>
> ---
>  drivers/video/fbdev/arcfb.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 06/32] fbdev/arcfb: Use generator macros for deferred I/O
  2023-11-15 10:19 ` [PATCH 06/32] fbdev/arcfb: Use generator macros for deferred I/O Thomas Zimmermann
@ 2023-11-16 10:16   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:16 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, dri-devel, Thomas Zimmermann, Jaya Kumar

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Implement 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Jaya Kumar <jayalk@intworks.biz>
> ---
>  drivers/video/fbdev/Kconfig |   5 +-
>  drivers/video/fbdev/arcfb.c | 113 +++++++++---------------------------
>  2 files changed, 27 insertions(+), 91 deletions(-)
>

The patch looks good to me from a high level point of view but it's not
trivial so it would be good if Jaya Kumar can review / test it as well.

Acked-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-16 10:16   ` Javier Martinez Canillas
  2023-11-21 23:44   ` Miguel Ojeda
  1 sibling, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:16 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: Miguel Ojeda, linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The cfag12864bfb driver operates on system memory. Mark the framebuffer
> accordingly. Helpers operating on the framebuffer memory will test for
> the presence of this flag.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> ---
>  drivers/auxdisplay/cfag12864bfb.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 10:22   ` Javier Martinez Canillas
  2023-11-21 23:45   ` Miguel Ojeda
  1 sibling, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:22 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: Miguel Ojeda, linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> ---
>  drivers/auxdisplay/Kconfig        | 5 +----
>  drivers/auxdisplay/cfag12864bfb.c | 7 ++-----
>  2 files changed, 3 insertions(+), 9 deletions(-)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-16 10:23   ` Javier Martinez Canillas
  2023-11-21 23:50   ` Miguel Ojeda
  2023-11-22  7:42   ` Robin van der Gracht
  2 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:23 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: Miguel Ojeda, Robin van der Gracht, linux-fbdev,
	Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The ht16k33 driver operates on system memory. Mark the framebuffer
> accordingly. Helpers operating on the framebuffer memory will test
> for the presence of this flag.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> Cc: Robin van der Gracht <robin@protonic.nl>
> ---
>  drivers/auxdisplay/ht16k33.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 10:23   ` Javier Martinez Canillas
  2023-11-21 23:45   ` Miguel Ojeda
  2023-11-22  7:47   ` Robin van der Gracht
  2 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:23 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: Miguel Ojeda, Robin van der Gracht, linux-fbdev,
	Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> Cc: Robin van der Gracht <robin@protonic.nl>
> ---
>  drivers/auxdisplay/Kconfig   | 5 +----
>  drivers/auxdisplay/ht16k33.c | 7 ++-----
>  2 files changed, 3 insertions(+), 9 deletions(-)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-16 10:27   ` Javier Martinez Canillas
  2023-11-17  8:51     ` Bruno Prémont
  2023-11-21  8:42   ` Jiri Kosina
  1 sibling, 1 reply; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:27 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Jiri Kosina, dri-devel, Bruno Prémont,
	Benjamin Tissoires, Thomas Zimmermann, linux-input

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: "Bruno Prémont" <bonbons@linux-vserver.org>
> Cc: Jiri Kosina <jikos@kernel.org>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: linux-input@vger.kernel.org
> ---
>  drivers/hid/hid-picolcd_fb.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 12/32] fbdev/sh_mobile_lcdcfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 12/32] fbdev/sh_mobile_lcdcfb: " Thomas Zimmermann
@ 2023-11-16 10:29   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:29 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 13/32] fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 13/32] fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 10:45   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:45 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 14/32] fbdev/smscufx: Select correct helpers
  2023-11-15 10:19 ` [PATCH 14/32] fbdev/smscufx: Select correct helpers Thomas Zimmermann
@ 2023-11-16 10:46   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:46 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The driver uses deferred I/O. Select the correct helpers via
> FB_SYSMEM_HELPERS_DEFERRED in the Kconfig file.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 15/32] fbdev/udlfb: Select correct helpers
  2023-11-15 10:19 ` [PATCH 15/32] fbdev/udlfb: " Thomas Zimmermann
@ 2023-11-16 10:46   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:46 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The driver uses deferred I/O. Select the correct helpers via
> FB_SYSMEM_HELPERS_DEFERRED in the Kconfig file.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 16/32] fbdev/au1200fb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 16/32] fbdev/au1200fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-16 10:47   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:47 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 17/32] fbdev/au1200fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 17/32] fbdev/au1200fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 10:48   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:48 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 18/32] fbdev/ps3fb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 18/32] fbdev/ps3fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
@ 2023-11-16 10:48   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:48 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Michael Ellerman, dri-devel, Nicholas Piggin,
	Christophe Leroy, Thomas Zimmermann, linuxppc-dev

Thomas Zimmermann <tzimmermann@suse.de> writes:

> The ps3fb driver operates on system memory. Mark the framebuffer
> accordingly. Helpers operating on the framebuffer memory will test
> for the presence of this flag.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
>  drivers/video/fbdev/ps3fb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 19/32] fbdev/ps3fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 19/32] fbdev/ps3fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 10:53   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 10:53 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Michael Ellerman, dri-devel, Christophe Leroy,
	Nicholas Piggin, Thomas Zimmermann, linuxppc-dev

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
>  drivers/video/fbdev/Kconfig | 5 +----
>  drivers/video/fbdev/ps3fb.c | 7 ++-----
>  2 files changed, 3 insertions(+), 9 deletions(-)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers
  2023-11-15 10:19 ` [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
@ 2023-11-16 11:26   ` Javier Martinez Canillas
  2023-11-20  8:52   ` Hans Verkuil
  1 sibling, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:26 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Andy Walls, dri-devel, Thomas Zimmermann,
	Mauro Carvalho Chehab, linux-media

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Andy Walls <awalls@md.metrocast.net>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: linux-media@vger.kernel.org
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 21/32] fbdev/clps711x-fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 21/32] fbdev/clps711x-fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 11:28   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:28 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 22/32] fbdev/vt8500lcdfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 22/32] fbdev/vt8500lcdfb: " Thomas Zimmermann
@ 2023-11-16 11:30   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:30 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 23/32] fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers
  2023-11-15 10:19 ` [PATCH 23/32] fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
@ 2023-11-16 11:34   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:34 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 24/32] fbdev/cyber2000fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 24/32] fbdev/cyber2000fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 11:35   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:35 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-arm-kernel, linux-fbdev, Thomas Zimmermann, dri-devel,
	Russell King

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 25/32] staging/sm750fb: Declare fb_ops as constant
  2023-11-15 10:19 ` [PATCH 25/32] staging/sm750fb: Declare fb_ops as constant Thomas Zimmermann
@ 2023-11-16 11:44   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:44 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Teddy Wang, Greg Kroah-Hartman, linux-staging,
	dri-devel, Thomas Zimmermann, Sudip Mukherjee

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Split 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> Cc: Teddy Wang <teddy.wang@siliconmotion.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-staging@lists.linux.dev
> ---
>  drivers/staging/sm750fb/sm750.c | 59 +++++++++++++++++++++++++++------
>  1 file changed, 49 insertions(+), 10 deletions(-)
>

Same than patch patch #6, the change is less trivial and would be great if
someone with the hardware can test/review. But the patch looks good to me:

Acked-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
@ 2023-11-16 11:57   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:57 UTC (permalink / raw)
  To: Thomas Zimmermann, deller
  Cc: linux-fbdev, Teddy Wang, Greg Kroah-Hartman, linux-staging,
	dri-devel, Thomas Zimmermann, Sudip Mukherjee

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> Cc: Teddy Wang <teddy.wang@siliconmotion.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-staging@lists.linux.dev
> ---
>  drivers/staging/sm750fb/sm750.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 28/32] fbdev: Remove trailing whitespaces
  2023-11-15 10:19 ` [PATCH 28/32] fbdev: Remove trailing whitespaces Thomas Zimmermann
@ 2023-11-16 11:57   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 11:57 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Fix coding style. No functional changes.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 27/32] fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS
  2023-11-15 10:19 ` [PATCH 27/32] fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS Thomas Zimmermann
@ 2023-11-16 12:05   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 12:05 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Rename the token to harmonize naming among various helpers. For
> example, I/O-memory helpers use FB_IOMEM_FOPS.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

I wonder if the object names should also be changed to fb_iomem_fops.o
and fb_sysmem_fops.o for consistency with the Kconfig symbols names.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 29/32] fbdev: Push pgprot_decrypted() into mmap implementations
  2023-11-15 10:19 ` [PATCH 29/32] fbdev: Push pgprot_decrypted() into mmap implementations Thomas Zimmermann
@ 2023-11-16 13:04   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 13:04 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, Thomas Zimmermann, dri-devel

Thomas Zimmermann <tzimmermann@suse.de> writes:

> If 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 30/32] fbdev: Move default fb_mmap code into helper function
  2023-11-15 10:19 ` [PATCH 30/32] fbdev: Move default fb_mmap code into helper function Thomas Zimmermann
@ 2023-11-16 13:10   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 13:10 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Move 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 31/32] fbdev: Warn on incorrect framebuffer access
  2023-11-15 10:19 ` [PATCH 31/32] fbdev: Warn on incorrect framebuffer access Thomas Zimmermann
@ 2023-11-16 13:12   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 13:12 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Test 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 32/32] fbdev: Remove default file-I/O implementations
  2023-11-15 10:19 ` [PATCH 32/32] fbdev: Remove default file-I/O implementations Thomas Zimmermann
@ 2023-11-16 13:15   ` Javier Martinez Canillas
  0 siblings, 0 replies; 77+ messages in thread
From: Javier Martinez Canillas @ 2023-11-16 13:15 UTC (permalink / raw)
  To: Thomas Zimmermann, deller; +Cc: linux-fbdev, dri-devel, Thomas Zimmermann

Thomas Zimmermann <tzimmermann@suse.de> writes:

> Drop 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---

[...]

> @@ -34,13 +34,13 @@ static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_t
>  	if (!info)
>  		return -ENODEV;
>  
> +	if (!info->fbops->fb_read)
> +		return -EINVAL;
> +

Can we also add a warn here? In case that it was missed to set a driver
callback. Probably can be figured out from the -EINVAL but better to be
explicit about the issue to make finding that easier.

And same for the other fops.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag
  2023-11-16 10:27   ` Javier Martinez Canillas
@ 2023-11-17  8:51     ` Bruno Prémont
  0 siblings, 0 replies; 77+ messages in thread
From: Bruno Prémont @ 2023-11-17  8:51 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: linux-fbdev, deller, Jiri Kosina, dri-devel, Bruno Prémont,
	Benjamin Tissoires, Thomas Zimmermann, linux-input

On Thu, 16 Nov 2023 11:27:55 +0100 Javier Martinez Canillas wrote:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
> 
> > The 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.
> >
> > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: "Bruno Prémont" <bonbons@linux-vserver.org>
> > Cc: Jiri Kosina <jikos@kernel.org>
> > Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> > Cc: linux-input@vger.kernel.org
> > ---
> >  drivers/hid/hid-picolcd_fb.c | 1 +
> >  1 file changed, 1 insertion(+)
> >  
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Acked-by: Bruno Prémont  <bonbons@linux-vserver.org>

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers
  2023-11-15 10:19 ` [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
  2023-11-16 11:26   ` Javier Martinez Canillas
@ 2023-11-20  8:52   ` Hans Verkuil
  2023-11-20 11:29     ` Thomas Zimmermann
  1 sibling, 1 reply; 77+ messages in thread
From: Hans Verkuil @ 2023-11-20  8:52 UTC (permalink / raw)
  To: Thomas Zimmermann, deller, javierm
  Cc: linux-fbdev, Andy Walls, Mauro Carvalho Chehab, dri-devel, linux-media

Hi Thomas,

On 15/11/2023 11:19, Thomas Zimmermann wrote:
> Initialize 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.

Makes sense, shall I pick up this patch?

If you prefer to take it, then you can add:

Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Regards,

	Hans

> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Andy Walls <awalls@md.metrocast.net>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: linux-media@vger.kernel.org
> ---
>  drivers/media/pci/ivtv/Kconfig  | 4 +---
>  drivers/media/pci/ivtv/ivtvfb.c | 6 +++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/pci/ivtv/Kconfig b/drivers/media/pci/ivtv/Kconfig
> index 9be52101bc4f2..2498f9079b756 100644
> --- a/drivers/media/pci/ivtv/Kconfig
> +++ b/drivers/media/pci/ivtv/Kconfig
> @@ -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.
> diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
> index 23c8c094e791b..410477e3e6216 100644
> --- a/drivers/media/pci/ivtv/ivtvfb.c
> +++ b/drivers/media/pci/ivtv/ivtvfb.c
> @@ -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 */


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers
  2023-11-20  8:52   ` Hans Verkuil
@ 2023-11-20 11:29     ` Thomas Zimmermann
  0 siblings, 0 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-20 11:29 UTC (permalink / raw)
  To: Hans Verkuil, deller, javierm
  Cc: linux-fbdev, Andy Walls, Mauro Carvalho Chehab, dri-devel, linux-media


[-- Attachment #1.1: Type: text/plain, Size: 3239 bytes --]

Hi

Am 20.11.23 um 09:52 schrieb Hans Verkuil:
> Hi Thomas,
> 
> On 15/11/2023 11:19, Thomas Zimmermann wrote:
>> Initialize 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.
> 
> Makes sense, shall I pick up this patch?
> 
> If you prefer to take it, then you can add:
> 
> Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Thanks. The series' final patches depend on this one. I'd preferably 
merge it at once through drm-misc.

Best regards
Thomas

> 
> Regards,
> 
> 	Hans
> 
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: Andy Walls <awalls@md.metrocast.net>
>> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
>> Cc: linux-media@vger.kernel.org
>> ---
>>   drivers/media/pci/ivtv/Kconfig  | 4 +---
>>   drivers/media/pci/ivtv/ivtvfb.c | 6 +++---
>>   2 files changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/pci/ivtv/Kconfig b/drivers/media/pci/ivtv/Kconfig
>> index 9be52101bc4f2..2498f9079b756 100644
>> --- a/drivers/media/pci/ivtv/Kconfig
>> +++ b/drivers/media/pci/ivtv/Kconfig
>> @@ -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.
>> diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
>> index 23c8c094e791b..410477e3e6216 100644
>> --- a/drivers/media/pci/ivtv/ivtvfb.c
>> +++ b/drivers/media/pci/ivtv/ivtvfb.c
>> @@ -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 */
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
  2023-11-16 10:27   ` Javier Martinez Canillas
@ 2023-11-21  8:42   ` Jiri Kosina
  2023-11-21  8:56     ` Thomas Zimmermann
  1 sibling, 1 reply; 77+ messages in thread
From: Jiri Kosina @ 2023-11-21  8:42 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: linux-fbdev, deller, javierm, dri-devel, Bruno Prémont,
	Benjamin Tissoires, linux-input

On Wed, 15 Nov 2023, Thomas Zimmermann wrote:

> The 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.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: "Bruno Prémont" <bonbons@linux-vserver.org>
> Cc: Jiri Kosina <jikos@kernel.org>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: linux-input@vger.kernel.org

Acked-by: Jiri Kosina <jkosina@suse.cz>

I guess this will go in as one series together, right?

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag
  2023-11-21  8:42   ` Jiri Kosina
@ 2023-11-21  8:56     ` Thomas Zimmermann
  0 siblings, 0 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-21  8:56 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: linux-fbdev, deller, javierm, dri-devel, Bruno Prémont,
	Benjamin Tissoires, linux-input


[-- Attachment #1.1: Type: text/plain, Size: 954 bytes --]

Hi

Am 21.11.23 um 09:42 schrieb Jiri Kosina:
> On Wed, 15 Nov 2023, Thomas Zimmermann wrote:
> 
>> The 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.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: "Bruno Prémont" <bonbons@linux-vserver.org>
>> Cc: Jiri Kosina <jikos@kernel.org>
>> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>> Cc: linux-input@vger.kernel.org
> 
> Acked-by: Jiri Kosina <jkosina@suse.cz>
> 
> I guess this will go in as one series together, right?

Yes. I intend to move all this through the DRM trees.

Best regards
Thomas

> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
  2023-11-16 10:16   ` Javier Martinez Canillas
@ 2023-11-21 23:44   ` Miguel Ojeda
  1 sibling, 0 replies; 77+ messages in thread
From: Miguel Ojeda @ 2023-11-21 23:44 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: dri-devel, Miguel Ojeda, deller, javierm, linux-fbdev

On Wed, Nov 15, 2023 at 11:30 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> The cfag12864bfb driver operates on system memory. Mark the framebuffer
> accordingly. Helpers operating on the framebuffer memory will test for
> the presence of this flag.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>

Acked-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
  2023-11-16 10:22   ` Javier Martinez Canillas
@ 2023-11-21 23:45   ` Miguel Ojeda
  1 sibling, 0 replies; 77+ messages in thread
From: Miguel Ojeda @ 2023-11-21 23:45 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: dri-devel, Miguel Ojeda, deller, javierm, linux-fbdev

On Wed, Nov 15, 2023 at 11:30 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>

Acked-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros Thomas Zimmermann
  2023-11-16 10:23   ` Javier Martinez Canillas
@ 2023-11-21 23:45   ` Miguel Ojeda
  2023-11-22  7:47   ` Robin van der Gracht
  2 siblings, 0 replies; 77+ messages in thread
From: Miguel Ojeda @ 2023-11-21 23:45 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: linux-fbdev, Robin van der Gracht, deller, javierm, dri-devel,
	Miguel Ojeda

On Wed, Nov 15, 2023 at 11:30 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Initialize 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.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> Cc: Robin van der Gracht <robin@protonic.nl>

Acked-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag Thomas Zimmermann
  2023-11-16 10:23   ` Javier Martinez Canillas
@ 2023-11-21 23:50   ` Miguel Ojeda
  2023-11-22  9:03     ` Thomas Zimmermann
  2023-11-22  7:42   ` Robin van der Gracht
  2 siblings, 1 reply; 77+ messages in thread
From: Miguel Ojeda @ 2023-11-21 23:50 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: linux-fbdev, Robin van der Gracht, deller, javierm, dri-devel,
	Miguel Ojeda

On Wed, Nov 15, 2023 at 11:30 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> +       fbdev->info->flags |= FBINFO_VIRTFB;

Is the `|=` (instead of just `=`) used in case someone adds something
to the flags before (e.g. `fb_bl_default_curve`) or due to some other
reason? (One of the other patches uses `=`).

In any case, if that is intended:

Acked-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag
  2023-11-15 10:19 ` [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag Thomas Zimmermann
  2023-11-16 10:23   ` Javier Martinez Canillas
  2023-11-21 23:50   ` Miguel Ojeda
@ 2023-11-22  7:42   ` Robin van der Gracht
  2 siblings, 0 replies; 77+ messages in thread
From: Robin van der Gracht @ 2023-11-22  7:42 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: dri-devel, Miguel Ojeda, deller, javierm, linux-fbdev

On 2023-11-15 11:19, Thomas Zimmermann wrote:
> The ht16k33 driver operates on system memory. Mark the framebuffer
> accordingly. Helpers operating on the framebuffer memory will test
> for the presence of this flag.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> Cc: Robin van der Gracht <robin@protonic.nl>
> ---
>  drivers/auxdisplay/ht16k33.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/auxdisplay/ht16k33.c 
> b/drivers/auxdisplay/ht16k33.c
> index 3a2d883872249..f1716e3ce6a92 100644
> --- a/drivers/auxdisplay/ht16k33.c
> +++ b/drivers/auxdisplay/ht16k33.c
> @@ -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;

Acked-by: Robin van der Gracht <robin@protonic.nl>

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros
  2023-11-15 10:19 ` [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros Thomas Zimmermann
  2023-11-16 10:23   ` Javier Martinez Canillas
  2023-11-21 23:45   ` Miguel Ojeda
@ 2023-11-22  7:47   ` Robin van der Gracht
  2 siblings, 0 replies; 77+ messages in thread
From: Robin van der Gracht @ 2023-11-22  7:47 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: dri-devel, Miguel Ojeda, deller, javierm, linux-fbdev

On 2023-11-15 11:19, Thomas Zimmermann wrote:
> Initialize 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.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> Cc: Robin van der Gracht <robin@protonic.nl>
> ---
>  drivers/auxdisplay/Kconfig   | 5 +----
>  drivers/auxdisplay/ht16k33.c | 7 ++-----
>  2 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
> index 4377e53f8f572..d944d5298eca8 100644
> --- a/drivers/auxdisplay/Kconfig
> +++ b/drivers/auxdisplay/Kconfig
> @@ -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
> diff --git a/drivers/auxdisplay/ht16k33.c 
> b/drivers/auxdisplay/ht16k33.c
> index f1716e3ce6a92..2f1dc6b4e2765 100644
> --- a/drivers/auxdisplay/ht16k33.c
> +++ b/drivers/auxdisplay/ht16k33.c
> @@ -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,
>  };

Reviewed-by: Robin van der Gracht <robin@protonic.nl>

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag
  2023-11-21 23:50   ` Miguel Ojeda
@ 2023-11-22  9:03     ` Thomas Zimmermann
  0 siblings, 0 replies; 77+ messages in thread
From: Thomas Zimmermann @ 2023-11-22  9:03 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: linux-fbdev, Robin van der Gracht, deller, javierm, dri-devel,
	Miguel Ojeda


[-- Attachment #1.1: Type: text/plain, Size: 770 bytes --]

Hi

Am 22.11.23 um 00:50 schrieb Miguel Ojeda:
> On Wed, Nov 15, 2023 at 11:30 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>> +       fbdev->info->flags |= FBINFO_VIRTFB;
> 
> Is the `|=` (instead of just `=`) used in case someone adds something
> to the flags before (e.g. `fb_bl_default_curve`) or due to some other
> reason? (One of the other patches uses `=`).

Yes, it's intentionally.

> 
> In any case, if that is intended:
> 
> Acked-by: Miguel Ojeda <ojeda@kernel.org>

Thanks.

> 
> Cheers,
> Miguel

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 77+ messages in thread

end of thread, other threads:[~2023-11-22  9:03 UTC | newest]

Thread overview: 77+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 10:19 [PATCH 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
2023-11-15 10:19 ` [PATCH 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro Thomas Zimmermann
2023-11-16  9:45   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 02/32] fbdev/sm712fb: Use correct initializer macros for struct fb_ops Thomas Zimmermann
2023-11-16  9:46   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 03/32] fbdev/vfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-16 10:00   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 04/32] fbdev/vfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 10:04   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 05/32] fbdev/arcfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-16 10:05   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 06/32] fbdev/arcfb: Use generator macros for deferred I/O Thomas Zimmermann
2023-11-16 10:16   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-16 10:16   ` Javier Martinez Canillas
2023-11-21 23:44   ` Miguel Ojeda
2023-11-15 10:19 ` [PATCH 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 10:22   ` Javier Martinez Canillas
2023-11-21 23:45   ` Miguel Ojeda
2023-11-15 10:19 ` [PATCH 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-16 10:23   ` Javier Martinez Canillas
2023-11-21 23:50   ` Miguel Ojeda
2023-11-22  9:03     ` Thomas Zimmermann
2023-11-22  7:42   ` Robin van der Gracht
2023-11-15 10:19 ` [PATCH 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 10:23   ` Javier Martinez Canillas
2023-11-21 23:45   ` Miguel Ojeda
2023-11-22  7:47   ` Robin van der Gracht
2023-11-15 10:19 ` [PATCH 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-16 10:27   ` Javier Martinez Canillas
2023-11-17  8:51     ` Bruno Prémont
2023-11-21  8:42   ` Jiri Kosina
2023-11-21  8:56     ` Thomas Zimmermann
2023-11-15 10:19 ` [PATCH 12/32] fbdev/sh_mobile_lcdcfb: " Thomas Zimmermann
2023-11-16 10:29   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 13/32] fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 10:45   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 14/32] fbdev/smscufx: Select correct helpers Thomas Zimmermann
2023-11-16 10:46   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 15/32] fbdev/udlfb: " Thomas Zimmermann
2023-11-16 10:46   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 16/32] fbdev/au1200fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-16 10:47   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 17/32] fbdev/au1200fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 10:48   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 18/32] fbdev/ps3fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-16 10:48   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 19/32] fbdev/ps3fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 10:53   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
2023-11-16 11:26   ` Javier Martinez Canillas
2023-11-20  8:52   ` Hans Verkuil
2023-11-20 11:29     ` Thomas Zimmermann
2023-11-15 10:19 ` [PATCH 21/32] fbdev/clps711x-fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 11:28   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 22/32] fbdev/vt8500lcdfb: " Thomas Zimmermann
2023-11-16 11:30   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 23/32] fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
2023-11-16 11:34   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 24/32] fbdev/cyber2000fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 11:35   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 25/32] staging/sm750fb: Declare fb_ops as constant Thomas Zimmermann
2023-11-16 11:44   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-16 11:57   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 27/32] fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS Thomas Zimmermann
2023-11-16 12:05   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 28/32] fbdev: Remove trailing whitespaces Thomas Zimmermann
2023-11-16 11:57   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 29/32] fbdev: Push pgprot_decrypted() into mmap implementations Thomas Zimmermann
2023-11-16 13:04   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 30/32] fbdev: Move default fb_mmap code into helper function Thomas Zimmermann
2023-11-16 13:10   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 31/32] fbdev: Warn on incorrect framebuffer access Thomas Zimmermann
2023-11-16 13:12   ` Javier Martinez Canillas
2023-11-15 10:19 ` [PATCH 32/32] fbdev: Remove default file-I/O implementations Thomas Zimmermann
2023-11-16 13:15   ` Javier Martinez Canillas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).