lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1335645928-30993-2-git-send-email-alexander.tarasikov@gmail.com>
Date:	Sun, 29 Apr 2012 00:45:28 +0400
From:	Alexander Tarasikov <alexander.tarasikov@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	airlied@...ux.ie,
	Alexander Tarasikov <alexander.tarasikov@...il.com>
Subject: [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@...il.com>
---
 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ