Skip to contentSkip to conversation

fbdev: Use helpers for deferred I/O

PATCH In review Thomas Zimmermann 4 participants 24 messages Aug 28, 2023 – Sep 4, 2023

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover fbdev: Use helpers for deferred I/O

Here's another patchset for deferred-I/O helpers. Update a number of fbdev drivers with deferred I/O to use fbdev's helper macros and Kconfig tokens.

Generating and initializing via helpers macros will later allow for a fine-grained setup, depending on Kconfig options. For example, it will be possible to leave out file I/O if FB_DEVICE has not been set.

Each driver in special in its own way. The smscufx and udlfb drivers support file I/O without damage updates. (That probably doesn't work correctly.) So they provide their own mmap code. The hyperv_fb driver sometimes operates on memory in I/O address spaces and fails to do damage handling correctly for write operations. The picolcd and fbtft drivers are outside of fbdev.

Thomas Zimmermann (8):
fbdev/smscufx: Use fb_ops helpers for deferred I/O fbdev/udlfb: Use fb_ops helpers for deferred I/O
fbdev: Add Kconfig macro FB_IOMEM_HELPERS_DEFERRED fbdev/hyperv_fb: Use fb_ops helpers for deferred I/O
hid: Remove trailing whitespace
hid/picolcd: Use fb_ops helpers for deferred I/O staging/fbtft: Initialize fb_op struct as static const staging/fbtft: Use fb_ops helpers for deferred I/O

 drivers/hid/Kconfig                |  8 +--
 drivers/hid/hid-picolcd_fb.c       | 73 ++++++----------------
 drivers/staging/fbtft/Kconfig      |  6 +-
 drivers/staging/fbtft/fbtft-core.c | 99 ++++++++----------------------
 drivers/video/fbdev/Kconfig        |  5 +-
 drivers/video/fbdev/core/Kconfig   |  6 ++
 drivers/video/fbdev/hyperv_fb.c    | 48 +++++----------
 drivers/video/fbdev/smscufx.c      | 85 +++++++------------------
 drivers/video/fbdev/udlfb.c        | 89 +++++++--------------------
 9 files changed, 114 insertions(+), 305 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/8 fbdev/smscufx: Use fb_ops helpers for deferred I/O

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---
 drivers/video/fbdev/smscufx.c | 85 +++++++++--------------------------
 1 file changed, 22 insertions(+), 63 deletions(-)
drivers/video/fbdev/smscufx.c +22 -63
index 387d18706fec..90a77d19b236 100644
@@ -894,64 +894,6 @@ static int ufx_handle_damage(struct ufx_data *dev, int x, int y,
 	return 0;
 }
 
-/* Path triggered by usermode clients who write to filesystem
- * e.g. cat filename > /dev/fb1
- * Not used by X Windows or text-mode console. But useful for testing.
- * Slow because of extra copy and we must assume all pixels dirty. */
-static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	ssize_t result;
-	struct ufx_data *dev = info->par;
-	u32 offset = (u32) *ppos;
-
-	result = fb_sys_write(info, buf, count, ppos);
-
-	if (result > 0) {
-		int start = max((int)(offset / info->fix.line_length), 0);
-		int lines = min((u32)((result / info->fix.line_length) + 1),
-				(u32)info->var.yres);
-
-		ufx_handle_damage(dev, 0, start, info->var.xres, lines);
-	}
-
-	return result;
-}
-
-static void ufx_ops_copyarea(struct fb_info *info,
-				const struct fb_copyarea *area)
-{
-
-	struct ufx_data *dev = info->par;
-
-	sys_copyarea(info, area);
-
-	ufx_handle_damage(dev, area->dx, area->dy,
-			area->width, area->height);
-}
-
-static void ufx_ops_imageblit(struct fb_info *info,
-				const struct fb_image *image)
-{
-	struct ufx_data *dev = info->par;
-
-	sys_imageblit(info, image);
-
-	ufx_handle_damage(dev, image->dx, image->dy,
-			image->width, image->height);
-}
-
-static void ufx_ops_fillrect(struct fb_info *info,
-			  const struct fb_fillrect *rect)
-{
-	struct ufx_data *dev = info->par;
-
-	sys_fillrect(info, rect);
-
-	ufx_handle_damage(dev, rect->dx, rect->dy, rect->width,
-			      rect->height);
-}
-
 /* NOTE: fb_defio.c is holding info->fbdefio.mutex
  *   Touching ANY framebuffer memory that triggers a page fault
  *   in fb_defio will cause a deadlock, when it also tries to
@@ -1279,14 +1221,31 @@ static int ufx_ops_blank(int blank_mode, struct fb_info *info)
 	return 0;
 }
 
+static void ufx_ops_damage_range(struct fb_info *info, off_t off, size_t len)
+{
+	struct ufx_data *dev = info->par;
+	int start = max((int)(off / info->fix.line_length), 0);
+	int lines = min((u32)((len / info->fix.line_length) + 1), (u32)info->var.yres);
+
+	ufx_handle_damage(dev, 0, start, info->var.xres, lines);
+}
+
+static void ufx_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
+{
+	struct ufx_data *dev = info->par;
+
+	ufx_handle_damage(dev, x, y, width, height);
+}
+
+FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(ufx_ops,
+				   ufx_ops_damage_range,
+				   ufx_ops_damage_area)
+
 static const struct fb_ops ufx_ops = {
 	.owner = THIS_MODULE,
-	.fb_read = fb_sys_read,
-	.fb_write = ufx_ops_write,
+	__FB_DEFAULT_DEFERRED_OPS_RDWR(ufx_ops),
 	.fb_setcolreg = ufx_ops_setcolreg,
-	.fb_fillrect = ufx_ops_fillrect,
-	.fb_copyarea = ufx_ops_copyarea,
-	.fb_imageblit = ufx_ops_imageblit,
+	__FB_DEFAULT_DEFERRED_OPS_DRAW(ufx_ops),
 	.fb_mmap = ufx_ops_mmap,
 	.fb_ioctl = ufx_ops_ioctl,
 	.fb_open = ufx_ops_open,
Signature · 1 line
2.41.0
Acked-by on v1 1/8
#2 lore raw

Re: [PATCH 1/8] fbdev/smscufx: Use fb_ops helpers for deferred I/O

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 7 lines

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---

The patch looks good to me, but I've a question below.

Quoted 4 lines
 drivers/video/fbdev/smscufx.c | 85 +++++++++--------------------------
 1 file changed, 22 insertions(+), 63 deletions(-)
drivers/video/fbdev/smscufx.c +0 -0

[...]

drivers/video/fbdev/smscufx.c static int ufx_ops_blank(int blank_mode, struct fb_info *info) · line 1249

Quoted 11 lines

static const struct fb_ops ufx_ops = {

drivers/video/fbdev/smscufx.c +2 -5
 	.owner = THIS_MODULE,
-	.fb_read = fb_sys_read,
-	.fb_write = ufx_ops_write,
+	__FB_DEFAULT_DEFERRED_OPS_RDWR(ufx_ops),
 	.fb_setcolreg = ufx_ops_setcolreg,
-	.fb_fillrect = ufx_ops_fillrect,
-	.fb_copyarea = ufx_ops_copyarea,
-	.fb_imageblit = ufx_ops_imageblit,
+	__FB_DEFAULT_DEFERRED_OPS_DRAW(ufx_ops),
 	.fb_mmap = ufx_ops_mmap,

There are no generated functions for .fb_mmap, I wonder what's the value of __FB_DEFAULT_DEFERRED_OPS_MMAP() ? Maybe just removing that macro and setting .fb_mmap = fb_deferred_io_mmap instead if there's no custom mmap handler would be easier to read ?

Alternatively, __FB_DEFAULT_DEFERRED_OPS_MMAP() could still be left but not taking a __prefix argument since that is not used anyways ?

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#3 lore raw

Re: [PATCH 1/8] fbdev/smscufx: Use fb_ops helpers for deferred I/O

Hi Javier

Am 04.09.23 um 14:59 schrieb Javier Martinez Canillas:

Quoted 23 lines

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 7 lines

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---

The patch looks good to me, but I've a question below.

Quoted 4 lines
  drivers/video/fbdev/smscufx.c | 85 +++++++++--------------------------
  1 file changed, 22 insertions(+), 63 deletions(-)
drivers/video/fbdev/smscufx.c +0 -0

[...]

Quoted 16 lines

drivers/video/fbdev/smscufx.c static int ufx_ops_blank(int blank_mode, struct fb_info *info) · line 1249

Quoted 11 lines
  static const struct fb_ops ufx_ops = {
  	.owner = THIS_MODULE,
drivers/video/fbdev/smscufx.c +2 -5
-	.fb_read = fb_sys_read,
-	.fb_write = ufx_ops_write,
+	__FB_DEFAULT_DEFERRED_OPS_RDWR(ufx_ops),
  	.fb_setcolreg = ufx_ops_setcolreg,
-	.fb_fillrect = ufx_ops_fillrect,
-	.fb_copyarea = ufx_ops_copyarea,
-	.fb_imageblit = ufx_ops_imageblit,
+	__FB_DEFAULT_DEFERRED_OPS_DRAW(ufx_ops),
  	.fb_mmap = ufx_ops_mmap,

There are no generated functions for .fb_mmap, I wonder what's the value of __FB_DEFAULT_DEFERRED_OPS_MMAP() ? Maybe just removing that macro and setting .fb_mmap = fb_deferred_io_mmap instead if there's no custom mmap handler would be easier to read ?

At least two drivers could use __FB_DEFAULT_DEFERRED_OPS_MMAP: picolcd-fb and hyperv_fb. At some point, we might want to set/clear fb_mmap depending on some Kconfig value. Having __FB_DEFAULT_DEFERRED_OPS_MMAP might be helpful then.

Quoted 3 lines

Alternatively, __FB_DEFAULT_DEFERRED_OPS_MMAP() could still be left but not taking a __prefix argument since that is not used anyways ?

The driver optionally provides mmap without deferred I/O, hence the mmap function. That makes no sense, as these writes to the buffer would never make it to the device memory. But I didn't want to remove the code either. So I just left the existing function as-is. Usually, the deferred-I/O mmap is called immediately. [1]

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.5.1/source/drivers/video/fbdev/smscufx.c#L784

Quoted 1 line
Signature · 6 lines
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)
#4 lore raw

Re: [PATCH 1/8] fbdev/smscufx: Use fb_ops helpers for deferred I/O

Am 04.09.23 um 16:39 schrieb Thomas Zimmermann:
[...]

Quoted 1 line

At least two drivers could use __FB_DEFAULT_DEFERRED_OPS_MMAP: picolcd-fb and hyperv_fb. At some point, we might want to set/clear

Both drivers are already in this patchset.

Quoted 15 lines

fb_mmap depending on some Kconfig value. Having __FB_DEFAULT_DEFERRED_OPS_MMAP might be helpful then.

Quoted 3 lines

Alternatively, __FB_DEFAULT_DEFERRED_OPS_MMAP() could still be left but not taking a __prefix argument since that is not used anyways ?

The driver optionally provides mmap without deferred I/O, hence the mmap function. That makes no sense, as these writes to the buffer would never make it to the device memory. But I didn't want to remove the code either. So I just left the existing function as-is. Usually, the deferred-I/O mmap is called immediately. [1]

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.5.1/source/drivers/video/fbdev/smscufx.c#L784

Quoted 1 line
Signature · 6 lines
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)
#5 lore raw

Re: [PATCH 1/8] fbdev/smscufx: Use fb_ops helpers for deferred I/O

In reply to Thomas Zimmermann
Quoted 43 lines · Thomas Zimmermann

Hi Javier

Am 04.09.23 um 14:59 schrieb Javier Martinez Canillas:

Quoted 23 lines

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 7 lines

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---

The patch looks good to me, but I've a question below.

Quoted 4 lines
  drivers/video/fbdev/smscufx.c | 85 +++++++++--------------------------
  1 file changed, 22 insertions(+), 63 deletions(-)
drivers/video/fbdev/smscufx.c +0 -0

[...]

Quoted 16 lines

drivers/video/fbdev/smscufx.c static int ufx_ops_blank(int blank_mode, struct fb_info *info) · line 1249

Quoted 11 lines
  static const struct fb_ops ufx_ops = {
  	.owner = THIS_MODULE,
drivers/video/fbdev/smscufx.c +2 -5
-	.fb_read = fb_sys_read,
-	.fb_write = ufx_ops_write,
+	__FB_DEFAULT_DEFERRED_OPS_RDWR(ufx_ops),
  	.fb_setcolreg = ufx_ops_setcolreg,
-	.fb_fillrect = ufx_ops_fillrect,
-	.fb_copyarea = ufx_ops_copyarea,
-	.fb_imageblit = ufx_ops_imageblit,
+	__FB_DEFAULT_DEFERRED_OPS_DRAW(ufx_ops),
  	.fb_mmap = ufx_ops_mmap,

There are no generated functions for .fb_mmap, I wonder what's the value of __FB_DEFAULT_DEFERRED_OPS_MMAP() ? Maybe just removing that macro and setting .fb_mmap = fb_deferred_io_mmap instead if there's no custom mmap handler would be easier to read ?

Quoted 5 lines

At least two drivers could use __FB_DEFAULT_DEFERRED_OPS_MMAP:
picolcd-fb and hyperv_fb. At some point, we might want to set/clear fb_mmap depending on some Kconfig value. Having __FB_DEFAULT_DEFERRED_OPS_MMAP might be helpful then.

Got it, thanks for the explanation.

Quoted 10 lines
Quoted 3 lines

Alternatively, __FB_DEFAULT_DEFERRED_OPS_MMAP() could still be left but not taking a __prefix argument since that is not used anyways ?

The driver optionally provides mmap without deferred I/O, hence the mmap function. That makes no sense, as these writes to the buffer would never make it to the device memory. But I didn't want to remove the code either. So I just left the existing function as-is. Usually, the deferred-I/O mmap is called immediately. [1]

Makes sense.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#6 lore raw

PATCH 2/8 fbdev/udlfb: Use fb_ops helpers for deferred I/O

In reply to Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---
 drivers/video/fbdev/udlfb.c | 89 +++++++++----------------------------
 1 file changed, 22 insertions(+), 67 deletions(-)
drivers/video/fbdev/udlfb.c +22 -67
index b70762ead13c..2460ff4ac86b 100644
@@ -715,68 +715,6 @@ static void dlfb_offload_damage(struct dlfb_data *dlfb, int x, int y, int width,
 	schedule_work(&dlfb->damage_work);
 }
 
-/*
- * Path triggered by usermode clients who write to filesystem
- * e.g. cat filename > /dev/fb1
- * Not used by X Windows or text-mode console. But useful for testing.
- * Slow because of extra copy and we must assume all pixels dirty.
- */
-static ssize_t dlfb_ops_write(struct fb_info *info, const char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	ssize_t result;
-	struct dlfb_data *dlfb = info->par;
-	u32 offset = (u32) *ppos;
-
-	result = fb_sys_write(info, buf, count, ppos);
-
-	if (result > 0) {
-		int start = max((int)(offset / info->fix.line_length), 0);
-		int lines = min((u32)((result / info->fix.line_length) + 1),
-				(u32)info->var.yres);
-
-		dlfb_handle_damage(dlfb, 0, start, info->var.xres,
-			lines);
-	}
-
-	return result;
-}
-
-/* hardware has native COPY command (see libdlo), but not worth it for fbcon */
-static void dlfb_ops_copyarea(struct fb_info *info,
-				const struct fb_copyarea *area)
-{
-
-	struct dlfb_data *dlfb = info->par;
-
-	sys_copyarea(info, area);
-
-	dlfb_offload_damage(dlfb, area->dx, area->dy,
-			area->width, area->height);
-}
-
-static void dlfb_ops_imageblit(struct fb_info *info,
-				const struct fb_image *image)
-{
-	struct dlfb_data *dlfb = info->par;
-
-	sys_imageblit(info, image);
-
-	dlfb_offload_damage(dlfb, image->dx, image->dy,
-			image->width, image->height);
-}
-
-static void dlfb_ops_fillrect(struct fb_info *info,
-			  const struct fb_fillrect *rect)
-{
-	struct dlfb_data *dlfb = info->par;
-
-	sys_fillrect(info, rect);
-
-	dlfb_offload_damage(dlfb, rect->dx, rect->dy, rect->width,
-			      rect->height);
-}
-
 /*
  * NOTE: fb_defio.c is holding info->fbdefio.mutex
  *   Touching ANY framebuffer memory that triggers a page fault
@@ -1186,14 +1124,31 @@ static int dlfb_ops_blank(int blank_mode, struct fb_info *info)
 	return 0;
 }
 
+static void dlfb_ops_damage_range(struct fb_info *info, off_t off, size_t len)
+{
+	struct dlfb_data *dlfb = info->par;
+	int start = max((int)(off / info->fix.line_length), 0);
+	int lines = min((u32)((len / info->fix.line_length) + 1), (u32)info->var.yres);
+
+	dlfb_handle_damage(dlfb, 0, start, info->var.xres, lines);
+}
+
+static void dlfb_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
+{
+	struct dlfb_data *dlfb = info->par;
+
+	dlfb_offload_damage(dlfb, x, y, width, height);
+}
+
+FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(dlfb_ops,
+				   dlfb_ops_damage_range,
+				   dlfb_ops_damage_area)
+
 static const struct fb_ops dlfb_ops = {
 	.owner = THIS_MODULE,
-	.fb_read = fb_sys_read,
-	.fb_write = dlfb_ops_write,
+	__FB_DEFAULT_DEFERRED_OPS_RDWR(dlfb_ops),
 	.fb_setcolreg = dlfb_ops_setcolreg,
-	.fb_fillrect = dlfb_ops_fillrect,
-	.fb_copyarea = dlfb_ops_copyarea,
-	.fb_imageblit = dlfb_ops_imageblit,
+	__FB_DEFAULT_DEFERRED_OPS_DRAW(dlfb_ops),
 	.fb_mmap = dlfb_ops_mmap,
 	.fb_ioctl = dlfb_ops_ioctl,
 	.fb_open = dlfb_ops_open,
Signature · 1 line
2.41.0
Acked-by on v1 2/8
#7 lore raw

Re: [PATCH 2/8] fbdev/udlfb: Use fb_ops helpers for deferred I/O

Quoted 7 lines · Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---

[...]

Quoted 6 lines
drivers/video/fbdev/udlfb.c +6 -0
+static void dlfb_ops_damage_range(struct fb_info *info, off_t off, size_t len)
+{
+	struct dlfb_data *dlfb = info->par;
+	int start = max((int)(off / info->fix.line_length), 0);
+	int lines = min((u32)((len / info->fix.line_length) + 1), (u32)info->var.yres);
+

drivers/video/fbdev/udlfb.c static int dlfb_ops_blank(int blank_mode, struct fb_info *info) · line 1142

Quoted 10 lines
drivers/video/fbdev/udlfb.c +10 -0
+	dlfb_handle_damage(dlfb, 0, start, info->var.xres, lines);
+}
+
+static void dlfb_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
+{
+	struct dlfb_data *dlfb = info->par;
+
+	dlfb_offload_damage(dlfb, x, y, width, height);
+}
+

These two are very similar to the helpers you added for the smscufx driver in patch #1. I guess there's room for further consolidation as follow-up ?

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#8 lore raw

Re: [PATCH 2/8] fbdev/udlfb: Use fb_ops helpers for deferred I/O

Am 04.09.23 um 15:05 schrieb Javier Martinez Canillas:

Quoted 25 lines
Quoted 7 lines · Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---

[...]

Quoted 11 lines
drivers/video/fbdev/udlfb.c +11 -0
+static void dlfb_ops_damage_range(struct fb_info *info, off_t off, size_t len)
+{
+	struct dlfb_data *dlfb = info->par;
+	int start = max((int)(off / info->fix.line_length), 0);
+	int lines = min((u32)((len / info->fix.line_length) + 1), (u32)info->var.yres);
+
+	dlfb_handle_damage(dlfb, 0, start, info->var.xres, lines);
+}
+
+static void dlfb_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
+{
Quoted 8 lines

drivers/video/fbdev/udlfb.c static int dlfb_ops_blank(int blank_mode, struct fb_info *info) · line 1142

Quoted 5 lines
drivers/video/fbdev/udlfb.c +5 -0
+	struct dlfb_data *dlfb = info->par;
+
+	dlfb_offload_damage(dlfb, x, y, width, height);
+}
+

These two are very similar to the helpers you added for the smscufx driver in patch #1. I guess there's room for further consolidation as follow-up ?

Maybe. I had patches that take the rectangle computation from [1] and turn it into a helper for these USB drivers. But it's an unrelated change, so I dropped them from this patchset.

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.5.1/source/drivers/gpu/drm/drm_fb_helper.c#L641

Quoted 1 line
Signature · 6 lines
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)
#9 lore raw

Re: [PATCH 2/8] fbdev/udlfb: Use fb_ops helpers for deferred I/O

Quoted 35 lines · Thomas Zimmermann

Am 04.09.23 um 15:05 schrieb Javier Martinez Canillas:

Quoted 25 lines
Quoted 7 lines · Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

---

[...]

Quoted 11 lines
drivers/video/fbdev/udlfb.c +11 -0
+static void dlfb_ops_damage_range(struct fb_info *info, off_t off, size_t len)
+{
+	struct dlfb_data *dlfb = info->par;
+	int start = max((int)(off / info->fix.line_length), 0);
+	int lines = min((u32)((len / info->fix.line_length) + 1), (u32)info->var.yres);
+
+	dlfb_handle_damage(dlfb, 0, start, info->var.xres, lines);
+}
+
+static void dlfb_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
+{
Quoted 8 lines

drivers/video/fbdev/udlfb.c static int dlfb_ops_blank(int blank_mode, struct fb_info *info) · line 1142

Quoted 5 lines
drivers/video/fbdev/udlfb.c +5 -0
+	struct dlfb_data *dlfb = info->par;
+
+	dlfb_offload_damage(dlfb, x, y, width, height);
+}
+

These two are very similar to the helpers you added for the smscufx driver in patch #1. I guess there's room for further consolidation as follow-up ?

Quoted 4 lines

Maybe. I had patches that take the rectangle computation from [1] and turn it into a helper for these USB drivers. But it's an unrelated change, so I dropped them from this patchset.

Great and yes, I meant as separate patch-set, not as a part of this one.

Quoted 3 lines

Best regards
Thomas

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#10 lore raw

PATCH 3/8 fbdev: Add Kconfig macro FB_IOMEM_HELPERS_DEFERRED

In reply to Thomas Zimmermann

The new Kconfig macro FB_IOMEM_HELPERS_DEFERRED selects fbdev's helpers for device I/O memory and deferred I/O. Drivers should use it if they perform damage updates on device I/O memory.

---
 drivers/video/fbdev/core/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/video/fbdev/core/Kconfig +6 -0
index baf7e852c75b..e80d6429f76a 100644
@@ -151,6 +151,12 @@ config FB_IOMEM_HELPERS
 	select FB_CFB_FILLRECT
 	select FB_CFB_IMAGEBLIT
 
+config FB_IOMEM_HELPERS_DEFERRED
+	bool
+	depends on FB_CORE
+	select FB_DEFERRED_IO
+	select FB_IOMEM_HELPERS
+
 config FB_SYSMEM_HELPERS
 	bool
 	depends on FB_CORE
Signature · 1 line
2.41.0
Acked-by on v1 3/8
#11 lore raw

Re: [PATCH 3/8] fbdev: Add Kconfig macro FB_IOMEM_HELPERS_DEFERRED

Quoted 6 lines · Thomas Zimmermann

The new Kconfig macro FB_IOMEM_HELPERS_DEFERRED selects fbdev's helpers for device I/O memory and deferred I/O. Drivers should use it if they perform damage updates on device I/O memory.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#12 lore raw

PATCH 4/8 fbdev/hyperv_fb: Use fb_ops helpers for deferred I/O

In reply to Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

The hyperv_fb driver is incomplete in its handling of deferred I/O and damage framebuffers. Write operations do no trigger damage handling. Fixing this is beyond the scope of this patch.

Cc "K. Y. Srinivasan" <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Wei Liu <[email protected]>
Cc Dexuan Cui <[email protected]>
---
 drivers/video/fbdev/Kconfig     |  5 +---
 drivers/video/fbdev/hyperv_fb.c | 48 ++++++++++-----------------------
 2 files changed, 15 insertions(+), 38 deletions(-)
drivers/video/fbdev/Kconfig +1 -4
index 79b1e4e542e7..4455bfd57f0e 100644
@@ -1905,11 +1905,8 @@ config FB_BROADSHEET
 config FB_HYPERV
 	tristate "Microsoft Hyper-V Synthetic Video support"
 	depends on FB && HYPERV
-	select FB_CFB_FILLRECT
-	select FB_CFB_COPYAREA
-	select FB_CFB_IMAGEBLIT
-	select FB_DEFERRED_IO
 	select DMA_CMA if HAVE_DMA_CONTIGUOUS && CMA
+	select FB_IOMEM_HELPERS_DEFERRED
 	select VIDEO_NOMODESET
 	help
 	  This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
drivers/video/fbdev/hyperv_fb.c +14 -34

72 lines not on this page · raw message

Signature · 1 line
2.41.0
Acked-by on v1 4/8
#13 lore raw

Re: [PATCH 4/8] fbdev/hyperv_fb: Use fb_ops helpers for deferred I/O

Quoted 9 lines · Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(). Initialize struct fb_ops to the generated functions with fbdev initializer macros.

The hyperv_fb driver is incomplete in its handling of deferred I/O and damage framebuffers. Write operations do no trigger damage handling. Fixing this is beyond the scope of this patch.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#14 lore raw

PATCH 5/8 hid: Remove trailing whitespace

In reply to Thomas Zimmermann

Fix coding style in Kconfig. No functional changes.

Cc Jiri Kosina <[email protected]>
Cc Benjamin Tissoires <[email protected]>
---
 drivers/hid/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/Kconfig +1 -1
index e11c1c803676..b50054a41c10 100644
@@ -1037,7 +1037,7 @@ config HID_SONY
 	  * Guitar Hero PS3 and PC guitar dongles
 
 config SONY_FF
-	bool "Sony PS2/3/4 accessories force feedback support" 
+	bool "Sony PS2/3/4 accessories force feedback support"
 	depends on HID_SONY
 	select INPUT_FF_MEMLESS
 	help
Signature · 1 line
2.41.0
#16 lore raw

PATCH 6/8 hid/picolcd: Use fb_ops helpers for deferred I/O

In reply to Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with an fbdev initializer macro.

Cc Jiri Kosina <[email protected]>
Cc Benjamin Tissoires <[email protected]>
Cc "Bruno Prémont" <[email protected]>
---
 drivers/hid/Kconfig          |  6 +--
 drivers/hid/hid-picolcd_fb.c | 73 ++++++++++--------------------------
 2 files changed, 20 insertions(+), 59 deletions(-)
drivers/hid/Kconfig +1 -5
index b50054a41c10..dbf632bb7e26 100644
@@ -871,11 +871,7 @@ config HID_PICOLCD_FB
 	default !EXPERT
 	depends on HID_PICOLCD
 	depends on HID_PICOLCD=FB || FB=y
-	select FB_DEFERRED_IO
-	select FB_SYS_FILLRECT
-	select FB_SYS_COPYAREA
-	select FB_SYS_IMAGEBLIT
-	select FB_SYS_FOPS
+	select FB_SYSMEM_HELPERS_DEFERRED
 	help
 	  Provide access to PicoLCD's 256x64 monochrome display via a
 	  framebuffer device.
drivers/hid/hid-picolcd_fb.c +19 -54

91 lines not on this page · raw message

Signature · 1 line
2.41.0
Acked-by on v1 6/8
#17 lore raw

Re: [PATCH 6/8] hid/picolcd: Use fb_ops helpers for deferred I/O

Quoted 9 lines · Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with an fbdev initializer macro.

Cc Jiri Kosina <[email protected]>
Cc Benjamin Tissoires <[email protected]>
Cc "Bruno Prémont" <[email protected]>

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#18 lore raw

PATCH 7/8 staging/fbtft: Initialize fb_op struct as static const

In reply to Thomas Zimmermann

Replace dynamic allocation of the fb_ops instance with static allocation. Initialize the fields at module-load time. The owner field changes to THIS_MODULE, as in all other fbdev drivers.

---
 drivers/staging/fbtft/fbtft-core.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/staging/fbtft/fbtft-core.c +13 -17
index eac1d570f437..e4a77a4e7be6 100644
@@ -473,6 +473,18 @@ static int fbtft_fb_blank(int blank, struct fb_info *info)
 	return ret;
 }
 
+static const struct fb_ops fbtft_ops = {
+	.owner        = THIS_MODULE;
+	.fb_read      = fb_sys_read;
+	.fb_write     = fbtft_fb_write;
+	.fb_fillrect  = fbtft_fb_fillrect;
+	.fb_copyarea  = fbtft_fb_copyarea;
+	.fb_imageblit = fbtft_fb_imageblit;
+	.fb_setcolreg = fbtft_fb_setcolreg;
+	.fb_blank     = fbtft_fb_blank;
+	.fb_mmap      = fb_deferred_io_mmap;
+};
+
 static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
 {
 	if (src->write)
@@ -521,7 +533,6 @@ static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
  * Creates a new frame buffer info structure.
  *
  * Also creates and populates the following structures:
- *   info->fbops
  *   info->fbdefio
  *   info->pseudo_palette
  *   par->fbtftops
@@ -536,7 +547,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
 {
 	struct fb_info *info;
 	struct fbtft_par *par;
-	struct fb_ops *fbops = NULL;
 	struct fb_deferred_io *fbdefio = NULL;
 	u8 *vmem = NULL;
 	void *txbuf = NULL;
@@ -611,10 +621,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
 	if (!vmem)
 		goto alloc_fail;
 
-	fbops = devm_kzalloc(dev, sizeof(struct fb_ops), GFP_KERNEL);
-	if (!fbops)
-		goto alloc_fail;
-
 	fbdefio = devm_kzalloc(dev, sizeof(struct fb_deferred_io), GFP_KERNEL);
 	if (!fbdefio)
 		goto alloc_fail;
@@ -638,19 +644,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
 		goto alloc_fail;
 
 	info->screen_buffer = vmem;
-	info->fbops = fbops;
+	info->fbops = &fbtft_ops;
 	info->fbdefio = fbdefio;
 
-	fbops->owner        =      dev->driver->owner;
-	fbops->fb_read      =      fb_sys_read;
-	fbops->fb_write     =      fbtft_fb_write;
-	fbops->fb_fillrect  =      fbtft_fb_fillrect;
-	fbops->fb_copyarea  =      fbtft_fb_copyarea;
-	fbops->fb_imageblit =      fbtft_fb_imageblit;
-	fbops->fb_setcolreg =      fbtft_fb_setcolreg;
-	fbops->fb_blank     =      fbtft_fb_blank;
-	fbops->fb_mmap      =      fb_deferred_io_mmap;
-
 	fbdefio->delay =            HZ / fps;
 	fbdefio->sort_pagereflist = true;
 	fbdefio->deferred_io =      fbtft_deferred_io;
Signature · 1 line
2.41.0
Acked-by Greg Kroah-Hartman on v1 7/8
#19 lore raw

Re: [PATCH 7/8] staging/fbtft: Initialize fb_op struct as static const

Quoted 9 lines · Thomas Zimmermann

Replace dynamic allocation of the fb_ops instance with static allocation. Initialize the fields at module-load time. The owner field changes to THIS_MODULE, as in all other fbdev drivers.

---
 drivers/staging/fbtft/fbtft-core.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
Acked-by on v1 7/8
#20 lore raw

Re: [PATCH 7/8] staging/fbtft: Initialize fb_op struct as static const

In reply to Thomas Zimmermann
Quoted 6 lines · Thomas Zimmermann

Replace dynamic allocation of the fb_ops instance with static allocation. Initialize the fields at module-load time. The owner field changes to THIS_MODULE, as in all other fbdev drivers.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#21 lore raw

PATCH 8/8 staging/fbtft: Use fb_ops helpers for deferred I/O

In reply to Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with an fbdev initializer macro.

---
 drivers/staging/fbtft/Kconfig      |  6 +--
 drivers/staging/fbtft/fbtft-core.c | 87 ++++++++----------------------
 2 files changed, 24 insertions(+), 69 deletions(-)
drivers/staging/fbtft/Kconfig +1 -5
index 5dda3c65a38e..77ab44362f16 100644
@@ -4,12 +4,8 @@ menuconfig FB_TFT
 	depends on FB && SPI
 	depends on FB_DEVICE
 	depends on GPIOLIB || COMPILE_TEST
-	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_SYSMEM_HELPERS_DEFERRED
 
 config FB_TFT_AGM1264K_FL
 	tristate "FB driver for the AGM1264K-FL LCD display"
drivers/staging/fbtft/fbtft-core.c +23 -64

100 lines not on this page · raw message

Signature · 1 line
2.41.0
Acked-by on v1 8/8
#23 lore raw

Re: [PATCH 8/8] staging/fbtft: Use fb_ops helpers for deferred I/O

In reply to Thomas Zimmermann
Quoted 6 lines · Thomas Zimmermann

Generate callback functions for struct fb_ops with the fbdev macro FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to the generated functions with an fbdev initializer macro.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat