Skip to contentSkip to conversation

video: deferred io sys helpers V2

PATCH In review Magnus Damm 2 participants 7 messages Dec 24, 2008 – Dec 25, 2008

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

cover video: deferred io sys helpers V2

video: deferred io sys helpers V2

[PATCH 01/05] video: deferred io sys helpers - core V2 [PATCH 02/05] video: deferred io sys helpers - sh_mobile_lcdcfb V2 [PATCH 03/05] video: deferred io sys helpers - hecuba / n411 V2 [PATCH 04/05] video: deferred io sys helpers - metronome V2 [PATCH 05/05] video: deferred io sys helpers - xen V2

This patchset extends the deferred io core code with commonly used functions.

The following functions are added to and exported from fb_defio.c:
- fb_deferred_io_read()
- fb_deferred_io_write()
- fb_deferred_io_fillrect()
- fb_deferred_io_copyarea()
- fb_deferred_io_imageblit()

The functions above makes use the deferred io delay which so far only has been used for mmap. This means for instance that the drivers using these functions no longer will refresh the screen according to the soft cursor refresh rate, instead the screen refresh rate derived from the deferred io delay value will be used.

The deferred io core code now keeps track of a dirty area between the calls to the functions above. Only xen is currently making use of this.

In the future we may want to extend the dirty area tracking code to instead modify the dirty bits for the pages backing the frame buffer.

Status:
- sh_mobile_lcdcfb: compiles and works well
- hecuba / n411: compiles on superh, but untested
- metronome: compiles on superh, but untested
- xen: unknown

---

 drivers/video/Kconfig            |   35 +++---------
 drivers/video/fb_defio.c         |   77 ++++++++++++++++++++++++++
 drivers/video/hecubafb.c         |   86 +----------------------------
 drivers/video/metronomefb.c      |  109 ++++++++------------------------------
 drivers/video/sh_mobile_lcdcfb.c |   39 +------------
 drivers/video/xen-fbfront.c      |   51 +++--------------
 include/linux/fb.h               |   12 ++++
 7 files changed, 145 insertions(+), 264 deletions(-)
#1 lore raw

PATCH 1/5 video: deferred io sys helpers - core V2

From: Magnus Damm <[email protected]>

Add shared sys helpers to the deferred io code. Instead of duplicating the code in each driver we can keep it in one place. This saves a few lines. The new helper functions make use of the deferred io delay. While at it, keep track of the dirty area to allow partial screen update.

---

Changes since V1
- Remove sysdelay
- Fix dirty area calculation

 drivers/video/Kconfig    |    4 ++
 drivers/video/fb_defio.c |   77 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fb.h       |   12 +++++++
 3 files changed, 93 insertions(+)
drivers/video/Kconfig +4 -0
@@ -179,6 +179,10 @@ config FB_SYS_FOPS
 config FB_DEFERRED_IO
 	bool
 	depends on FB
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
 
 config FB_HECUBA
 	tristate
drivers/video/fb_defio.c +77 -0

98 lines not on this page · raw message

include/linux/fb.h +12 -0
@@ -589,6 +589,7 @@ struct fb_deferred_io {
 	unsigned long delay;
 	struct mutex lock; /* mutex that protects the page list */
 	struct list_head pagelist; /* list of touched pages */
+	int dx, dy, width, height; /* modified area, excluding pages */
 	/* callback */
 	void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
 };
@@ -983,6 +984,17 @@ extern void fb_deferred_io_open(struct f
 extern void fb_deferred_io_cleanup(struct fb_info *info);
 extern int fb_deferred_io_fsync(struct file *file, struct dentry *dentry,
 				int datasync);
+extern ssize_t fb_deferred_io_read(struct fb_info *info, char __user *buf,
+				   size_t count, loff_t *ppos);
+extern ssize_t fb_deferred_io_write(struct fb_info *info,
+				    const char __user *buf,
+				    size_t count, loff_t *ppos);
+extern void fb_deferred_io_fillrect(struct fb_info *info,
+				    const struct fb_fillrect *rect);
+extern void fb_deferred_io_copyarea(struct fb_info *info,
+				    const struct fb_copyarea *area);
+extern void fb_deferred_io_imageblit(struct fb_info *info,
+				     const struct fb_image *image);
 
 static inline bool fb_be_math(struct fb_info *info)
 {
#2 lore raw

Re: [PATCH 01/05] video: deferred io sys helpers - core V2

Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Add shared sys helpers to the deferred io code. Instead of duplicating the code in each driver we can keep it in one place. This saves a few lines. The new helper functions make use of the deferred io delay. While at it, keep track of the dirty area to allow partial screen update.

Hi Magnus,

Ok, while the overall patchset looks good, I still had trouble with the dx, dy, w, h stuff. It had me a bit confused. The above comment about keeping track of the dirty area made me realize why I think that portion can be improved. The reason is that we already have a pagelist to track touched pages and the dx, dy, w, h stuff duplicates that. I have an idea of how we can avoid this duplication which I'll sketch below.

drivers/video/fb_defio.c static void fb_deferred_io_work(struct w · line 231

Quoted 11 lines
drivers/video/fb_defio.c +11 -0
+ssize_t fb_deferred_io_write(struct fb_info *info, const char __user *buf,
+                            size_t count, loff_t *ppos)
+{
+       int ret = fb_sys_write(info, buf, count, ppos);
+
+       if (ret > 0)
+               fb_deferred_io_touch(info, 0, 0, INT_MAX, INT_MAX);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(fb_deferred_io_write);

As you have noticed, doing it using x, y, w, h results in needing to do things like INT_MAX above and side effects like dx != -1 in the client drivers. I think that we can avoid this. Instead, I would prepare the pagelist directly in write, imageblit, etc since we know exactly which pages have been touched.

I guess this would be better explained if I posted some sample code rather than just talking about it so I'll do a quick and dirty implementation for write only in metronomefb so that we can discuss this further.

Thanks,
jaya

#3 lore raw

PATCH 2/5 video: deferred io sys helpers - sh_mobile_lcdcfb V2

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Change the sh_mobile_lcdcfb driver to use the new shared sys helpers. This allows us to remove some code.

---

Changes since V1:
- remove sysdelay

 drivers/video/Kconfig            |    4 ---
 drivers/video/sh_mobile_lcdcfb.c |   39 ++++----------------------------------
 2 files changed, 5 insertions(+), 38 deletions(-)
drivers/video/Kconfig +0 -4
@@ -1893,10 +1893,6 @@ config FB_W100
 config FB_SH_MOBILE_LCDC
 	tristate "SuperH Mobile LCDC framebuffer support"
 	depends on FB && SUPERH
-	select FB_SYS_FILLRECT
-	select FB_SYS_COPYAREA
-	select FB_SYS_IMAGEBLIT
-	select FB_SYS_FOPS
 	select FB_DEFERRED_IO
 	---help---
 	  Frame buffer driver for the on-chip SH-Mobile LCD controller.
drivers/video/sh_mobile_lcdcfb.c +5 -34
@@ -215,14 +215,6 @@ static void sh_mobile_lcdc_deferred_io(s
 	lcdc_write_chan(ch, LDSM2R, 1);
 }
 
-static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info)
-{
-	struct fb_deferred_io *fbdefio = info->fbdefio;
-
-	if (fbdefio)
-		schedule_delayed_work(&info->deferred_work, fbdefio->delay);
-}
-
 static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
 {
 	struct sh_mobile_lcdc_priv *priv = data;
@@ -586,34 +578,13 @@ static struct fb_fix_screeninfo sh_mobil
 	.accel =	FB_ACCEL_NONE,
 };
 
-static void sh_mobile_lcdc_fillrect(struct fb_info *info,
-				    const struct fb_fillrect *rect)
-{
-	sys_fillrect(info, rect);
-	sh_mobile_lcdc_deferred_io_touch(info);
-}
-
-static void sh_mobile_lcdc_copyarea(struct fb_info *info,
-				    const struct fb_copyarea *area)
-{
-	sys_copyarea(info, area);
-	sh_mobile_lcdc_deferred_io_touch(info);
-}
-
-static void sh_mobile_lcdc_imageblit(struct fb_info *info,
-				     const struct fb_image *image)
-{
-	sys_imageblit(info, image);
-	sh_mobile_lcdc_deferred_io_touch(info);
-}
-
 static struct fb_ops sh_mobile_lcdc_ops = {
 	.fb_setcolreg	= sh_mobile_lcdc_setcolreg,
-	.fb_read        = fb_sys_read,
-	.fb_write       = fb_sys_write,
-	.fb_fillrect	= sh_mobile_lcdc_fillrect,
-	.fb_copyarea	= sh_mobile_lcdc_copyarea,
-	.fb_imageblit	= sh_mobile_lcdc_imageblit,
+	.fb_read        = fb_deferred_io_read,
+	.fb_write       = fb_deferred_io_write,
+	.fb_fillrect	= fb_deferred_io_fillrect,
+	.fb_copyarea	= fb_deferred_io_copyarea,
+	.fb_imageblit	= fb_deferred_io_imageblit,
 };
 
 static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp)
#4 lore raw

PATCH 3/5 video: deferred io sys helpers - hecuba / n411 V2

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Change the hecubafb driver and the n411 code to use the new shared sys helpers. This allows us to remove some duplicated code. The use of the new shared sys helpers will change the behavior of this driver from syncing all fillrect/copyarea/imageblit/write operations directly to using the deferred io delay.

While at it, convert space to tabs for the n411 kconfig entry.

---

Changes since V1:
- fix FB_HECUBA select of FB_DEFERRED_IO, thanks Paul!

 drivers/video/Kconfig    |   19 +++-------
 drivers/video/hecubafb.c |   86 ++--------------------------------------------
 2 files changed, 12 insertions(+), 93 deletions(-)
drivers/video/Kconfig +7 -12
@@ -187,7 +187,7 @@ config FB_DEFERRED_IO
 config FB_HECUBA
 	tristate
 	depends on FB
-	depends on FB_DEFERRED_IO
+	select FB_DEFERRED_IO
 
 config FB_SVGALIB
 	tristate
@@ -712,17 +712,12 @@ config FB_EFI
 	  using the EFI framebuffer as your console.
 
 config FB_N411
-       tristate "N411 Apollo/Hecuba devkit support"
-       depends on FB && X86 && MMU
-       select FB_SYS_FILLRECT
-       select FB_SYS_COPYAREA
-       select FB_SYS_IMAGEBLIT
-       select FB_SYS_FOPS
-       select FB_DEFERRED_IO
-       select FB_HECUBA
-       help
-         This enables support for the Apollo display controller in its
-         Hecuba form using the n411 devkit.
+	tristate "N411 Apollo/Hecuba devkit support"
+	depends on FB && X86 && MMU
+	select FB_HECUBA
+	help
+	  This enables support for the Apollo display controller in its
+	  Hecuba form using the n411 devkit.
 
 config FB_HGA
 	tristate "Hercules mono graphics support"
drivers/video/hecubafb.c +5 -81

94 lines not on this page · raw message

#5 lore raw

PATCH 4/5 video: deferred io sys helpers - metronome V2

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Change the metronome driver to use the new shared sys helpers. This allows us to remove some duplicated code. The use of the new shared sys helpers will change the behavior of this driver from syncing all fillrect/copyarea/imageblit/write operations directly to using the deferred io delay.

---

Changes since V1:
- added dirty area update comment

 drivers/video/Kconfig       |    4 -
 drivers/video/metronomefb.c |  109 +++++++++----------------------------------
 2 files changed, 24 insertions(+), 89 deletions(-)
drivers/video/Kconfig +0 -4
@@ -2071,10 +2071,6 @@ config XEN_FBDEV_FRONTEND
 config FB_METRONOME
 	tristate "E-Ink Metronome/8track controller support"
 	depends on FB
-	select FB_SYS_FILLRECT
-	select FB_SYS_COPYAREA
-	select FB_SYS_IMAGEBLIT
-	select FB_SYS_FOPS
 	select FB_DEFERRED_IO
 	help
 	  This driver implements support for the E-Ink Metronome
drivers/video/metronomefb.c +24 -85

128 lines not on this page · raw message

#6 lore raw

PATCH 5/5 video: deferred io sys helpers - xen V2

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Change the xen driver to use the new shared sys helpers. This allows us to remove some duplicated code. The use of the new shared sys helpers will change the behavior of this driver from syncing all operations directly to using the deferred io delay.

---

Changes since V1:
- Only cosmetic

 drivers/video/Kconfig       |    4 ---
 drivers/video/xen-fbfront.c |   51 +++++++++----------------------------------
 2 files changed, 11 insertions(+), 44 deletions(-)
drivers/video/Kconfig +0 -4
@@ -2057,10 +2057,6 @@ config FB_VIRTUAL
 config XEN_FBDEV_FRONTEND
 	tristate "Xen virtual frame buffer support"
 	depends on FB && XEN
-	select FB_SYS_FILLRECT
-	select FB_SYS_COPYAREA
-	select FB_SYS_IMAGEBLIT
-	select FB_SYS_FOPS
 	select FB_DEFERRED_IO
 	default y
 	help
drivers/video/xen-fbfront.c +11 -40

75 lines not on this page · raw message