All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernhard Froemel <bfroemel@gmail.com>
To: Matthew Garrett <mjg@redhat.com>,
	platform-driver-x86@vger.kernel.org,
	Seth Forshee <seth.forshee@canonical.com>
Cc: linux-kernel@vger.kernel.org,
	Bernhard Froemel <froemel@vmars.tuwien.ac.at>
Subject: [PATCH v2 1/2] apple-gmux: Fix index read functions
Date: Sat, 25 Aug 2012 10:30:48 +0200	[thread overview]
Message-ID: <1345883449-2790-1-git-send-email-bfroemel@gmail.com> (raw)
In-Reply-To: <50388C45.6030707@gmail.com>

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

  reply	other threads:[~2012-08-25  8:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345883449-2790-1-git-send-email-bfroemel@gmail.com \
    --to=bfroemel@gmail.com \
    --cc=froemel@vmars.tuwien.ac.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=seth.forshee@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.