linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] initial suspend and resume support
@ 2010-09-24  4:50 Florian Tobias Schandinat
  2010-09-24  4:50 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Florian Tobias Schandinat @ 2010-09-24  4:50 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-kernel, Florian Tobias Schandinat, Jonathan Corbet

Hi,

this little patch series finally adds basic suspend and resume support.
The good thing is, that it nearly works. Well in fact it should work
fine if the only connected device is a CRT. For other devices it might
happen that suspend and resume works but the screen stays black. This
is probably caused by auxiliary devices that are connect via I2C lines
and not yet reinitialized properly.
This should be a huge improvent above the current behaviour, especially
the hardware acceleration including a visible cursor works.

As usual tests were performed on CLE266, VX800 and VX855.
These patches are also available on
	git://github.com/schandinat/linux-2.6.git viafb-s4v1

Happy testing :)


Thanks,

Florian Tobias Schandinat


Deepak Saxena (1):
  Minimal support for viafb suspend/resume

Florian Tobias Schandinat (3):
  viafb: restore display on resume
  viafb: make suspend and resume work (on all machines?)
  viafb: fix hardware acceleration for suspend & resume

 drivers/video/via/accel.c    |   43 +++++++++++++++++++++++++----------------
 drivers/video/via/accel.h    |    3 +-
 drivers/video/via/via-core.c |    4 +++
 drivers/video/via/viafbdev.c |   43 +++++++++++++++++++++++++++++++++++++++++-
 drivers/video/via/viafbdev.h |    2 +
 5 files changed, 76 insertions(+), 19 deletions(-)


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

* [PATCH 1/4] Minimal support for viafb suspend/resume
  2010-09-24  4:50 [PATCH 0/4] initial suspend and resume support Florian Tobias Schandinat
@ 2010-09-24  4:50 ` Florian Tobias Schandinat
  2010-09-24  4:50 ` [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume Florian Tobias Schandinat
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Tobias Schandinat @ 2010-09-24  4:50 UTC (permalink / raw)
  To: linux-fbdev
  Cc: linux-kernel, Deepak Saxena, Florian Tobias Schandinat,
	Joseph Chan, Jonathan Corbet

From: Deepak Saxena <dsaxena@laptop.org>

This patch adds minimal support for suspend/resume of the
VIA framebuffer device. It requires a version of OFW
that restores the video mode.

This patch is OLPC-specific as the proper upstream solution
is to move the VIA video path to using the kernel modesetting
infrastructure and doing a proper save/restore in the kernel.

[jc: extensive changes for 2.6.34 merge]
Signed-off-by: Deepak Saxena <dsaxena@laptop.org>
[fts: viafb_driver moved from viafbdev.c to via-core.c]
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Joseph Chan <JosephChan@via.com.tw>
Cc: Jonathan Corbet <corbet@lwn.net>
---
 drivers/video/via/via-core.c |    4 +++
 drivers/video/via/viafbdev.c |   46 ++++++++++++++++++++++++++++++++++++++++++
 drivers/video/via/viafbdev.h |    5 ++++
 3 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c
index 66f4030..bca9e9d 100644
--- a/drivers/video/via/via-core.c
+++ b/drivers/video/via/via-core.c
@@ -644,6 +644,10 @@ static struct pci_driver via_driver = {
 	.id_table	= via_pci_table,
 	.probe		= via_pci_probe,
 	.remove		= __devexit_p(via_pci_remove),
+#ifdef CONFIG_PM
+	.suspend	= viafb_suspend,
+	.resume		= viafb_resume,
+#endif
 };
 
 static int __init via_core_init(void)
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index bdd0e41..f2b68cc 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1486,6 +1486,52 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres)
 }
 
 
+#ifdef CONFIG_PM
+int viafb_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	if (state.event = PM_EVENT_SUSPEND) {
+		acquire_console_sem();
+
+		memcpy_fromio(viaparinfo->shared->saved_regs,
+			      viaparinfo->shared->vdev->engine_mmio + 0x100,
+			      0xff * sizeof(u32));
+
+		fb_set_suspend(viafbinfo, 1);
+
+		viafb_sync(viafbinfo);
+
+		pci_save_state(pdev);
+		pci_disable_device(pdev);
+		pci_set_power_state(pdev, pci_choose_state(pdev, state));
+		release_console_sem();
+	}
+
+	return 0;
+}
+
+int viafb_resume(struct pci_dev *pdev)
+{
+	acquire_console_sem();
+	pci_set_power_state(pdev, PCI_D0);
+	pci_restore_state(pdev);
+	if (pci_enable_device(pdev))
+		goto fail;
+	pci_set_master(pdev);
+
+	memcpy_toio(viaparinfo->shared->vdev->engine_mmio + 0x100,
+		    viaparinfo->shared->saved_regs,
+		    0x100 * sizeof(u32));
+
+	fb_set_suspend(viafbinfo, 0);
+
+fail:
+	release_console_sem();
+	return 0;
+}
+
+#endif
+
+
 int __devinit via_fb_pci_probe(struct viafb_dev *vdev)
 {
 	u32 default_xres, default_yres;
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index 52a35fa..3bcae0a 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -57,6 +57,9 @@ struct viafb_shared {
 		u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y,
 		u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,
 		u32 fg_color, u32 bg_color, u8 fill_rop);
+
+	/* For suspend/resume */
+	u32 saved_regs[0x100];
 };
 
 struct viafb_par {
@@ -103,4 +106,6 @@ void via_fb_pci_remove(struct pci_dev *pdev);
 /* Temporary */
 int viafb_init(void);
 void viafb_exit(void);
+int viafb_suspend(struct pci_dev *pdev, pm_message_t state);
+int viafb_resume(struct pci_dev *pdev);
 #endif /* __VIAFBDEV_H__ */
-- 
1.6.3.2


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

* [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume
  2010-09-24  4:50 [PATCH 0/4] initial suspend and resume support Florian Tobias Schandinat
  2010-09-24  4:50 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
@ 2010-09-24  4:50 ` Florian Tobias Schandinat
  2010-09-24  4:51 ` [PATCH 2/4] viafb: restore display on resume Florian Tobias Schandinat
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Tobias Schandinat @ 2010-09-24  4:50 UTC (permalink / raw)
  To: linux-fbdev
  Cc: linux-kernel, Florian Tobias Schandinat, Joseph Chan,
	Jonathan Corbet

This patch splits the acceleration initialization in two parts:
The first is only called during probe and is used to allocate
resources. The second part is also called on resume to reinitalize
the 2D engine. This should fix all acceleration issues after resume
most notable an "invisible" cursor and as we do nothing special it is
reasonable to assume that it works on all supported IGPs.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Joseph Chan <JosephChan@via.com.tw>
Cc: Jonathan Corbet <corbet@lwn.net>
---
 drivers/video/via/accel.c    |   43 +++++++++++++++++++++++++----------------
 drivers/video/via/accel.h    |    3 +-
 drivers/video/via/viafbdev.c |    4 ++-
 3 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c
index e44893e..ae0bdf6 100644
--- a/drivers/video/via/accel.c
+++ b/drivers/video/via/accel.c
@@ -314,13 +314,11 @@ static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,
 	return 0;
 }
 
-int viafb_init_engine(struct fb_info *info)
+int viafb_setup_engine(struct fb_info *info)
 {
 	struct viafb_par *viapar = info->par;
 	void __iomem *engine;
-	int highest_reg, i;
-	u32 vq_start_addr, vq_end_addr, vq_start_low, vq_end_low, vq_high,
-		vq_len, chip_name = viapar->shared->chip_info.gfx_chip_name;
+	u32 chip_name = viapar->shared->chip_info.gfx_chip_name;
 
 	engine = viapar->shared->vdev->engine_mmio;
 	if (!engine) {
@@ -329,18 +327,6 @@ int viafb_init_engine(struct fb_info *info)
 		return -ENOMEM;
 	}
 
-	/* Initialize registers to reset the 2D engine */
-	switch (viapar->shared->chip_info.twod_engine) {
-	case VIA_2D_ENG_M1:
-		highest_reg = 0x5c;
-		break;
-	default:
-		highest_reg = 0x40;
-		break;
-	}
-	for (i = 0; i <= highest_reg; i += 4)
-		writel(0x0, engine + i);
-
 	switch (chip_name) {
 	case UNICHROME_CLE266:
 	case UNICHROME_K400:
@@ -386,6 +372,29 @@ int viafb_init_engine(struct fb_info *info)
 	viapar->shared->vdev->camera_fbmem_offset = viapar->fbmem_free;
 #endif
 
+	viafb_reset_engine(viapar);
+	return 0;
+}
+
+void viafb_reset_engine(struct viafb_par *viapar)
+{
+	void __iomem *engine = viapar->shared->vdev->engine_mmio;
+	int highest_reg, i;
+	u32 vq_start_addr, vq_end_addr, vq_start_low, vq_end_low, vq_high,
+		vq_len, chip_name = viapar->shared->chip_info.gfx_chip_name;
+
+	/* Initialize registers to reset the 2D engine */
+	switch (viapar->shared->chip_info.twod_engine) {
+	case VIA_2D_ENG_M1:
+		highest_reg = 0x5c;
+		break;
+	default:
+		highest_reg = 0x40;
+		break;
+	}
+	for (i = 0; i <= highest_reg; i += 4)
+		writel(0x0, engine + i);
+
 	/* Init AGP and VQ regs */
 	switch (chip_name) {
 	case UNICHROME_K8M890:
@@ -473,7 +482,7 @@ int viafb_init_engine(struct fb_info *info)
 	writel(0x0, engine + VIA_REG_CURSOR_ORG);
 	writel(0x0, engine + VIA_REG_CURSOR_BG);
 	writel(0x0, engine + VIA_REG_CURSOR_FG);
-	return 0;
+	return;
 }
 
 void viafb_show_hw_cursor(struct fb_info *info, int Status)
diff --git a/drivers/video/via/accel.h b/drivers/video/via/accel.h
index 2c122d2..79d5e10 100644
--- a/drivers/video/via/accel.h
+++ b/drivers/video/via/accel.h
@@ -203,7 +203,8 @@
 #define VIA_BITBLT_MONO		2
 #define VIA_BITBLT_FILL		3
 
-int viafb_init_engine(struct fb_info *info);
+int viafb_setup_engine(struct fb_info *info);
+void viafb_reset_engine(struct viafb_par *viapar);
 void viafb_show_hw_cursor(struct fb_info *info, int Status);
 void viafb_wait_engine_idle(struct fb_info *info);
 
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index c4218ce..fdb1e84 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1512,6 +1512,8 @@ int viafb_resume(struct pci_dev *pdev)
 	if (pci_enable_device(pdev))
 		goto fail;
 	pci_set_master(pdev);
+	if (viaparinfo->shared->vdev->engine_mmio)
+		viafb_reset_engine(viaparinfo);
 	viafb_set_par(viafbinfo);
 	if (viafb_dual_fb)
 		viafb_set_par(viafbinfo1);
@@ -1583,7 +1585,7 @@ int __devinit via_fb_pci_probe(struct viafb_dev *vdev)
 	viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
 
 	viafbinfo->pseudo_palette = pseudo_pal;
-	if (viafb_accel && !viafb_init_engine(viafbinfo)) {
+	if (viafb_accel && !viafb_setup_engine(viafbinfo)) {
 		viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA |
 			FBINFO_HWACCEL_FILLRECT |  FBINFO_HWACCEL_IMAGEBLIT;
 		default_var.accel_flags = FB_ACCELF_TEXT;
-- 
1.6.3.2


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

* [PATCH 2/4] viafb: restore display on resume
  2010-09-24  4:50 [PATCH 0/4] initial suspend and resume support Florian Tobias Schandinat
  2010-09-24  4:50 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
  2010-09-24  4:50 ` [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume Florian Tobias Schandinat
@ 2010-09-24  4:51 ` Florian Tobias Schandinat
  2010-09-24  4:51 ` [PATCH 3/4] viafb: make suspend and resume work (on all machines?) Florian Tobias Schandinat
  2010-10-06 21:33 ` [PATCH 0/4] initial suspend and resume support Jonathan Corbet
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Tobias Schandinat @ 2010-09-24  4:51 UTC (permalink / raw)
  To: linux-fbdev
  Cc: linux-kernel, Florian Tobias Schandinat, Joseph Chan,
	Jonathan Corbet

This patch makes viafb restore the display on resume by calling
viafb_set_par. Resumeing has still its issues:
- will probably freeze most machines (for me on VX800 reliable on the
  second resume)
- under some configurations the screen appears on the wrong output
  device (reason unknown)

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Joseph Chan <JosephChan@via.com.tw>
Cc: Jonathan Corbet <corbet@lwn.net>
---
 drivers/video/via/viafbdev.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index f2b68cc..5b23293 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1522,6 +1522,9 @@ int viafb_resume(struct pci_dev *pdev)
 		    viaparinfo->shared->saved_regs,
 		    0x100 * sizeof(u32));
 
+	viafb_set_par(viafbinfo);
+	if (viafb_dual_fb)
+		viafb_set_par(viafbinfo1);
 	fb_set_suspend(viafbinfo, 0);
 
 fail:
-- 
1.6.3.2


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

* [PATCH 3/4] viafb: make suspend and resume work (on all machines?)
  2010-09-24  4:50 [PATCH 0/4] initial suspend and resume support Florian Tobias Schandinat
                   ` (2 preceding siblings ...)
  2010-09-24  4:51 ` [PATCH 2/4] viafb: restore display on resume Florian Tobias Schandinat
@ 2010-09-24  4:51 ` Florian Tobias Schandinat
  2010-10-06 21:33 ` [PATCH 0/4] initial suspend and resume support Jonathan Corbet
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Tobias Schandinat @ 2010-09-24  4:51 UTC (permalink / raw)
  To: linux-fbdev
  Cc: linux-kernel, Florian Tobias Schandinat, Joseph Chan,
	Jonathan Corbet

This patch removes the dangerous suspend and resume code that was
developed for VX855 only. After this the framebuffer is expected to
cause no longer serious (freezing) issues on any machines.
However the hardware acceleration is broken now so only doing resume
with unaccelerated framebuffers is save. This did not work previously
as the 2D engine is not mapped if the framebuffer is not accelerated.
The acceleration issue will be addressed later.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Joseph Chan <JosephChan@via.com.tw>
Cc: Jonathan Corbet <corbet@lwn.net>
---
 drivers/video/via/viafbdev.c |   10 ----------
 drivers/video/via/viafbdev.h |    3 ---
 2 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 5b23293..c4218ce 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1491,11 +1491,6 @@ int viafb_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	if (state.event = PM_EVENT_SUSPEND) {
 		acquire_console_sem();
-
-		memcpy_fromio(viaparinfo->shared->saved_regs,
-			      viaparinfo->shared->vdev->engine_mmio + 0x100,
-			      0xff * sizeof(u32));
-
 		fb_set_suspend(viafbinfo, 1);
 
 		viafb_sync(viafbinfo);
@@ -1517,11 +1512,6 @@ int viafb_resume(struct pci_dev *pdev)
 	if (pci_enable_device(pdev))
 		goto fail;
 	pci_set_master(pdev);
-
-	memcpy_toio(viaparinfo->shared->vdev->engine_mmio + 0x100,
-		    viaparinfo->shared->saved_regs,
-		    0x100 * sizeof(u32));
-
 	viafb_set_par(viafbinfo);
 	if (viafb_dual_fb)
 		viafb_set_par(viafbinfo1);
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index 3bcae0a..be2fad6 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -57,9 +57,6 @@ struct viafb_shared {
 		u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y,
 		u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,
 		u32 fg_color, u32 bg_color, u8 fill_rop);
-
-	/* For suspend/resume */
-	u32 saved_regs[0x100];
 };
 
 struct viafb_par {
-- 
1.6.3.2


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

* Re: [PATCH 0/4] initial suspend and resume support
  2010-09-24  4:50 [PATCH 0/4] initial suspend and resume support Florian Tobias Schandinat
                   ` (3 preceding siblings ...)
  2010-09-24  4:51 ` [PATCH 3/4] viafb: make suspend and resume work (on all machines?) Florian Tobias Schandinat
@ 2010-10-06 21:33 ` Jonathan Corbet
  4 siblings, 0 replies; 6+ messages in thread
From: Jonathan Corbet @ 2010-10-06 21:33 UTC (permalink / raw)
  To: Florian Tobias Schandinat; +Cc: linux-fbdev, linux-kernel

On Fri, 24 Sep 2010 05:01:22 +0000
Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:

> this little patch series finally adds basic suspend and resume support.
> The good thing is, that it nearly works.

I finally got around to taking a quick look at this.  It looks fine as
far as it goes, though I'd be tempted to take out the intermediate
steps and reduce the code churn a bit.

I need to dig out the more general suspend/resume stuff I have buried
in one of my trees, we'll need it at some point.  In the mean time, I
see no reason not to go ahead with this work.

Thanks,

jon

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

end of thread, other threads:[~2010-10-06 21:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-24  4:50 [PATCH 0/4] initial suspend and resume support Florian Tobias Schandinat
2010-09-24  4:50 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
2010-09-24  4:50 ` [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume Florian Tobias Schandinat
2010-09-24  4:51 ` [PATCH 2/4] viafb: restore display on resume Florian Tobias Schandinat
2010-09-24  4:51 ` [PATCH 3/4] viafb: make suspend and resume work (on all machines?) Florian Tobias Schandinat
2010-10-06 21:33 ` [PATCH 0/4] initial suspend and resume support Jonathan Corbet

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