* viafb suspend & resume, v2
@ 2010-05-02 15:17 Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Florian Tobias Schandinat @ 2010-05-02 15:17 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-fbdev, JosephChan, ScottFang, corbet
This is the second version of this patch series. It is forward ported to apply
on Jon's current viafb-posted branch. Furthermore the engine is only
(re)started if the mmio space is mapped.
There are still issues left especially device configuration and it does not yet
integrate nicely in the new structure of the driver. However it is in a state
where it shouldn't hurt anyone but could be useful for some people.
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] Minimal support for viafb suspend/resume
2010-05-02 15:17 viafb suspend & resume, v2 Florian Tobias Schandinat
@ 2010-05-02 15:17 ` Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 2/4] viafb: restore display on resume Florian Tobias Schandinat
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Florian Tobias Schandinat @ 2010-05-02 15:17 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-fbdev, JosephChan, ScottFang, corbet, Deepak Saxena
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>
---
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 a084363..b9ad283 100644
--- a/drivers/video/via/via-core.c
+++ b/drivers/video/via/via-core.c
@@ -647,6 +647,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 3d03318..1b435b3 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1741,6 +1741,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] 7+ messages in thread
* [PATCH 2/4] viafb: restore display on resume
2010-05-02 15:17 viafb suspend & resume, v2 Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
@ 2010-05-02 15:17 ` Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 3/4] viafb: make suspend and resume work (on all machines?) Florian Tobias Schandinat
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Florian Tobias Schandinat @ 2010-05-02 15:17 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet,
Florian Tobias Schandinat
viafb: restore display on resume
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>
---
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 1b435b3..b4baed6 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1777,6 +1777,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] 7+ messages in thread
* [PATCH 3/4] viafb: make suspend and resume work (on all machines?)
2010-05-02 15:17 viafb suspend & resume, v2 Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 2/4] viafb: restore display on resume Florian Tobias Schandinat
@ 2010-05-02 15:17 ` Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume Florian Tobias Schandinat
2010-05-10 17:56 ` viafb suspend & resume, v2 Bruno Prémont
4 siblings, 0 replies; 7+ messages in thread
From: Florian Tobias Schandinat @ 2010-05-02 15:17 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet,
Florian Tobias Schandinat
viafb: make suspend and resume work (on all machines?)
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>
---
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 b4baed6..b5099b9 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1746,11 +1746,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);
@@ -1772,11 +1767,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] 7+ messages in thread
* [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume
2010-05-02 15:17 viafb suspend & resume, v2 Florian Tobias Schandinat
` (2 preceding siblings ...)
2010-05-02 15:17 ` [PATCH 3/4] viafb: make suspend and resume work (on all machines?) Florian Tobias Schandinat
@ 2010-05-02 15:17 ` Florian Tobias Schandinat
2010-05-10 17:56 ` viafb suspend & resume, v2 Bruno Prémont
4 siblings, 0 replies; 7+ messages in thread
From: Florian Tobias Schandinat @ 2010-05-02 15:17 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet,
Florian Tobias Schandinat
viafb: fix hardware acceleration for suspend & resume
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>
---
drivers/video/via/accel.c | 41 +++++++++++++++++++++++++----------------
drivers/video/via/accel.h | 1 +
drivers/video/via/viafbdev.c | 2 ++
3 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c
index 189aba4..49c27b5 100644
--- a/drivers/video/via/accel.c
+++ b/drivers/video/via/accel.c
@@ -318,9 +318,7 @@ int viafb_init_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_start_engine(viapar);
+ return 0;
+}
+
+void viafb_start_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..5352f87 100644
--- a/drivers/video/via/accel.h
+++ b/drivers/video/via/accel.h
@@ -204,6 +204,7 @@
#define VIA_BITBLT_FILL 3
int viafb_init_engine(struct fb_info *info);
+void viafb_start_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 b5099b9..aaf572a 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1767,6 +1767,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_start_engine(viaparinfo);
viafb_set_par(viafbinfo);
if (viafb_dual_fb)
viafb_set_par(viafbinfo1);
--
1.6.3.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: viafb suspend & resume, v2
2010-05-02 15:17 viafb suspend & resume, v2 Florian Tobias Schandinat
` (3 preceding siblings ...)
2010-05-02 15:17 ` [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume Florian Tobias Schandinat
@ 2010-05-10 17:56 ` Bruno Prémont
2010-05-19 19:08 ` Florian Tobias Schandinat
4 siblings, 1 reply; 7+ messages in thread
From: Bruno Prémont @ 2010-05-10 17:56 UTC (permalink / raw)
To: Florian Tobias Schandinat
Cc: linux-kernel, linux-fbdev, JosephChan, ScottFang, corbet
On Sun, 02 May 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:
> This is the second version of this patch series. It is forward ported to apply
> on Jon's current viafb-posted branch. Furthermore the engine is only
> (re)started if the mmio space is mapped.
> There are still issues left especially device configuration and it does not yet
> integrate nicely in the new structure of the driver. However it is in a state
> where it shouldn't hurt anyone but could be useful for some people.
Only works with restrictions on my box.
System is Commell LE-365, 1GB RAM, lspci:
00:00.0 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Host Bridge [1106:0324] (rev 03)
00:00.1 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Host Bridge [1106:1324]
00:00.2 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Host Bridge [1106:2324]
00:00.3 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Host Bridge [1106:3324]
00:00.4 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Host Bridge [1106:4324]
00:00.7 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Host Bridge [1106:7324]
00:01.0 PCI bridge [0604]: VIA Technologies, Inc. VT8237/VX700 PCI Bridge [1106:b198]
00:0f.0 IDE interface [0101]: VIA Technologies, Inc. CX700/VX700 RAID Controller [1106:0581]
00:10.0 USB Controller [0c03]: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller [1106:3038] (rev 90)
00:10.1 USB Controller [0c03]: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller [1106:3038] (rev 90)
00:10.2 USB Controller [0c03]: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller [1106:3038] (rev 90)
00:10.4 USB Controller [0c03]: VIA Technologies, Inc. USB 2.0 [1106:3104] (rev 90)
00:11.0 ISA bridge [0601]: VIA Technologies, Inc. CX700/VX700 PCI to ISA Bridge [1106:8324]
00:11.7 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Internal Module Bus [1106:324e]
00:13.0 Host bridge [0600]: VIA Technologies, Inc. CX700/VX700 Host Bridge [1106:324b]
00:13.1 PCI bridge [0604]: VIA Technologies, Inc. CX700/VX700 PCI to PCI Bridge [1106:324a]
01:00.0 VGA compatible controller [0300]: VIA Technologies, Inc. CX700/VX700 [S3 UniChrome Pro] [1106:3157] (rev 03)
02:08.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8169 Gigabit Ethernet [10ec:8169] (rev 10)
80:01.0 Audio device [0403]: VIA Technologies, Inc. VT1708/A [Azalia HDAC] (VIA High Definition Audio Controller) [1106:3288] (rev 10)
If I have accel enabled system freezes during suspend, if accel is disabled
system suspends&resumes.
From a quick glance at the code I don't know what to do to disable accel
during suspend (and restore it on resume)...
viafb is not able to get GPU alive from its own, it still needs to have the
BIOS run VBIOS on resume.
Thanks,
Bruno
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: viafb suspend & resume, v2
2010-05-10 17:56 ` viafb suspend & resume, v2 Bruno Prémont
@ 2010-05-19 19:08 ` Florian Tobias Schandinat
0 siblings, 0 replies; 7+ messages in thread
From: Florian Tobias Schandinat @ 2010-05-19 19:08 UTC (permalink / raw)
To: Bruno Prémont
Cc: linux-kernel, linux-fbdev, JosephChan, ScottFang, corbet
Bruno Prémont schrieb:
> On Sun, 02 May 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:
>> This is the second version of this patch series. It is forward ported to apply
>> on Jon's current viafb-posted branch. Furthermore the engine is only
>> (re)started if the mmio space is mapped.
>> There are still issues left especially device configuration and it does not yet
>> integrate nicely in the new structure of the driver. However it is in a state
>> where it shouldn't hurt anyone but could be useful for some people.
>
> Only works with restrictions on my box.
Thanks for testing it.
> If I have accel enabled system freezes during suspend, if accel is disabled
> system suspends&resumes.
>>From a quick glance at the code I don't know what to do to disable accel
> during suspend (and restore it on resume)...
I am wondering where the freeze comes from. We don't use too much of the engine
and we already wait for it to become idle. Can you please test whether this patch
fixes it? It's not really acceleration related but other framebuffers do the same
and maybe it has a side effect for acceleration.
> viafb is not able to get GPU alive from its own, it still needs to have the
> BIOS run VBIOS on resume.
Okay, I guess the current code needs to be cleaned up before I can expect it to
work reliable...
Thanks,
Florian Tobias Schandinat
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index f581fb7..10b907a 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1750,6 +1750,7 @@ int viafb_suspend(struct pci_dev *pdev, pm_message_t state)
fb_set_suspend(viafbinfo, 1);
viafb_sync(viafbinfo);
+ viafb_blank(FB_BLANK_POWERDOWN, viafbinfo);
pci_save_state(pdev);
pci_disable_device(pdev);
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-05-19 19:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-02 15:17 viafb suspend & resume, v2 Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 1/4] Minimal support for viafb suspend/resume Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 2/4] viafb: restore display on resume Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 3/4] viafb: make suspend and resume work (on all machines?) Florian Tobias Schandinat
2010-05-02 15:17 ` [PATCH 4/4] viafb: fix hardware acceleration for suspend & resume Florian Tobias Schandinat
2010-05-10 17:56 ` viafb suspend & resume, v2 Bruno Prémont
2010-05-19 19:08 ` Florian Tobias Schandinat
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).