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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1341891593-6485-1-git-send-email-arun.raghavan@collabora.co.uk>
Date:	Tue, 10 Jul 2012 09:09:53 +0530
From:	Arun Raghavan <arun.raghavan@...labora.co.uk>
To:	Matthew Garrett <mjg@...hat.com>,
	Seth Forshee <seth.forshee@...onical.com>
Cc:	platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
	Arun Raghavan <arun.raghavan@...labora.co.uk>
Subject: [PATCH] apple-gmux: Restore switch registers on suspend/resume

After suspend and resume, the values of these registers seem to change
from what they were at suspend time, potentially preventing the actual
output lines from being enabled post-resume. This saves relevant state
at suspend and restores it when resumed.

This is at least required on the MacBook Pro 8.2 when the Intel GPU is
manually selected in GRUB config before the kernel is loaded.

Signed-off-by: Arun Raghavan <arun.raghavan@...labora.co.uk>
---
 drivers/platform/x86/apple-gmux.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index 694a15a..5a5d005 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -26,6 +26,11 @@ struct apple_gmux_data {
 	unsigned long iolen;
 
 	struct backlight_device *bdev;
+
+	bool was_suspended;
+	u8 save_switch_ddc;
+	u8 save_switch_disp;
+	u8 save_switch_ext;
 };
 
 /*
@@ -87,8 +92,30 @@ static int gmux_update_status(struct backlight_device *bd)
 	struct apple_gmux_data *gmux_data = bl_get_data(bd);
 	u32 brightness = bd->props.brightness;
 
-	if (bd->props.state & BL_CORE_SUSPENDED)
+	if (bd->props.state & BL_CORE_SUSPENDED) {
+		/* Save mux settings for output lines since they get reset on
+		 * suspend */
+		gmux_data->was_suspended = TRUE;
+		gmux_data->save_switch_ddc = gmux_read8(gmux_data,
+				GMUX_PORT_SWITCH_DDC);
+		gmux_data->save_switch_disp = gmux_read8(gmux_data,
+				GMUX_PORT_SWITCH_DISPLAY);
+		gmux_data->save_switch_ext = gmux_read8(gmux_data,
+				GMUX_PORT_SWITCH_EXTERNAL);
+
 		return 0;
+	}
+
+	if (gmux_data->was_suspended) {
+		/* Restore pre-suspend values for output lines */
+		gmux_data->was_suspended = FALSE;
+		gmux_write8(gmux_data, GMUX_PORT_SWITCH_DDC,
+				gmux_data->save_switch_ddc);
+		gmux_write8(gmux_data, GMUX_PORT_SWITCH_DISPLAY,
+				gmux_data->save_switch_disp);
+		gmux_write8(gmux_data, GMUX_PORT_SWITCH_EXTERNAL,
+				gmux_data->save_switch_ext);
+	}
 
 	/*
 	 * Older gmux versions require writing out lower bytes first then
-- 
1.7.8.6

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