linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support
@ 2008-12-19  6:33 Magnus Damm
  2008-12-19  6:34 ` [PATCH 01/05] video: fix deferred io fsync() Magnus Damm
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Magnus Damm @ 2008-12-19  6:33 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Magnus Damm, lethal, adaplas, linux-sh

video: deferred io fixes and sh_mobile_lcdcfb support

[PATCH 01/05] video: fix deferred io fsync()
[PATCH 02/05] video: deferred io cleanup
[PATCH 03/05] video: deferred io with physically contiguous memory
[PATCH 04/05] video: sh_mobile_lcdcfb deferred io support 
[PATCH 05/05] sh: enable deferred io LCDC on Migo-R

This patchset adds deferred io support to sh_mobile_lcdcfb.

The LCDC hardware block managed by the sh_mobile_lcdcfb driver supports
RGB or SYS panel configurations. SYS panels come with an external display
controller that is resposible for refreshing the actual LCD panel. RGB
panels are controlled directly by the LCDC and they need to be refreshed
by the LCDC hardware.

In the case of SYS panels we can save some power by configuring the LCDC
hardware block in one-shot mode. In this one-shot mode panel refresh is
managed by software. This works well together with deferred io since it
allows us to stop clocks for most of the time and only enable clocks when
we actually want to trigger an update. When there is no fbdev activity
the clocks are kept stopped which allows us to deep sleep.

May I suggest merging the first 3 patches with other framebuffer changes,
but handling patch 4 and 5 with other SuperH changes? That strategy
should be fine since there are no compile time dependencies. To keep
things running please apply patch number 5 when all other changes are in.

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

 arch/sh/boards/mach-migor/setup.c |    2 
 drivers/video/Kconfig             |    1 
 drivers/video/fb_defio.c          |   27 ++++-
 drivers/video/sh_mobile_lcdcfb.c  |  170 ++++++++++++++++++++++++++++++++-----
 include/video/sh_mobile_lcdc.h    |    1 
 5 files changed, 174 insertions(+), 27 deletions(-)

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

* [PATCH 01/05] video: fix deferred io fsync()
  2008-12-19  6:33 [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Magnus Damm
@ 2008-12-19  6:34 ` Magnus Damm
  2008-12-24  5:05   ` [Linux-fbdev-devel] " Jaya Kumar
  2008-12-19  6:34 ` [PATCH 02/05] video: deferred io cleanup Magnus Damm
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Magnus Damm @ 2008-12-19  6:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Magnus Damm, lethal, adaplas, linux-sh

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

If CONFIG_FB_DEFERRED_IO is set, but there are framebuffers 
registered that does not make use of deferred io, then fsync()
on those framebuffers will result in a crash. Fix that.

This is needed for sh_mobile_lcdcfb since we always enable
deferred io at compile time but we may disable deferred io
for some types of hardware configurations.

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

 drivers/video/fb_defio.c |    4 ++++
 1 file changed, 4 insertions(+)

--- 0001/drivers/video/fb_defio.c
+++ work/drivers/video/fb_defio.c	2008-12-17 15:27:44.000000000 +0900
@@ -60,6 +60,10 @@ int fb_deferred_io_fsync(struct file *fi
 {
 	struct fb_info *info = file->private_data;
 
+	/* Skip if deferred io is complied-in but disabled on this fbdev */
+	if (!info->fbdefio)
+		return 0;
+
 	/* Kill off the delayed work */
 	cancel_rearming_delayed_work(&info->deferred_work);
 

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

* [PATCH 02/05] video: deferred io cleanup
  2008-12-19  6:33 [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Magnus Damm
  2008-12-19  6:34 ` [PATCH 01/05] video: fix deferred io fsync() Magnus Damm
@ 2008-12-19  6:34 ` Magnus Damm
  2008-12-24  5:05   ` [Linux-fbdev-devel] " Jaya Kumar
  2008-12-19  6:34 ` [PATCH 03/05] video: deferred io with physically contiguous memory Magnus Damm
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Magnus Damm @ 2008-12-19  6:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Magnus Damm, lethal, adaplas, linux-sh

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

Make sure the mmap callback is set to NULL in the deferred io
cleanup function. This way we can enable and disable deferred
io on the fly.

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

 drivers/video/fb_defio.c |    3 +++
 1 file changed, 3 insertions(+)

--- 0004/drivers/video/fb_defio.c
+++ work/drivers/video/fb_defio.c	2008-12-17 15:32:04.000000000 +0900
@@ -202,6 +202,9 @@ void fb_deferred_io_cleanup(struct fb_in
 		page = vmalloc_to_page(screen_base + i);
 		page->mapping = NULL;
 	}
+
+	info->fbops->fb_mmap = NULL;
+	mutex_destroy(&fbdefio->lock);
 }
 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
 

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

* [PATCH 03/05] video: deferred io with physically contiguous memory
  2008-12-19  6:33 [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Magnus Damm
  2008-12-19  6:34 ` [PATCH 01/05] video: fix deferred io fsync() Magnus Damm
  2008-12-19  6:34 ` [PATCH 02/05] video: deferred io cleanup Magnus Damm
@ 2008-12-19  6:34 ` Magnus Damm
  2008-12-24  5:13   ` [Linux-fbdev-devel] " Jaya Kumar
  2008-12-19  6:34 ` [PATCH 04/05] video: sh_mobile_lcdcfb deferred io support Magnus Damm
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Magnus Damm @ 2008-12-19  6:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Magnus Damm, lethal, adaplas, linux-sh

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

Extend the deferred io code from only supporting vmalloc()ed frame
buffer memory to support both vmalloc()ed and physically contiguous
frame buffer memory.

The sh_mobile_lcdcfb hardware does not support scatter gather so
we need physically contiguous memory to back our frame buffer.

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

 drivers/video/fb_defio.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

--- 0003/drivers/video/fb_defio.c
+++ work/drivers/video/fb_defio.c	2008-12-19 14:29:45.000000000 +0900
@@ -24,6 +24,19 @@
 #include <linux/rmap.h>
 #include <linux/pagemap.h>
 
+struct page *fb_deferred_io_page(struct fb_info *info, unsigned long offs)
+{
+	void *screen_base = (void __force *) info->screen_base;
+	struct page *page;
+
+	if (is_vmalloc_addr(screen_base + offs))
+		page = vmalloc_to_page(screen_base + offs);
+	else
+		page = pfn_to_page((info->fix.smem_start + offs) >> PAGE_SHIFT);
+
+	return page;
+}
+
 /* this is to find and return the vmalloc-ed fb pages */
 static int fb_deferred_io_fault(struct vm_area_struct *vma,
 				struct vm_fault *vmf)
@@ -31,14 +44,12 @@ static int fb_deferred_io_fault(struct v
 	unsigned long offset;
 	struct page *page;
 	struct fb_info *info = vma->vm_private_data;
-	/* info->screen_base is virtual memory */
-	void *screen_base = (void __force *) info->screen_base;
 
 	offset = vmf->pgoff << PAGE_SHIFT;
 	if (offset >= info->fix.smem_len)
 		return VM_FAULT_SIGBUS;
 
-	page = vmalloc_to_page(screen_base + offset);
+	page = fb_deferred_io_page(info, offset);
 	if (!page)
 		return VM_FAULT_SIGBUS;
 
@@ -188,7 +199,6 @@ EXPORT_SYMBOL_GPL(fb_deferred_io_open);
 
 void fb_deferred_io_cleanup(struct fb_info *info)
 {
-	void *screen_base = (void __force *) info->screen_base;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
 	struct page *page;
 	int i;
@@ -199,7 +209,7 @@ void fb_deferred_io_cleanup(struct fb_in
 
 	/* clear out the mapping that we setup */
 	for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) {
-		page = vmalloc_to_page(screen_base + i);
+		page = fb_deferred_io_page(info, i);
 		page->mapping = NULL;
 	}
 

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

* [PATCH 04/05] video: sh_mobile_lcdcfb deferred io support
  2008-12-19  6:33 [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Magnus Damm
                   ` (2 preceding siblings ...)
  2008-12-19  6:34 ` [PATCH 03/05] video: deferred io with physically contiguous memory Magnus Damm
@ 2008-12-19  6:34 ` Magnus Damm
  2008-12-19  6:34 ` [PATCH 05/05] sh: enable deferred io LCDC on Migo-R Magnus Damm
  2008-12-21  6:53 ` [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Paul Mundt
  5 siblings, 0 replies; 14+ messages in thread
From: Magnus Damm @ 2008-12-19  6:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Magnus Damm, lethal, adaplas, linux-sh

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

This patch adds sh_mobile_lcdcfb deferred io support for SYS panels.

The LCDC hardware block managed by the sh_mobile_lcdcfb driver supports
RGB or SYS panel configurations. SYS panels come with an external display
controller that is resposible for refreshing the actual LCD panel. RGB
panels are controlled directly by the LCDC and they need to be refreshed
by the LCDC hardware.

In the case of SYS panels we can save some power by configuring the LCDC
hardware block in one-shot mode. In this one-shot mode panel refresh is
managed by software. This works well together with deferred io since it
allows us to stop clocks for most of the time and only enable clocks when
we actually want to trigger an update. When there is no fbdev activity
the clocks are kept stopped which allows us to deep sleep.

The refresh rate in deferred io mode is set using platform data. The same
platform data can also be used to disable deferred io mode.

As with other deferred io frame buffers user space code should use fsync()
on the frame buffer device to trigger an update.

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

 drivers/video/Kconfig            |    1 
 drivers/video/sh_mobile_lcdcfb.c |  170 +++++++++++++++++++++++++++++++++-----
 include/video/sh_mobile_lcdc.h   |    1 
 3 files changed, 150 insertions(+), 22 deletions(-)

--- 0001/drivers/video/Kconfig
+++ work/drivers/video/Kconfig	2008-12-19 14:17:44.000000000 +0900
@@ -1893,6 +1893,7 @@ config FB_SH_MOBILE_LCDC
 	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-19 14:17:59.000000000 +0900
@@ -16,7 +16,9 @@
 #include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/interrupt.h>
 #include <video/sh_mobile_lcdc.h>
+#include <asm/atomic.h>
 
 #define PALETTE_NR 16
 
@@ -30,11 +32,14 @@ struct sh_mobile_lcdc_chan {
 	u32 pseudo_palette[PALETTE_NR];
 	struct fb_info info;
 	dma_addr_t dma_handle;
+	struct fb_deferred_io defio;
 };
 
 struct sh_mobile_lcdc_priv {
 	void __iomem *base;
+	int irq;
 #ifdef CONFIG_HAVE_CLK
+	atomic_t clk_usecnt;
 	struct clk *dot_clk;
 	struct clk *clk;
 #endif
@@ -57,7 +62,7 @@ struct sh_mobile_lcdc_priv {
 
 /* per-channel registers */
 enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R,
-       LDSA1R, LDMLSR, LDHCNR, LDHSYNR, LDVLNR, LDVSYNR, LDPMR };
+       LDSM2R, LDSA1R, LDMLSR, LDHCNR, LDHSYNR, LDVLNR, LDVSYNR, LDPMR };
 
 static unsigned long lcdc_offs_mainlcd[] = {
 	[LDDCKPAT1R] = 0x400,
@@ -67,6 +72,7 @@ static unsigned long lcdc_offs_mainlcd[]
 	[LDMT3R] = 0x420,
 	[LDDFR] = 0x424,
 	[LDSM1R] = 0x428,
+	[LDSM2R] = 0x42c,
 	[LDSA1R] = 0x430,
 	[LDMLSR] = 0x438,
 	[LDHCNR] = 0x448,
@@ -84,6 +90,7 @@ static unsigned long lcdc_offs_sublcd[] 
 	[LDMT3R] = 0x608,
 	[LDDFR] = 0x60c,
 	[LDSM1R] = 0x610,
+	[LDSM2R] = 0x614,
 	[LDSA1R] = 0x618,
 	[LDMLSR] = 0x620,
 	[LDHCNR] = 0x624,
@@ -97,6 +104,8 @@ static unsigned long lcdc_offs_sublcd[] 
 #define LCDC_RESET	0x00000100
 #define DISPLAY_BEU	0x00000008
 #define LCDC_ENABLE	0x00000001
+#define LDINTR_FE	0x00000400
+#define LDINTR_FS	0x00000004
 
 static void lcdc_write_chan(struct sh_mobile_lcdc_chan *chan,
 			    int reg_nr, unsigned long data)
@@ -171,6 +180,65 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mob
 	lcdc_sys_read_data,
 };
 
+#ifdef CONFIG_HAVE_CLK
+static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
+{
+	if (atomic_inc_and_test(&priv->clk_usecnt)) {
+		clk_enable(priv->clk);
+		if (priv->dot_clk)
+			clk_enable(priv->dot_clk);
+	}
+}
+
+static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv)
+{
+	if (atomic_sub_return(1, &priv->clk_usecnt) == -1) {
+		if (priv->dot_clk)
+			clk_disable(priv->dot_clk);
+		clk_disable(priv->clk);
+	}
+}
+#else
+static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv) {}
+static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv) {}
+#endif
+
+static void sh_mobile_lcdc_deferred_io(struct fb_info *info,
+				       struct list_head *pagelist)
+{
+	struct sh_mobile_lcdc_chan *ch = info->par;
+
+	/* enable clocks before accessing hardware */
+	sh_mobile_lcdc_clk_on(ch->lcdc);
+
+	/* trigger panel update */
+	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;
+	unsigned long tmp;
+
+	/* acknowledge interrupt */
+	tmp = lcdc_read(priv, _LDINTR);
+	tmp &= 0xffffff00; /* mask in high 24 bits */
+	tmp |= 0x000000ff ^ LDINTR_FS; /* status in low 8 */
+	lcdc_write(priv, _LDINTR, tmp);
+
+	/* disable clocks */
+	sh_mobile_lcdc_clk_off(priv);
+	return IRQ_HANDLED;
+}
+
 static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv,
 				      int start)
 {
@@ -208,11 +276,11 @@ static int sh_mobile_lcdc_start(struct s
 	int k, m;
 	int ret = 0;
 
-#ifdef CONFIG_HAVE_CLK
-	clk_enable(priv->clk);
-	if (priv->dot_clk)
-		clk_enable(priv->dot_clk);
-#endif
+	/* enable clocks before accessing the hardware */
+	for (k = 0; k < ARRAY_SIZE(priv->ch); k++)
+		if (priv->ch[k].enabled)
+			sh_mobile_lcdc_clk_on(priv);
+
 	/* reset */
 	lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET);
 	lcdc_wait_bit(priv, _LDCNT2R, LCDC_RESET, 0);
@@ -255,7 +323,7 @@ static int sh_mobile_lcdc_start(struct s
 	lcdc_write(priv, _LDDCKSTPR, 0);
 	lcdc_wait_bit(priv, _LDDCKSTPR, ~0, 0);
 
-	/* interrupts are disabled */
+	/* interrupts are disabled to begin with */
 	lcdc_write(priv, _LDINTR, 0);
 
 	for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
@@ -316,9 +384,6 @@ static int sh_mobile_lcdc_start(struct s
 			return ret;
 	}
 
-	/* --- display_lcdc_data() --- */
-	lcdc_write(priv, _LDINTR, 0x00000f00);
-
 	/* word and long word swap */
 	lcdc_write(priv, _LDDDSR, lcdc_read(priv, _LDDDSR) | 6);
 
@@ -340,8 +405,24 @@ static int sh_mobile_lcdc_start(struct s
 		/* set line size */
 		lcdc_write_chan(ch, LDMLSR, ch->info.fix.line_length);
 
-		/* continuous read mode */
-		lcdc_write_chan(ch, LDSM1R, 0);
+		/* setup deferred io if SYS bus */
+		tmp = ch->cfg.sys_bus_cfg.deferred_io_msec;
+		if (ch->ldmt1r_value & (1 << 12) && tmp) {
+			ch->defio.deferred_io = sh_mobile_lcdc_deferred_io;
+			ch->defio.delay = msecs_to_jiffies(tmp);
+			ch->info.fbdefio = &ch->defio;
+			fb_deferred_io_init(&ch->info);
+
+			/* one-shot mode */
+			lcdc_write_chan(ch, LDSM1R, 1);
+
+			/* enable "Frame End Interrupt Enable" bit */
+			lcdc_write(priv, _LDINTR, LDINTR_FE);
+
+		} else {
+			/* continuous read mode */
+			lcdc_write_chan(ch, LDSM1R, 0);
+		}
 	}
 
 	/* display output */
@@ -365,6 +446,7 @@ static void sh_mobile_lcdc_stop(struct s
 {
 	struct sh_mobile_lcdc_chan *ch;
 	struct sh_mobile_lcdc_board_cfg	*board_cfg;
+	unsigned long tmp;
 	int k;
 
 	/* tell the board code to disable the panel */
@@ -373,16 +455,22 @@ static void sh_mobile_lcdc_stop(struct s
 		board_cfg = &ch->cfg.board_cfg;
 		if (board_cfg->display_off)
 			board_cfg->display_off(board_cfg->board_data);
+
+		/* cleanup deferred io if SYS bus */
+		tmp = ch->cfg.sys_bus_cfg.deferred_io_msec;
+		if (ch->ldmt1r_value & (1 << 12) && tmp) {
+			fb_deferred_io_cleanup(&ch->info);
+			ch->info.fbdefio = NULL;
+		}
 	}
 
 	/* stop the lcdc */
 	sh_mobile_lcdc_start_stop(priv, 0);
 
-#ifdef CONFIG_HAVE_CLK
-	if (priv->dot_clk)
-		clk_disable(priv->dot_clk);
-	clk_disable(priv->clk);
-#endif
+	/* stop clocks */
+	for (k = 0; k < ARRAY_SIZE(priv->ch); k++)
+		if (priv->ch[k].enabled)
+			sh_mobile_lcdc_clk_off(priv);
 }
 
 static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch)
@@ -446,6 +534,7 @@ static int sh_mobile_lcdc_setup_clocks(s
 	priv->lddckr = icksel << 16;
 
 #ifdef CONFIG_HAVE_CLK
+	atomic_set(&priv->clk_usecnt, -1);
 	snprintf(clk_name, sizeof(clk_name), "lcdc%d", pdev->id);
 	priv->clk = clk_get(&pdev->dev, clk_name);
 	if (IS_ERR(priv->clk)) {
@@ -497,13 +586,34 @@ 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	= sys_fillrect,
-	.fb_copyarea	= sys_copyarea,
-	.fb_imageblit	= sys_imageblit,
+	.fb_fillrect	= sh_mobile_lcdc_fillrect,
+	.fb_copyarea	= sh_mobile_lcdc_copyarea,
+	.fb_imageblit	= sh_mobile_lcdc_imageblit,
 };
 
 static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp)
@@ -564,8 +674,9 @@ static int __init sh_mobile_lcdc_probe(s
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "cannot find IO resource\n");
+	i = platform_get_irq(pdev, 0);
+	if (!res || i < 0) {
+		dev_err(&pdev->dev, "cannot get platform resources\n");
 		error = -ENOENT;
 		goto err0;
 	}
@@ -577,6 +688,14 @@ static int __init sh_mobile_lcdc_probe(s
 		goto err0;
 	}
 
+	error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED,
+			    pdev->dev.bus_id, priv);
+	if (error) {
+		dev_err(&pdev->dev, "unable to request irq\n");
+		goto err1;
+	}
+
+	priv->irq = i;
 	platform_set_drvdata(pdev, priv);
 	pdata = pdev->dev.platform_data;
 
@@ -660,6 +779,7 @@ static int __init sh_mobile_lcdc_probe(s
 		info->fix.smem_start = priv->ch[i].dma_handle;
 		info->screen_base = buf;
 		info->device = &pdev->dev;
+		info->par = &priv->ch[i];
 	}
 
 	if (error)
@@ -687,6 +807,10 @@ static int __init sh_mobile_lcdc_probe(s
 			 (int) priv->ch[i].cfg.lcd_cfg.xres,
 			 (int) priv->ch[i].cfg.lcd_cfg.yres,
 			 priv->ch[i].cfg.bpp);
+
+		/* deferred io mode: disable clock to save power */
+		if (info->fbdefio)
+			sh_mobile_lcdc_clk_off(priv);
 	}
 
 	return 0;
@@ -728,6 +852,8 @@ static int sh_mobile_lcdc_remove(struct 
 	if (priv->base)
 		iounmap(priv->base);
 
+	if (priv->irq)
+		free_irq(priv->irq, priv);
 	kfree(priv);
 	return 0;
 }
--- 0001/include/video/sh_mobile_lcdc.h
+++ work/include/video/sh_mobile_lcdc.h	2008-12-19 14:17:44.000000000 +0900
@@ -37,6 +37,7 @@ enum { LCDC_CLK_BUS, LCDC_CLK_PERIPHERAL
 struct sh_mobile_lcdc_sys_bus_cfg {
 	unsigned long ldmt2r;
 	unsigned long ldmt3r;
+	unsigned long deferred_io_msec;
 };
 
 struct sh_mobile_lcdc_sys_bus_ops {

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

* [PATCH 05/05] sh: enable deferred io LCDC on Migo-R
  2008-12-19  6:33 [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Magnus Damm
                   ` (3 preceding siblings ...)
  2008-12-19  6:34 ` [PATCH 04/05] video: sh_mobile_lcdcfb deferred io support Magnus Damm
@ 2008-12-19  6:34 ` Magnus Damm
  2008-12-21  6:53 ` [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Paul Mundt
  5 siblings, 0 replies; 14+ messages in thread
From: Magnus Damm @ 2008-12-19  6:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Magnus Damm, lethal, adaplas, linux-sh

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

Enable LCDC deferred io on Migo-R using 1s delay.

As with other deferred io frame buffers user space code should
use fsync() on the frame buffer device to trigger an update.

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

 arch/sh/boards/mach-migor/setup.c |    2 ++
 1 file changed, 2 insertions(+)

--- 0008/arch/sh/boards/mach-migor/setup.c
+++ work/arch/sh/boards/mach-migor/setup.c	2008-12-18 13:59:06.000000000 +0900
@@ -262,6 +262,8 @@ static struct sh_mobile_lcdc_info sh_mob
 		.sys_bus_cfg = {
 			.ldmt2r = 0x06000a09,
 			.ldmt3r = 0x180e3418,
+			/* set 1s delay to encourage fsync() */
+			.deferred_io_msec = 1000,
 		},
 	}
 #endif

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

* Re: [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support
  2008-12-19  6:33 [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Magnus Damm
                   ` (4 preceding siblings ...)
  2008-12-19  6:34 ` [PATCH 05/05] sh: enable deferred io LCDC on Migo-R Magnus Damm
@ 2008-12-21  6:53 ` Paul Mundt
  2008-12-21  7:11   ` Jaya Kumar
  5 siblings, 1 reply; 14+ messages in thread
From: Paul Mundt @ 2008-12-21  6:53 UTC (permalink / raw)
  To: Magnus Damm, Jaya Kumar; +Cc: linux-fbdev-devel, adaplas, linux-sh

On Fri, Dec 19, 2008 at 03:33:59PM +0900, Magnus Damm wrote:
> video: deferred io fixes and sh_mobile_lcdcfb support
> 
> [PATCH 01/05] video: fix deferred io fsync()
> [PATCH 02/05] video: deferred io cleanup
> [PATCH 03/05] video: deferred io with physically contiguous memory
> [PATCH 04/05] video: sh_mobile_lcdcfb deferred io support 
> [PATCH 05/05] sh: enable deferred io LCDC on Migo-R
> 
> This patchset adds deferred io support to sh_mobile_lcdcfb.
> 
> The LCDC hardware block managed by the sh_mobile_lcdcfb driver supports
> RGB or SYS panel configurations. SYS panels come with an external display
> controller that is resposible for refreshing the actual LCD panel. RGB
> panels are controlled directly by the LCDC and they need to be refreshed
> by the LCDC hardware.
> 
> In the case of SYS panels we can save some power by configuring the LCDC
> hardware block in one-shot mode. In this one-shot mode panel refresh is
> managed by software. This works well together with deferred io since it
> allows us to stop clocks for most of the time and only enable clocks when
> we actually want to trigger an update. When there is no fbdev activity
> the clocks are kept stopped which allows us to deep sleep.
> 
> May I suggest merging the first 3 patches with other framebuffer changes,
> but handling patch 4 and 5 with other SuperH changes? That strategy
> should be fine since there are no compile time dependencies. To keep
> things running please apply patch number 5 when all other changes are in.
> 
> Signed-off-by: Magnus Damm <damm@igel.co.jp>

I have no particular issues with this series anyways. If Jaya is fine
with the first three, I will take the last two. Or I can just take the entire
series, as it's fairly insular and no one else is likely to care about it
presently. Jaya?

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

* Re: [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support
  2008-12-21  6:53 ` [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Paul Mundt
@ 2008-12-21  7:11   ` Jaya Kumar
  2008-12-21 16:14     ` Paul Mundt
  0 siblings, 1 reply; 14+ messages in thread
From: Jaya Kumar @ 2008-12-21  7:11 UTC (permalink / raw)
  To: Paul Mundt, Magnus Damm, Jaya Kumar, linux-fbdev-devel, adaplas

On Sun, Dec 21, 2008 at 1:53 AM, Paul Mundt <lethal@linux-sh.org> wrote:
>
> I have no particular issues with this series anyways. If Jaya is fine
> with the first three, I will take the last two. Or I can just take the entire
> series, as it's fairly insular and no one else is likely to care about it
> presently. Jaya?
>

Hi Paul,

Looks fine to me too. Nice work. Thanks for the effort Magnus.

I agree that it'd be best if you could take the entire series as it is
self-contained, plus there's no fbdev specific tree currently and I'm
not sure if Tony is back yet.

Thanks,
jaya

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

* Re: [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support
  2008-12-21  7:11   ` Jaya Kumar
@ 2008-12-21 16:14     ` Paul Mundt
  2008-12-24  5:01       ` Jaya Kumar
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Mundt @ 2008-12-21 16:14 UTC (permalink / raw)
  To: Jaya Kumar; +Cc: Magnus Damm, linux-fbdev-devel, adaplas, linux-sh

On Sun, Dec 21, 2008 at 02:11:50AM -0500, Jaya Kumar wrote:
> On Sun, Dec 21, 2008 at 1:53 AM, Paul Mundt <lethal@linux-sh.org> wrote:
> >
> > I have no particular issues with this series anyways. If Jaya is fine
> > with the first three, I will take the last two. Or I can just take the entire
> > series, as it's fairly insular and no one else is likely to care about it
> > presently. Jaya?
> >
> 
> Hi Paul,
> 
> Looks fine to me too. Nice work. Thanks for the effort Magnus.
> 
> I agree that it'd be best if you could take the entire series as it is
> self-contained, plus there's no fbdev specific tree currently and I'm
> not sure if Tony is back yet.
> 
Ok, I will carry it then. Can I add your Acked-by?

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

* Re: [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support
  2008-12-21 16:14     ` Paul Mundt
@ 2008-12-24  5:01       ` Jaya Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Jaya Kumar @ 2008-12-24  5:01 UTC (permalink / raw)
  To: Paul Mundt, Jaya Kumar, Magnus Damm, linux-fbdev-devel, adaplas

On Sun, Dec 21, 2008 at 11:14 AM, Paul Mundt <lethal@linux-sh.org> wrote:
> On Sun, Dec 21, 2008 at 02:11:50AM -0500, Jaya Kumar wrote:
>> On Sun, Dec 21, 2008 at 1:53 AM, Paul Mundt <lethal@linux-sh.org> wrote:
>> >
>> > I have no particular issues with this series anyways. If Jaya is fine
>> > with the first three, I will take the last two. Or I can just take the entire
>> > series, as it's fairly insular and no one else is likely to care about it
>> > presently. Jaya?
>> >
>>
>> Hi Paul,
>>
>> Looks fine to me too. Nice work. Thanks for the effort Magnus.
>>
>> I agree that it'd be best if you could take the entire series as it is
>> self-contained, plus there's no fbdev specific tree currently and I'm
>> not sure if Tony is back yet.
>>
> Ok, I will carry it then. Can I add your Acked-by?
>

Ok, I'll find Magnus' patches and add my Acked-by to be thorough for each one.

Thanks,
jaya

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

* Re: [Linux-fbdev-devel] [PATCH 01/05] video: fix deferred io fsync()
  2008-12-19  6:34 ` [PATCH 01/05] video: fix deferred io fsync() Magnus Damm
@ 2008-12-24  5:05   ` Jaya Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Jaya Kumar @ 2008-12-24  5:05 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-fbdev-devel, lethal, adaplas, linux-sh

On Fri, Dec 19, 2008 at 1:34 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> From: Magnus Damm <damm@igel.co.jp>
>
> If CONFIG_FB_DEFERRED_IO is set, but there are framebuffers
> registered that does not make use of deferred io, then fsync()
> on those framebuffers will result in a crash. Fix that.
>
> This is needed for sh_mobile_lcdcfb since we always enable
> deferred io at compile time but we may disable deferred io
> for some types of hardware configurations.
>
> Signed-off-by: Magnus Damm <damm@igel.co.jp>

Acked-by: Jaya Kumar <jayakumar.lkml@gmail.com>

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

* Re: [Linux-fbdev-devel] [PATCH 02/05] video: deferred io cleanup
  2008-12-19  6:34 ` [PATCH 02/05] video: deferred io cleanup Magnus Damm
@ 2008-12-24  5:05   ` Jaya Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Jaya Kumar @ 2008-12-24  5:05 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-fbdev-devel, lethal, adaplas, linux-sh

On Fri, Dec 19, 2008 at 1:34 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> From: Magnus Damm <damm@igel.co.jp>
>
> Make sure the mmap callback is set to NULL in the deferred io
> cleanup function. This way we can enable and disable deferred
> io on the fly.
>
> Signed-off-by: Magnus Damm <damm@igel.co.jp>


Acked-by: Jaya Kumar <jayakumar.lkml@gmail.com>

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

* Re: [Linux-fbdev-devel] [PATCH 03/05] video: deferred io with physically contiguous memory
  2008-12-19  6:34 ` [PATCH 03/05] video: deferred io with physically contiguous memory Magnus Damm
@ 2008-12-24  5:13   ` Jaya Kumar
  2008-12-25 19:04     ` Jaya Kumar
  0 siblings, 1 reply; 14+ messages in thread
From: Jaya Kumar @ 2008-12-24  5:13 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-fbdev-devel, lethal, adaplas, linux-sh

On Fri, Dec 19, 2008 at 1:34 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> From: Magnus Damm <damm@igel.co.jp>
>
> Extend the deferred io code from only supporting vmalloc()ed frame
> buffer memory to support both vmalloc()ed and physically contiguous
> frame buffer memory.
>
> The sh_mobile_lcdcfb hardware does not support scatter gather so
> we need physically contiguous memory to back our frame buffer.
>
> Signed-off-by: Magnus Damm <damm@igel.co.jp>
> ---
>
>  drivers/video/fb_defio.c |   20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> --- 0003/drivers/video/fb_defio.c
> +++ work/drivers/video/fb_defio.c       2008-12-19 14:29:45.000000000 +0900
> @@ -24,6 +24,19 @@
>  #include <linux/rmap.h>
>  #include <linux/pagemap.h>
>
> +struct page *fb_deferred_io_page(struct fb_info *info, unsigned long offs)
> +{
> +       void *screen_base = (void __force *) info->screen_base;
> +       struct page *page;
> +
> +       if (is_vmalloc_addr(screen_base + offs))
> +               page = vmalloc_to_page(screen_base + offs);
> +       else
> +               page = pfn_to_page((info->fix.smem_start + offs) >> PAGE_SHIFT);
> +
> +       return page;
> +}
> +

Just nitpicking about naming. I think a better name is possible for
above, no? Like fb_to_page or fbdefio_to_page or similar to remain
consistent with vmalloc/pfn_to_page. Also the comment below about
vmalloc-ed pages would no longer be accurate. Otherwise, looks fine.

Acked-by: Jaya Kumar <jayakumar.lkml@gmail.com>

>  /* this is to find and return the vmalloc-ed fb pages */
>  static int fb_deferred_io_fault(struct vm_area_struct *vma,
>                                struct vm_fault *vmf)
> @@ -31,14 +44,12 @@ static int fb_deferred_io_fault(struct v
>        unsigned long offset;
>        struct page *page;
>        struct fb_info *info = vma->vm_private_data;
> -       /* info->screen_base is virtual memory */
> -       void *screen_base = (void __force *) info->screen_base;
>
>        offset = vmf->pgoff << PAGE_SHIFT;
>        if (offset >= info->fix.smem_len)
>                return VM_FAULT_SIGBUS;
>
> -       page = vmalloc_to_page(screen_base + offset);
> +       page = fb_deferred_io_page(info, offset);
>        if (!page)
>                return VM_FAULT_SIGBUS;
>
> @@ -188,7 +199,6 @@ EXPORT_SYMBOL_GPL(fb_deferred_io_open);
>
>  void fb_deferred_io_cleanup(struct fb_info *info)
>  {
> -       void *screen_base = (void __force *) info->screen_base;
>        struct fb_deferred_io *fbdefio = info->fbdefio;
>        struct page *page;
>        int i;
> @@ -199,7 +209,7 @@ void fb_deferred_io_cleanup(struct fb_in
>
>        /* clear out the mapping that we setup */
>        for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) {
> -               page = vmalloc_to_page(screen_base + i);
> +               page = fb_deferred_io_page(info, i);
>                page->mapping = NULL;
>        }
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Linux-fbdev-devel mailing list
> Linux-fbdev-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
>

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

* Re: [Linux-fbdev-devel] [PATCH 03/05] video: deferred io with physically contiguous memory
  2008-12-24  5:13   ` [Linux-fbdev-devel] " Jaya Kumar
@ 2008-12-25 19:04     ` Jaya Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Jaya Kumar @ 2008-12-25 19:04 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-fbdev-devel, lethal, adaplas, linux-sh

On Wed, Dec 24, 2008 at 12:13 AM, Jaya Kumar <jayakumar.lkml@gmail.com> wrote:
> On Fri, Dec 19, 2008 at 1:34 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
>> From: Magnus Damm <damm@igel.co.jp>
>>
>> Extend the deferred io code from only supporting vmalloc()ed frame
>> buffer memory to support both vmalloc()ed and physically contiguous
>> frame buffer memory.
>>
>> The sh_mobile_lcdcfb hardware does not support scatter gather so
>> we need physically contiguous memory to back our frame buffer.
>>
>> Signed-off-by: Magnus Damm <damm@igel.co.jp>
>> ---
>>
>>  drivers/video/fb_defio.c |   20 +++++++++++++++-----
>>  1 file changed, 15 insertions(+), 5 deletions(-)
>>
>> --- 0003/drivers/video/fb_defio.c
>> +++ work/drivers/video/fb_defio.c       2008-12-19 14:29:45.000000000 +0900
>> @@ -24,6 +24,19 @@
>>  #include <linux/rmap.h>
>>  #include <linux/pagemap.h>
>>
>> +struct page *fb_deferred_io_page(struct fb_info *info, unsigned long offs)

I think this should be a static function.

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

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

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-19  6:33 [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Magnus Damm
2008-12-19  6:34 ` [PATCH 01/05] video: fix deferred io fsync() Magnus Damm
2008-12-24  5:05   ` [Linux-fbdev-devel] " Jaya Kumar
2008-12-19  6:34 ` [PATCH 02/05] video: deferred io cleanup Magnus Damm
2008-12-24  5:05   ` [Linux-fbdev-devel] " Jaya Kumar
2008-12-19  6:34 ` [PATCH 03/05] video: deferred io with physically contiguous memory Magnus Damm
2008-12-24  5:13   ` [Linux-fbdev-devel] " Jaya Kumar
2008-12-25 19:04     ` Jaya Kumar
2008-12-19  6:34 ` [PATCH 04/05] video: sh_mobile_lcdcfb deferred io support Magnus Damm
2008-12-19  6:34 ` [PATCH 05/05] sh: enable deferred io LCDC on Migo-R Magnus Damm
2008-12-21  6:53 ` [PATCH 00/05] video: deferred io fixes and sh_mobile_lcdcfb support Paul Mundt
2008-12-21  7:11   ` Jaya Kumar
2008-12-21 16:14     ` Paul Mundt
2008-12-24  5:01       ` Jaya Kumar

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