From patchwork Mon Apr 20 10:08:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 6246811 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 412939F6E2 for ; Tue, 21 Apr 2015 11:38:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A383120251 for ; Tue, 21 Apr 2015 11:38:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C905320253 for ; Tue, 21 Apr 2015 11:38:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 85E428989A; Tue, 21 Apr 2015 04:38:36 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 442 seconds by postgrey-1.34 at gabe; Tue, 21 Apr 2015 04:38:35 PDT Received: from mailout2.hostsharing.net (mailout2.hostsharing.net [83.223.90.233]) by gabe.freedesktop.org (Postfix) with ESMTP id 038698973E for ; Tue, 21 Apr 2015 04:38:35 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout2.hostsharing.net (Postfix) with ESMTPS id 5036C10189CB5; Tue, 21 Apr 2015 13:31:40 +0200 (CEST) Received: from localhost (5-38-90-81.adsl.cmo.de [81.90.38.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id DADCC603E04D; Tue, 21 Apr 2015 13:31:38 +0200 (CEST) X-Mailbox-Line: From c0e32c8b950d6f535b37fe998bb9da468b11e916 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Lukas Wunner Date: Mon, 20 Apr 2015 12:08:12 +0200 Subject: [PATCH 08/11] vga_switcheroo: Reprobe connectors if handler registers late To: dri-devel@lists.freedesktop.org Cc: Daniel Vetter , Seth Forshee , Matthew Garrett , Dave Airlie X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_24_48, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); };