Skip to contentSkip to conversation

initial suspend and resume support

PATCH In review Florian Tobias Schandinat 2 participants 6 messages Sep 24, 2010 – Oct 6, 2010 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

cover initial suspend and resume support

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(-)
#1 lore raw

PATCH 1/4 Minimal support for viafb suspend/resume

From: Deepak Saxena <[email protected]>

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]
[fts: viafb_driver moved from viafbdev.c to via-core.c]
Cc Joseph Chan <[email protected]>
Cc Jonathan Corbet <[email protected]>
---
 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(-)
drivers/video/via/via-core.c +4 -0
index 66f4030..bca9e9d 100644
@@ -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)
drivers/video/via/viafbdev.c +46 -0

52 lines not on this page · raw message

drivers/video/via/viafbdev.h +5 -0
index 52a35fa..3bcae0a 100644
@@ -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__ */
Signature · 1 line
1.6.3.2
#2 lore raw

PATCH 2/4 viafb: restore display on resume

In reply to Florian Tobias Schandinat

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)

---
 drivers/video/via/viafbdev.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/video/via/viafbdev.c +3 -0
index f2b68cc..5b23293 100644
@@ -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:
Signature · 1 line
1.6.3.2
#3 lore raw

PATCH 3/4 viafb: make suspend and resume work (on all machines?)

In reply to Florian Tobias Schandinat

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.

---
 drivers/video/via/viafbdev.c |   10 ----------
 drivers/video/via/viafbdev.h |    3 ---
 2 files changed, 0 insertions(+), 13 deletions(-)
drivers/video/via/viafbdev.c +0 -10
index 5b23293..c4218ce 100644
@@ -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);
drivers/video/via/viafbdev.h +0 -3
index 3bcae0a..be2fad6 100644
@@ -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 {
Signature · 1 line
1.6.3.2
#4 lore raw

PATCH 4/4 viafb: fix hardware acceleration for suspend & resume

In reply to Florian Tobias Schandinat

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.

---
 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(-)
drivers/video/via/accel.c +26 -17
index e44893e..ae0bdf6 100644
@@ -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)
drivers/video/via/accel.h +2 -1
index 2c122d2..79d5e10 100644
@@ -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);
 
drivers/video/via/viafbdev.c +3 -1
index c4218ce..fdb1e84 100644
@@ -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;
Signature · 1 line
1.6.3.2
#5 lore raw
In reply to Florian Tobias Schandinat
Quoted 2 lines · On Fri, 24 Sep 2010 05:01:22 +0000 Florian Tobias Schandinat…

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