linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/05] video: deferred io sys helpers V2
@ 2008-12-24  8:29 Magnus Damm
  2008-12-24  8:29 ` [PATCH 01/05] video: deferred io sys helpers - core V2 Magnus Damm
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Magnus Damm @ 2008-12-24  8:29 UTC (permalink / raw)
  To: linux-fbdev-devel
  Cc: aliguori, adaplas, linux-sh, armbru, lethal, Magnus Damm,
	jayakumar.lkml

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

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 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(-)

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

* [PATCH 01/05] video: deferred io sys helpers - core V2
  2008-12-24  8:29 [PATCH 00/05] video: deferred io sys helpers V2 Magnus Damm
@ 2008-12-24  8:29 ` Magnus Damm
  2008-12-25 19:03   ` Jaya Kumar
  2008-12-24  8:30 ` [PATCH 02/05] video: deferred io sys helpers - sh_mobile_lcdcfb V2 Magnus Damm
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Magnus Damm @ 2008-12-24  8:29 UTC (permalink / raw)
  To: linux-fbdev-devel
  Cc: aliguori, adaplas, linux-sh, armbru, lethal, Magnus Damm,
	jayakumar.lkml

From: Magnus Damm <damm@igel.co.jp>

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.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 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(+)

--- 0001/drivers/video/Kconfig
+++ work/drivers/video/Kconfig	2008-12-24 15:31:14.000000000 +0900
@@ -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
--- 0001/drivers/video/fb_defio.c
+++ work/drivers/video/fb_defio.c	2008-12-24 16:24:01.000000000 +0900
@@ -83,6 +83,38 @@ int fb_deferred_io_fsync(struct file *fi
 }
 EXPORT_SYMBOL_GPL(fb_deferred_io_fsync);
 
+static void fb_deferred_io_touch(struct fb_info *info,
+				 int dx, int dy, int width, int height)
+{
+	struct fb_deferred_io *fbdefio = info->fbdefio;
+	int x, y, ex, ey;
+
+	/* Skip if deferred io is complied-in but disabled on this fbdev */
+	if (!fbdefio)
+		return;
+
+	/* Remember area to redraw and expand if necessary */
+	if (fbdefio->dx != -1) {
+		x = min_t(int, dx, fbdefio->dx);
+		y = min_t(int, dy, fbdefio->dy);
+		ex = max_t(int, dx + width, fbdefio->dx + fbdefio->width);
+		ey = max_t(int, dy + height, fbdefio->dy + fbdefio->height);
+
+		dx = x;
+		dy = y;
+		width = ex - x;
+		height = ey - y;
+	}
+
+	fbdefio->dx = dx;
+	fbdefio->dy = dy;
+	fbdefio->width = width;
+	fbdefio->height = height;
+
+	/* come back after delay to process the deferred IO */
+	schedule_delayed_work(&info->deferred_work, fbdefio->delay);
+}
+
 /* vm_ops->page_mkwrite handler */
 static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 				  struct page *page)
@@ -172,9 +204,53 @@ static void fb_deferred_io_work(struct w
 	list_for_each_safe(node, next, &fbdefio->pagelist) {
 		list_del(node);
 	}
+
+	/* reset sys operations state */
+	fbdefio->dx = -1;
+
 	mutex_unlock(&fbdefio->lock);
 }
 
+ssize_t fb_deferred_io_read(struct fb_info *info, char __user *buf,
+			    size_t count, loff_t *ppos)
+{
+	return fb_sys_read(info, buf, count, ppos);
+}
+EXPORT_SYMBOL_GPL(fb_deferred_io_read);
+
+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);
+
+void fb_deferred_io_fillrect(struct fb_info *info, const struct fb_fillrect *r)
+{
+	sys_fillrect(info, r);
+	fb_deferred_io_touch(info, r->dx, r->dy, r->width, r->height);
+}
+EXPORT_SYMBOL_GPL(fb_deferred_io_fillrect);
+
+void fb_deferred_io_copyarea(struct fb_info *info, const struct fb_copyarea *a)
+{
+	sys_copyarea(info, a);
+	fb_deferred_io_touch(info, a->dx, a->dy, a->width, a->height);
+}
+EXPORT_SYMBOL_GPL(fb_deferred_io_copyarea);
+
+void fb_deferred_io_imageblit(struct fb_info *info, const struct fb_image *i)
+{
+	sys_imageblit(info, i);
+	fb_deferred_io_touch(info, i->dx, i->dy, i->width, i->height);
+}
+EXPORT_SYMBOL_GPL(fb_deferred_io_imageblit);
+
 void fb_deferred_io_init(struct fb_info *info)
 {
 	struct fb_deferred_io *fbdefio = info->fbdefio;
@@ -184,6 +260,7 @@ void fb_deferred_io_init(struct fb_info 
 	info->fbops->fb_mmap = fb_deferred_io_mmap;
 	INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
 	INIT_LIST_HEAD(&fbdefio->pagelist);
+	fbdefio->dx = -1;
 	if (fbdefio->delay == 0) /* set a default of 1 s */
 		fbdefio->delay = HZ;
 }
--- 0001/include/linux/fb.h
+++ work/include/linux/fb.h	2008-12-24 16:20:57.000000000 +0900
@@ -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)
 {

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

* [PATCH 02/05] video: deferred io sys helpers - sh_mobile_lcdcfb V2
  2008-12-24  8:29 [PATCH 00/05] video: deferred io sys helpers V2 Magnus Damm
  2008-12-24  8:29 ` [PATCH 01/05] video: deferred io sys helpers - core V2 Magnus Damm
@ 2008-12-24  8:30 ` Magnus Damm
  2008-12-24  8:30 ` [PATCH 03/05] video: deferred io sys helpers - hecuba / n411 V2 Magnus Damm
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Magnus Damm @ 2008-12-24  8:30 UTC (permalink / raw)
  To: linux-fbdev-devel
  Cc: aliguori, adaplas, linux-sh, armbru, lethal, Magnus Damm,
	jayakumar.lkml

From: Magnus Damm <damm@igel.co.jp>

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

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 Changes since V1:
 - remove sysdelay

 drivers/video/Kconfig            |    4 ---
 drivers/video/sh_mobile_lcdcfb.c |   39 ++++----------------------------------
 2 files changed, 5 insertions(+), 38 deletions(-)

--- 0002/drivers/video/Kconfig
+++ work/drivers/video/Kconfig	2008-12-24 16:29:02.000000000 +0900
@@ -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.
--- 0001/drivers/video/sh_mobile_lcdcfb.c
+++ work/drivers/video/sh_mobile_lcdcfb.c	2008-12-24 16:29:09.000000000 +0900
@@ -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)

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

* [PATCH 03/05] video: deferred io sys helpers - hecuba / n411 V2
  2008-12-24  8:29 [PATCH 00/05] video: deferred io sys helpers V2 Magnus Damm
  2008-12-24  8:29 ` [PATCH 01/05] video: deferred io sys helpers - core V2 Magnus Damm
  2008-12-24  8:30 ` [PATCH 02/05] video: deferred io sys helpers - sh_mobile_lcdcfb V2 Magnus Damm
@ 2008-12-24  8:30 ` Magnus Damm
  2008-12-24  8:30 ` [PATCH 04/05] video: deferred io sys helpers - metronome V2 Magnus Damm
  2008-12-24  8:30 ` [PATCH 05/05] video: deferred io sys helpers - xen V2 Magnus Damm
  4 siblings, 0 replies; 7+ messages in thread
From: Magnus Damm @ 2008-12-24  8:30 UTC (permalink / raw)
  To: linux-fbdev-devel
  Cc: aliguori, adaplas, linux-sh, armbru, lethal, Magnus Damm,
	jayakumar.lkml

From: Magnus Damm <damm@igel.co.jp>

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.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 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(-)

--- 0003/drivers/video/Kconfig
+++ work/drivers/video/Kconfig	2008-12-24 15:32:30.000000000 +0900
@@ -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"
--- 0001/drivers/video/hecubafb.c
+++ work/drivers/video/hecubafb.c	2008-12-24 15:32:30.000000000 +0900
@@ -122,89 +122,13 @@ static void hecubafb_dpy_deferred_io(str
 	hecubafb_dpy_update(info->par);
 }
 
-static void hecubafb_fillrect(struct fb_info *info,
-				   const struct fb_fillrect *rect)
-{
-	struct hecubafb_par *par = info->par;
-
-	sys_fillrect(info, rect);
-
-	hecubafb_dpy_update(par);
-}
-
-static void hecubafb_copyarea(struct fb_info *info,
-				   const struct fb_copyarea *area)
-{
-	struct hecubafb_par *par = info->par;
-
-	sys_copyarea(info, area);
-
-	hecubafb_dpy_update(par);
-}
-
-static void hecubafb_imageblit(struct fb_info *info,
-				const struct fb_image *image)
-{
-	struct hecubafb_par *par = info->par;
-
-	sys_imageblit(info, image);
-
-	hecubafb_dpy_update(par);
-}
-
-/*
- * this is the slow path from userspace. they can seek and write to
- * the fb. it's inefficient to do anything less than a full screen draw
- */
-static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf,
-				size_t count, loff_t *ppos)
-{
-	struct hecubafb_par *par = info->par;
-	unsigned long p = *ppos;
-	void *dst;
-	int err = 0;
-	unsigned long total_size;
-
-	if (info->state != FBINFO_STATE_RUNNING)
-		return -EPERM;
-
-	total_size = info->fix.smem_len;
-
-	if (p > total_size)
-		return -EFBIG;
-
-	if (count > total_size) {
-		err = -EFBIG;
-		count = total_size;
-	}
-
-	if (count + p > total_size) {
-		if (!err)
-			err = -ENOSPC;
-
-		count = total_size - p;
-	}
-
-	dst = (void __force *) (info->screen_base + p);
-
-	if (copy_from_user(dst, buf, count))
-		err = -EFAULT;
-
-	if  (!err)
-		*ppos += count;
-
-	hecubafb_dpy_update(par);
-
-	return (err) ? err : count;
-}
-
 static struct fb_ops hecubafb_ops = {
 	.owner		= THIS_MODULE,
-	.fb_read        = fb_sys_read,
-	.fb_write	= hecubafb_write,
-	.fb_fillrect	= hecubafb_fillrect,
-	.fb_copyarea	= hecubafb_copyarea,
-	.fb_imageblit	= hecubafb_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 struct fb_deferred_io hecubafb_defio = {

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

* [PATCH 04/05] video: deferred io sys helpers - metronome V2
  2008-12-24  8:29 [PATCH 00/05] video: deferred io sys helpers V2 Magnus Damm
                   ` (2 preceding siblings ...)
  2008-12-24  8:30 ` [PATCH 03/05] video: deferred io sys helpers - hecuba / n411 V2 Magnus Damm
@ 2008-12-24  8:30 ` Magnus Damm
  2008-12-24  8:30 ` [PATCH 05/05] video: deferred io sys helpers - xen V2 Magnus Damm
  4 siblings, 0 replies; 7+ messages in thread
From: Magnus Damm @ 2008-12-24  8:30 UTC (permalink / raw)
  To: linux-fbdev-devel
  Cc: aliguori, adaplas, linux-sh, armbru, lethal, Magnus Damm,
	jayakumar.lkml

From: Magnus Damm <damm@igel.co.jp>

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.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 Changes since V1:
 - added dirty area update comment

 drivers/video/Kconfig       |    4 -
 drivers/video/metronomefb.c |  109 +++++++++----------------------------------
 2 files changed, 24 insertions(+), 89 deletions(-)

--- 0004/drivers/video/Kconfig
+++ work/drivers/video/Kconfig	2008-12-24 16:33:39.000000000 +0900
@@ -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
--- 0001/drivers/video/metronomefb.c
+++ work/drivers/video/metronomefb.c	2008-12-24 16:41:55.000000000 +0900
@@ -445,7 +445,6 @@ static void metronomefb_dpy_update(struc
 
 	cksum = calc_img_cksum((u16 *) par->metromem_img, fbsize/2);
 	*((u16 *)(par->metromem_img) + fbsize/2) = cksum;
-	metronome_display_cmd(par);
 }
 
 static u16 metronomefb_dpy_update_page(struct metronomefb_par *par, int index)
@@ -472,97 +471,37 @@ static void metronomefb_dpy_deferred_io(
 	struct fb_deferred_io *fbdefio = info->fbdefio;
 	struct metronomefb_par *par = info->par;
 
-	/* walk the written page list and swizzle the data */
-	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
-		cksum = metronomefb_dpy_update_page(par,
-					(cur->index << PAGE_SHIFT));
-		par->metromem_img_csum -= par->csum_table[cur->index];
-		par->csum_table[cur->index] = cksum;
-		par->metromem_img_csum += cksum;
+	/* force full screen update if dx is set or walk page list.
+	 *
+	 * normally, we need to update the dirty area pointed out by dx and
+	 * plus all dirty pages. in this driver any dirty area pointed out
+	 * by dx results in a full screen update. and since the entire screen
+	 * is updated in that case we can skip walking the page list.
+	 */
+	if (fbdefio->dx != -1) {
+		/* update the entire screen */
+		metronomefb_dpy_update(par);
+	} else {
+		/* walk the written page list and swizzle the data */
+		list_for_each_entry(cur, &fbdefio->pagelist, lru) {
+			cksum = metronomefb_dpy_update_page(par,
+						(cur->index << PAGE_SHIFT));
+			par->metromem_img_csum -= par->csum_table[cur->index];
+			par->csum_table[cur->index] = cksum;
+			par->metromem_img_csum += cksum;
+		}
 	}
 
 	metronome_display_cmd(par);
 }
 
-static void metronomefb_fillrect(struct fb_info *info,
-				   const struct fb_fillrect *rect)
-{
-	struct metronomefb_par *par = info->par;
-
-	sys_fillrect(info, rect);
-	metronomefb_dpy_update(par);
-}
-
-static void metronomefb_copyarea(struct fb_info *info,
-				   const struct fb_copyarea *area)
-{
-	struct metronomefb_par *par = info->par;
-
-	sys_copyarea(info, area);
-	metronomefb_dpy_update(par);
-}
-
-static void metronomefb_imageblit(struct fb_info *info,
-				const struct fb_image *image)
-{
-	struct metronomefb_par *par = info->par;
-
-	sys_imageblit(info, image);
-	metronomefb_dpy_update(par);
-}
-
-/*
- * this is the slow path from userspace. they can seek and write to
- * the fb. it is based on fb_sys_write
- */
-static ssize_t metronomefb_write(struct fb_info *info, const char __user *buf,
-				size_t count, loff_t *ppos)
-{
-	struct metronomefb_par *par = info->par;
-	unsigned long p = *ppos;
-	void *dst;
-	int err = 0;
-	unsigned long total_size;
-
-	if (info->state != FBINFO_STATE_RUNNING)
-		return -EPERM;
-
-	total_size = info->fix.smem_len;
-
-	if (p > total_size)
-		return -EFBIG;
-
-	if (count > total_size) {
-		err = -EFBIG;
-		count = total_size;
-	}
-
-	if (count + p > total_size) {
-		if (!err)
-			err = -ENOSPC;
-
-		count = total_size - p;
-	}
-
-	dst = (void __force *)(info->screen_base + p);
-
-	if (copy_from_user(dst, buf, count))
-		err = -EFAULT;
-
-	if  (!err)
-		*ppos += count;
-
-	metronomefb_dpy_update(par);
-
-	return (err) ? err : count;
-}
-
 static struct fb_ops metronomefb_ops = {
 	.owner		= THIS_MODULE,
-	.fb_write	= metronomefb_write,
-	.fb_fillrect	= metronomefb_fillrect,
-	.fb_copyarea	= metronomefb_copyarea,
-	.fb_imageblit	= metronomefb_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 struct fb_deferred_io metronomefb_defio = {

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

* [PATCH 05/05] video: deferred io sys helpers - xen V2
  2008-12-24  8:29 [PATCH 00/05] video: deferred io sys helpers V2 Magnus Damm
                   ` (3 preceding siblings ...)
  2008-12-24  8:30 ` [PATCH 04/05] video: deferred io sys helpers - metronome V2 Magnus Damm
@ 2008-12-24  8:30 ` Magnus Damm
  4 siblings, 0 replies; 7+ messages in thread
From: Magnus Damm @ 2008-12-24  8:30 UTC (permalink / raw)
  To: linux-fbdev-devel
  Cc: aliguori, adaplas, linux-sh, armbru, lethal, Magnus Damm,
	jayakumar.lkml

From: Magnus Damm <damm@igel.co.jp>

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.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 Changes since V1:
 - Only cosmetic

 drivers/video/Kconfig       |    4 ---
 drivers/video/xen-fbfront.c |   51 +++++++++----------------------------------
 2 files changed, 11 insertions(+), 44 deletions(-)

--- 0005/drivers/video/Kconfig
+++ work/drivers/video/Kconfig	2008-12-24 16:42:47.000000000 +0900
@@ -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
--- 0001/drivers/video/xen-fbfront.c
+++ work/drivers/video/xen-fbfront.c	2008-12-24 16:44:19.000000000 +0900
@@ -177,11 +177,17 @@ static void xenfb_refresh(struct xenfb_i
 static void xenfb_deferred_io(struct fb_info *fb_info,
 			      struct list_head *pagelist)
 {
+	struct fb_deferred_io *fbdefio = fb_info->fbdefio;
 	struct xenfb_info *info = fb_info->par;
 	struct page *page;
 	unsigned long beg, end;
 	int y1, y2, miny, maxy;
 
+	if (fbdefio->dx != -1)
+		xenfb_refresh(info, fbdefio->dx, fbdefio->dy,
+			      min_t(int, info->page->width, fbdefio->width),
+			      min_t(int, info->page->height, fbdefio->height));
+
 	miny = INT_MAX;
 	maxy = 0;
 	list_for_each_entry(page, pagelist, lru) {
@@ -235,41 +241,6 @@ static int xenfb_setcolreg(unsigned regn
 	return 0;
 }
 
-static void xenfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
-{
-	struct xenfb_info *info = p->par;
-
-	sys_fillrect(p, rect);
-	xenfb_refresh(info, rect->dx, rect->dy, rect->width, rect->height);
-}
-
-static void xenfb_imageblit(struct fb_info *p, const struct fb_image *image)
-{
-	struct xenfb_info *info = p->par;
-
-	sys_imageblit(p, image);
-	xenfb_refresh(info, image->dx, image->dy, image->width, image->height);
-}
-
-static void xenfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
-{
-	struct xenfb_info *info = p->par;
-
-	sys_copyarea(p, area);
-	xenfb_refresh(info, area->dx, area->dy, area->width, area->height);
-}
-
-static ssize_t xenfb_write(struct fb_info *p, const char __user *buf,
-			size_t count, loff_t *ppos)
-{
-	struct xenfb_info *info = p->par;
-	ssize_t res;
-
-	res = fb_sys_write(p, buf, count, ppos);
-	xenfb_refresh(info, 0, 0, info->page->width, info->page->height);
-	return res;
-}
-
 static int
 xenfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
@@ -323,12 +294,12 @@ static int xenfb_set_par(struct fb_info 
 
 static struct fb_ops xenfb_fb_ops = {
 	.owner		= THIS_MODULE,
-	.fb_read	= fb_sys_read,
-	.fb_write	= xenfb_write,
+	.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,
 	.fb_setcolreg	= xenfb_setcolreg,
-	.fb_fillrect	= xenfb_fillrect,
-	.fb_copyarea	= xenfb_copyarea,
-	.fb_imageblit	= xenfb_imageblit,
 	.fb_check_var	= xenfb_check_var,
 	.fb_set_par     = xenfb_set_par,
 };

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

* Re: [PATCH 01/05] video: deferred io sys helpers - core V2
  2008-12-24  8:29 ` [PATCH 01/05] video: deferred io sys helpers - core V2 Magnus Damm
@ 2008-12-25 19:03   ` Jaya Kumar
  0 siblings, 0 replies; 7+ messages in thread
From: Jaya Kumar @ 2008-12-25 19:03 UTC (permalink / raw)
  To: Magnus Damm
  Cc: linux-fbdev-devel, aliguori, adaplas, linux-sh, armbru, lethal

On Wed, Dec 24, 2008 at 3:29 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> From: Magnus Damm <damm@igel.co.jp>
>
> 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.

> +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

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

end of thread, other threads:[~2008-12-25 19:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-24  8:29 [PATCH 00/05] video: deferred io sys helpers V2 Magnus Damm
2008-12-24  8:29 ` [PATCH 01/05] video: deferred io sys helpers - core V2 Magnus Damm
2008-12-25 19:03   ` Jaya Kumar
2008-12-24  8:30 ` [PATCH 02/05] video: deferred io sys helpers - sh_mobile_lcdcfb V2 Magnus Damm
2008-12-24  8:30 ` [PATCH 03/05] video: deferred io sys helpers - hecuba / n411 V2 Magnus Damm
2008-12-24  8:30 ` [PATCH 04/05] video: deferred io sys helpers - metronome V2 Magnus Damm
2008-12-24  8:30 ` [PATCH 05/05] video: deferred io sys helpers - xen V2 Magnus Damm

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