All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Seth Forshee <seth.forshee@canonical.com>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	Dave Airlie <airlied@redhat.com>
Subject: [PATCH 08/11] vga_switcheroo: Reprobe connectors if handler registers late
Date: Mon, 20 Apr 2015 12:08:12 +0200	[thread overview]
Message-ID: <c0e32c8b950d6f535b37fe998bb9da468b11e916.1429610300.git.lukas@wunner.de> (raw)
In-Reply-To: <cover.1429610300.git.lukas@wunner.de>

If the handler registers late, already registered clients must
reprobe their connectors in case they require the handler to
switch DDC lines. That is the case on MacBook Pros, which use
a gmux chip as handler.

Inspired by Matthew Garrett, who did this in vga_switcheroo_enable()
instead, which delayed reprobing until a second gpu registers.
Probably makes sense to do this as early as possible, particularly
since a second gpu may never register if its driver is blacklisted
or not installed:
http://lists.freedesktop.org/archives/dri-devel/2014-June/060941.html

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/gpu/vga/vga_switcheroo.c | 8 ++++++++
 include/linux/vga_switcheroo.h   | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index 062fafe..3b13e9a 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -108,6 +108,8 @@ static void vga_switcheroo_enable(void)
 
 int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler)
 {
+	struct vga_switcheroo_client *client;
+
 	mutex_lock(&vgasr_mutex);
 	if (vgasr_priv.handler) {
 		mutex_unlock(&vgasr_mutex);
@@ -115,6 +117,12 @@ int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler)
 	}
 
 	vgasr_priv.handler = handler;
+
+	/* clients which registered before the handler must reprobe */
+	list_for_each_entry(client, &vgasr_priv.clients, list)
+		if (!client->active && client->ops->reprobe_connectors)
+			client->ops->reprobe_connectors(client->pdev);
+
 	if (vga_switcheroo_ready()) {
 		printk(KERN_INFO "vga_switcheroo: enabled\n");
 		vga_switcheroo_enable();
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index 60c9d65..c3ad8bf 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -40,6 +40,7 @@ struct vga_switcheroo_handler {
 struct vga_switcheroo_client_ops {
 	void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state);
 	void (*reprobe)(struct pci_dev *dev);
+	void (*reprobe_connectors)(struct pci_dev *dev);
 	bool (*can_switch)(struct pci_dev *dev);
 };
 
-- 
1.8.5.2 (Apple Git-48)

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-04-21 11:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21  9:58 [PATCH 00/11] Enable gpu switching on the MacBook Pro Lukas Wunner
2012-09-07 15:22 ` [PATCH 01/11] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2012-09-07 15:22 ` [PATCH 02/11] vga_switcheroo: Add helper function to get the active client Lukas Wunner
2012-09-07 15:22 ` [PATCH 03/11] apple-gmux: Add switch_ddc support Lukas Wunner
2012-09-07 15:22 ` [PATCH 04/11] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2012-12-22  2:52 ` [PATCH 05/11] vga_switcheroo: Lock/unlock DDC lines Lukas Wunner
2014-03-05 22:34 ` [PATCH 09/11] apple-gmux: Assign apple_gmux_data before registering Lukas Wunner
2015-03-27 11:29 ` [PATCH 06/11] vga_switcheroo: Lock/unlock DDC lines harder Lukas Wunner
2015-04-19 15:01 ` [PATCH 10/11] drm/i915: Reprobe connectors if vga_switcheroo handler registers late Lukas Wunner
2015-04-21 11:50   ` Chris Wilson
2015-04-21 12:16     ` Lukas Wunner
2015-04-21 12:37       ` Chris Wilson
2015-04-19 15:18 ` [PATCH 11/11] drm/nouveau: Pause between setting gpu to D3hot and cutting the power Lukas Wunner
2015-04-20 10:08 ` Lukas Wunner [this message]
2015-04-21  8:39 ` [PATCH 07/11] Revert "vga_switcheroo: Add helper function to get the active client" Lukas Wunner
2015-04-21 19:49 ` [PATCH 00/11] Enable gpu switching on the MacBook Pro Matthew Garrett
2015-04-22 13:48   ` Lukas Wunner
2015-04-25 14:20   ` Lukas Wunner
2015-05-02 19:03     ` Lu, Ran

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=c0e32c8b950d6f535b37fe998bb9da468b11e916.1429610300.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=airlied@redhat.com \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mjg59@srcf.ucam.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.