Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH] drivers:gpu:vga_switcheroo: Work around dramatic power drain in laptops

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


alexander.tarasikov at gmail

Apr 28, 2012, 1:45 PM

Post #1 of 5 (274 views)
Permalink
[PATCH] drivers:gpu:vga_switcheroo: Work around dramatic power drain in laptops

Many laptop computers with switchable graphics that have an ATI
Radeon graphics card ignore ACPI state for the discrete VGA
and enable it on resume in spite of it being disabled by
vga_switcheroo.

That causes an extra power drain of around 10-15W and overheating after
a suspend-resume cycle. A userspace-based workaround involving
enabling and disabling the discrete card via debugfs has a major
drawback - it causes long (around one minute) lockups because VGA BIOS
is confused by the enable request.

This patch adds an experimental module parameter that causes
vga_switcheroo to disable all inactive VGA cards after a resume
to save power and avoid lockups/GPU freezes. This has been tested
on a Sony VAIO laptop with Intel HD3000 and Ati Radeon 6630M GPU.

Signed-off-by: Alexander Tarasikov <alexander.tarasikov [at] gmail>
---
drivers/gpu/vga/vga_switcheroo.c | 71 ++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index 58434e8..21b8e2c 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -490,3 +490,74 @@ err:
}
EXPORT_SYMBOL(vga_switcheroo_process_delayed_switch);

+#ifdef CONFIG_PM_SLEEP
+#include <linux/suspend.h>
+
+static int resume_powercut;
+module_param_named(resume_powercut, resume_powercut, int, 0400);
+MODULE_PARM_DESC(resume_powercut,
+ "Forcibly disable power to inactive VGA cards on resume."
+ " This is a workaround for laptops with ATI Radeon cards"
+ " which ignore ACPI state and cause extra 10W of power consumption");
+
+static int vga_switcheroo_notify(struct notifier_block *nb,
+ unsigned long mode, void *_unused)
+{
+ int i;
+
+ switch (mode) {
+ case PM_POST_HIBERNATION:
+ case PM_POST_SUSPEND:
+ break;
+ default:
+ return 0;
+ }
+
+ mutex_lock(&vgasr_mutex);
+
+ if (!vgasr_priv.active) {
+ pr_info("vga_witcheroo: not active, ignoring notification\n");
+ goto out;
+ }
+
+ pr_debug("vga_switcheroo: disabling unused VGAs\n");
+ for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) {
+ if (vgasr_priv.clients[i].active)
+ continue;
+ pr_info("vga_switcheroo: disabling VGA %d at resume\n", i);
+ vga_switchoff(&vgasr_priv.clients[i]);
+ }
+
+out:
+ mutex_unlock(&vgasr_mutex);
+
+ return 0;
+}
+
+static struct notifier_block vga_switcheroo_notifier_block = {
+ .notifier_call = vga_switcheroo_notify,
+};
+
+static int __init vga_switcheroo_pm_hack_init(void)
+{
+ int ret;
+
+ if (!resume_powercut)
+ return 0;
+
+ ret = register_pm_notifier(&vga_switcheroo_notifier_block);
+ if (ret)
+ pr_err("%s: failed to register pm notifier\n", __func__);
+
+ return ret;
+}
+
+static void __exit vga_switcheroo_pm_hack_exit(void)
+{
+ if (resume_powercut)
+ unregister_pm_notifier(&vga_switcheroo_notifier_block);
+}
+
+late_initcall(vga_switcheroo_pm_hack_init);
+module_exit(vga_switcheroo_pm_hack_exit);
+#endif
--
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


alan at lxorguk

Apr 28, 2012, 2:10 PM

Post #2 of 5 (265 views)
Permalink
Re: [PATCH] drivers:gpu:vga_switcheroo: Work around dramatic power drain in laptops [In reply to]

> This patch adds an experimental module parameter that causes
> vga_switcheroo to disable all inactive VGA cards after a resume
> to save power and avoid lockups/GPU freezes. This has been tested
> on a Sony VAIO laptop with Intel HD3000 and Ati Radeon 6630M GPU.

The module parameter is probably the wrong long term option. Do you know
if the problem is general or specific to some laptops. If it's the latter
then it might also be worth implementing a DMI and/or PCI detection
routine to match the laptops you know are afflicted and automatically
enabled it.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


alexander.tarasikov at gmail

Apr 28, 2012, 3:17 PM

Post #3 of 5 (265 views)
Permalink
Re: [PATCH] drivers:gpu:vga_switcheroo: Work around dramatic power drain in laptops [In reply to]

2012/4/29 Alan Cox <alan [at] lxorguk>:
> The module parameter is probably the wrong long term option. Do you know
> if the problem is general or specific to some laptops. If it's the latter
> then it might also be worth implementing a DMI and/or PCI detection
> routine to match the laptops you know are afflicted and automatically
> enabled it.
> Alan

I agree that module parameter is not a good idea, but I have seen a
lot of reports
of the problem and no patches were proposed, so I tried to do what I could. It
could be a good temporary solution until we make sure it does not break
any configurations. I am unsure how muxless/muxed cards may differ in
behaviour.

I suspect that the problem is specific to all laptops with
intel+radeon combination.
So far I have found these reports of radeon eating battery

[2010] Acer TravelMate Timeline 8371
[2012] Hp Envy 14 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/909337
[2012] Thinkpad T400 https://bbs.archlinux.org/viewtopic.php?id=133329
[2012] Sony Vaio SE15 (VPCSE1v9E)
http://blog.ejbca.org/2012/02/ubuntu-gnulinux-1204-precise-on-sony.html

The current solution involves doing an ON-OFF cycle and radeon hangs
on echoing ON to switcheroo for a minute. This if, of course, very
annoying and is not ready for daily usage.
I and other users get the messages like

[drm:atom_op_jump] *ERROR* atombios stuck in loop for more than 1sec aborting
[drm:atom_execute_table_locked] *ERROR* atombios stuck executing CAE2
(len 62, WS 0, PS 0) @ 0xCAFE

A possible solution might be to simply remove the "if
(vgasr_priv.clients[i].pwr_state == VGA_SWITCHEROO_ON)"
check. However, that would still mean some userland app will have to echo "OFF"
on each resume. I find this behaviour unacceptable because I believe power
management must be done by kernel and things that are likely to cause hardware
damage (i.e., overheating) must be kept off userland. Overall, the
drivers only do this enable-disable stuff
during probe/remove, but when suspending, we're handing the control
over to the proprietary BIOS/bootloader
and the hardware is left in the undeterminate state. It might be a
good idea to force power reinit on suspend/resume.

Therefore I think we should get people having problems (and those not
having problems) to test the patch
to see if it fixes power drain and does not break other machines
(i.e., whether we can enable aggressive
powersaving for everyone). Maybe it's better to notify downstream
(ubuntu, fedora) but I guess everyone
reads LKML.

--
Regards, Alexander
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bon at elektron

May 6, 2012, 10:36 AM

Post #4 of 5 (263 views)
Permalink
Re: [PATCH] drivers:gpu:vga_switcheroo: Work around dramatic power drain in laptops [In reply to]

Alexander Tarasikov <alexander.tarasikov [at] gmail> wrote:
> 2012/4/29 Alan Cox <alan [at] lxorguk>:
> > The module parameter is probably the wrong long term option. Do you know
> > if the problem is general or specific to some laptops. If it's the latter
> > then it might also be worth implementing a DMI and/or PCI detection
> > routine to match the laptops you know are afflicted and automatically
> > enabled it.
> > Alan

> I agree that module parameter is not a good idea, but I have seen a
> lot of reports of the problem and no patches were proposed,
> so I tried to do what I could. It
> could be a good temporary solution until we make sure it does not break
> any configurations. I am unsure how muxless/muxed cards may differ in
> behaviour.

> I suspect that the problem is specific to all laptops with
> intel+radeon combination.

Intel+Nvidia combination seems to be affected too!

> So far I have found these reports of radeon eating battery

> [2010] Acer TravelMate Timeline 8371
> [2012] Hp Envy 14 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/909337
> [2012] Thinkpad T400 https://bbs.archlinux.org/viewtopic.php?id=133329
> [2012] Sony Vaio SE15 (VPCSE1v9E)
> http://blog.ejbca.org/2012/02/ubuntu-gnulinux-1204-precise-on-sony.html

I can confirm the problem with an intel+nvidia combination, on a Thinkpad T520:
> lspci |grep -i VGA
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core \
Processor Family Integrated Graphics Controller (rev 09)
01:00.0 VGA compatible controller: nVidia Corporation GF119 [Quadro NVS 4200M] (rev ff)

I suspend with "DIS"cret graphics off. Resuming comes up with about 5 Watt
more power drain compared before suspend. Switching "DIS" needs another 5
Watt. Switching "DIS" off again brings me back to the power drain level
before suspend.

I vote for Alexander proposal!

Bye

--
Uwe Bonnes bon [at] elektron

Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


valery.pipin at gmail

Jul 2, 2012, 6:55 PM

Post #5 of 5 (222 views)
Permalink
Re: [PATCH] drivers:gpu:vga_switcheroo: Work around dramatic power drain in laptops [In reply to]

I vote for this patch. It solves my problems with suspend/hibernate/resume on
ENVY 14 1210NR that has itegrated card by Intel and discrete from AMD(redwood).
Using on Mageia 2 kernel 3.4.2

Valery




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.