linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] apple-gmux: Fixes related to 'Support for new hardware'
@ 2012-08-25  8:26 Bernhard Froemel
  2012-08-25  8:30 ` [PATCH v2 1/2] apple-gmux: Fix index read functions Bernhard Froemel
  0 siblings, 1 reply; 6+ messages in thread
From: Bernhard Froemel @ 2012-08-25  8:26 UTC (permalink / raw)
  To: Seth Forshee, Matthew Garrett, platform-driver-x86; +Cc: linux-kernel, froemel

Hello,

it follows a refined version where thanks to Seth and his extensive x86
assembly knowledge my initial assumption about how Apple does byte
writes could be falsified. It appears that byte writes only failed
because the index protocol was not correctly followed in the read functions.

Cheers,
 Bernhard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] apple-gmux: Fix index read functions
  2012-08-25  8:26 [PATCH v2 0/2] apple-gmux: Fixes related to 'Support for new hardware' Bernhard Froemel
@ 2012-08-25  8:30 ` Bernhard Froemel
  2012-08-25  8:30   ` [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux Bernhard Froemel
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bernhard Froemel @ 2012-08-25  8:30 UTC (permalink / raw)
  To: Matthew Garrett, platform-driver-x86, Seth Forshee
  Cc: linux-kernel, Bernhard Froemel

From: Bernhard Froemel <froemel@vmars.tuwien.ac.at>

Study of Apple's binary driver revealed that the GMUX_READ_PORT should
be written between calls to gmux_index_wait_ready and
gmux_index_wait_complete (i.e., the new index protocol must be
followed). If this is not done correctly, the indexed
gmux device only partially accepts writes which lead to problems
concerning GPU switching. Special thanks to Seth Forshee who helped
greatly with identifying unnecessary changes.

Signed-off-by: Bernhard Froemel <froemel@vmars.tuwien.ac.at>
---
 drivers/platform/x86/apple-gmux.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index dfb1a92..c38538e 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -142,8 +142,9 @@ static u8 gmux_index_read8(struct apple_gmux_data *gmux_data, int port)
 	u8 val;
 
 	mutex_lock(&gmux_data->index_lock);
-	outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
 	gmux_index_wait_ready(gmux_data);
+	outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
+	gmux_index_wait_complete(gmux_data);
 	val = inb(gmux_data->iostart + GMUX_PORT_VALUE);
 	mutex_unlock(&gmux_data->index_lock);
 
@@ -166,8 +167,9 @@ static u32 gmux_index_read32(struct apple_gmux_data *gmux_data, int port)
 	u32 val;
 
 	mutex_lock(&gmux_data->index_lock);
-	outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
 	gmux_index_wait_ready(gmux_data);
+	outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ);
+	gmux_index_wait_complete(gmux_data);
 	val = inl(gmux_data->iostart + GMUX_PORT_VALUE);
 	mutex_unlock(&gmux_data->index_lock);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux
  2012-08-25  8:30 ` [PATCH v2 1/2] apple-gmux: Fix index read functions Bernhard Froemel
@ 2012-08-25  8:30   ` Bernhard Froemel
  2012-08-26  0:48     ` Seth Forshee
  2012-08-25 17:53   ` [PATCH v2 1/2] apple-gmux: Fix index read functions Henrik Rydberg
  2012-08-26  0:47   ` Seth Forshee
  2 siblings, 1 reply; 6+ messages in thread
From: Bernhard Froemel @ 2012-08-25  8:30 UTC (permalink / raw)
  To: Matthew Garrett, platform-driver-x86, Seth Forshee
  Cc: linux-kernel, Bernhard Froemel

From: Bernhard Froemel <froemel@vmars.tuwien.ac.at>

This patch extracts and displays version information from the indexed
gmux device as it is also done for the classic gmux device.

Signed-off-by: Bernhard Froemel <froemel@vmars.tuwien.ac.at>
---
 drivers/platform/x86/apple-gmux.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index c38538e..0e43477 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -463,18 +463,22 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,
 	ver_release = gmux_read8(gmux_data, GMUX_PORT_VERSION_RELEASE);
 	if (ver_major == 0xff && ver_minor == 0xff && ver_release == 0xff) {
 		if (gmux_is_indexed(gmux_data)) {
+			u32 version;
 			mutex_init(&gmux_data->index_lock);
 			gmux_data->indexed = true;
+			version = gmux_read32(gmux_data,
+				GMUX_PORT_VERSION_MAJOR);
+			ver_major = (version >> 24) & 0xff;
+			ver_minor = (version >> 16) & 0xff;
+			ver_release = (version >> 8) & 0xff;
 		} else {
 			pr_info("gmux device not present\n");
 			ret = -ENODEV;
 			goto err_release;
 		}
-		pr_info("Found indexed gmux\n");
-	} else {
-		pr_info("Found gmux version %d.%d.%d\n", ver_major, ver_minor,
-			ver_release);
 	}
+	pr_info("Found gmux version %d.%d.%d [%s]\n", ver_major, ver_minor,
+		ver_release, (gmux_data->indexed ? "indexed" : "classic"));
 
 	memset(&props, 0, sizeof(props));
 	props.type = BACKLIGHT_PLATFORM;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] apple-gmux: Fix index read functions
  2012-08-25  8:30 ` [PATCH v2 1/2] apple-gmux: Fix index read functions Bernhard Froemel
  2012-08-25  8:30   ` [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux Bernhard Froemel
@ 2012-08-25 17:53   ` Henrik Rydberg
  2012-08-26  0:47   ` Seth Forshee
  2 siblings, 0 replies; 6+ messages in thread
From: Henrik Rydberg @ 2012-08-25 17:53 UTC (permalink / raw)
  To: Bernhard Froemel
  Cc: Matthew Garrett, platform-driver-x86, Seth Forshee, linux-kernel,
	Bernhard Froemel

On Sat, Aug 25, 2012 at 10:30:48AM +0200, Bernhard Froemel wrote:
> From: Bernhard Froemel <froemel@vmars.tuwien.ac.at>
> 
> Study of Apple's binary driver revealed that the GMUX_READ_PORT should
> be written between calls to gmux_index_wait_ready and
> gmux_index_wait_complete (i.e., the new index protocol must be
> followed). If this is not done correctly, the indexed
> gmux device only partially accepts writes which lead to problems
> concerning GPU switching. Special thanks to Seth Forshee who helped
> greatly with identifying unnecessary changes.
> 
> Signed-off-by: Bernhard Froemel <froemel@vmars.tuwien.ac.at>
> ---

Hi Bernhard,

thanks for your patch, this works splendidly; I can resume and select
different screen resolutions using xrandr.

    Tested-by: Henrik Rydberg <rydberg@euromail.se>

Henrik

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] apple-gmux: Fix index read functions
  2012-08-25  8:30 ` [PATCH v2 1/2] apple-gmux: Fix index read functions Bernhard Froemel
  2012-08-25  8:30   ` [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux Bernhard Froemel
  2012-08-25 17:53   ` [PATCH v2 1/2] apple-gmux: Fix index read functions Henrik Rydberg
@ 2012-08-26  0:47   ` Seth Forshee
  2 siblings, 0 replies; 6+ messages in thread
From: Seth Forshee @ 2012-08-26  0:47 UTC (permalink / raw)
  To: Bernhard Froemel
  Cc: Matthew Garrett, platform-driver-x86, linux-kernel, Bernhard Froemel

On Sat, Aug 25, 2012 at 10:30:48AM +0200, Bernhard Froemel wrote:
> From: Bernhard Froemel <froemel@vmars.tuwien.ac.at>
> 
> Study of Apple's binary driver revealed that the GMUX_READ_PORT should
> be written between calls to gmux_index_wait_ready and
> gmux_index_wait_complete (i.e., the new index protocol must be
> followed). If this is not done correctly, the indexed
> gmux device only partially accepts writes which lead to problems
> concerning GPU switching. Special thanks to Seth Forshee who helped
> greatly with identifying unnecessary changes.
> 
> Signed-off-by: Bernhard Froemel <froemel@vmars.tuwien.ac.at>

This does better match what Apple's driver does. Thanks Bernhard.

Acked-by: Seth Forshee <seth.forshee@canonical.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux
  2012-08-25  8:30   ` [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux Bernhard Froemel
@ 2012-08-26  0:48     ` Seth Forshee
  0 siblings, 0 replies; 6+ messages in thread
From: Seth Forshee @ 2012-08-26  0:48 UTC (permalink / raw)
  To: Bernhard Froemel
  Cc: Matthew Garrett, platform-driver-x86, linux-kernel, Bernhard Froemel

On Sat, Aug 25, 2012 at 10:30:49AM +0200, Bernhard Froemel wrote:
> From: Bernhard Froemel <froemel@vmars.tuwien.ac.at>
> 
> This patch extracts and displays version information from the indexed
> gmux device as it is also done for the classic gmux device.
> 
> Signed-off-by: Bernhard Froemel <froemel@vmars.tuwien.ac.at>

Acked-by: Seth Forshee <seth.forshee@canonical.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-26  0:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-25  8:26 [PATCH v2 0/2] apple-gmux: Fixes related to 'Support for new hardware' Bernhard Froemel
2012-08-25  8:30 ` [PATCH v2 1/2] apple-gmux: Fix index read functions Bernhard Froemel
2012-08-25  8:30   ` [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux Bernhard Froemel
2012-08-26  0:48     ` Seth Forshee
2012-08-25 17:53   ` [PATCH v2 1/2] apple-gmux: Fix index read functions Henrik Rydberg
2012-08-26  0:47   ` Seth Forshee

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