From patchwork Sun Jun 1 16:38:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 4279341 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C636A9F326 for ; Mon, 2 Jun 2014 00:52:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3D9420397 for ; Mon, 2 Jun 2014 00:52:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4BAB3203AA for ; Mon, 2 Jun 2014 00:52:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1404F6E40F; Sun, 1 Jun 2014 17:52:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cavan.codon.org.uk (cavan.codon.org.uk [93.93.128.6]) by gabe.freedesktop.org (Postfix) with ESMTP id 991846E08B for ; Sun, 1 Jun 2014 10:24:20 -0700 (PDT) Received: from 209-6-207-143.c3-0.smr-ubr2.sbo-smr.ma.cable.rcn.com ([209.6.207.143] helo=localhost.lan) by cavan.codon.org.uk with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Wr8mr-00062c-Cs; Sun, 01 Jun 2014 17:39:16 +0100 From: Matthew Garrett To: airlied@gmail.com Date: Sun, 1 Jun 2014 12:38:38 -0400 Message-Id: <1401640723-2058-7-git-send-email-matthew.garrett@nebula.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1401640723-2058-1-git-send-email-matthew.garrett@nebula.com> References: <1401640723-2058-1-git-send-email-matthew.garrett@nebula.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 209.6.207.143 X-SA-Exim-Mail-From: matthew.garrett@nebula.com X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-ASN: Subject: [PATCH 06/11] vga_switcheroo: Add enable() call to clients and permit deferral of dynamic PM X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:54:46 +0000) X-SA-Exim-Scanned: Yes (on cavan.codon.org.uk) X-Mailman-Approved-At: Sun, 01 Jun 2014 17:52:06 -0700 Cc: Matthew Garrett , dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Virus-Scanned: ClamAV using ClamSMTP We may not know whether the platform supports dynamic PM of GPUs until the switcheroo handler is registered. Add an enable() callback for clients and another entry point to switcheroo in order to permit them to set dynamic PM appropriately. Signed-off-by: Matthew Garrett --- drivers/gpu/vga/vga_switcheroo.c | 17 +++++++++++++++++ include/linux/vga_switcheroo.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index c5e97d4..199a111 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -108,6 +108,9 @@ static void vga_switcheroo_enable(void) client->id = ret; + if (client->ops->enable) + client->ops->enable(client->pdev); + if (!client->active && client->ops->reprobe_connectors) { int old_id = (client->id == VGA_SWITCHEROO_IGD) ? VGA_SWITCHEROO_DIS : VGA_SWITCHEROO_IGD; @@ -670,6 +673,20 @@ static void vga_switcheroo_power_switch(struct pci_dev *pdev, enum vga_switchero vgasr_priv.handler->power_state(client->id, state); } +void vga_switcheroo_set_dynamic_support(struct pci_dev *pdev, bool dynamic) +{ + struct vga_switcheroo_client *client; + + client = find_client_from_pci(&vgasr_priv.clients, pdev); + if (!client) + return; + + client->driver_power_control = dynamic; + + return; +} +EXPORT_SYMBOL(vga_switcheroo_set_dynamic_support); + /* force a PCI device to a certain state - mainly to turn off audio clients */ void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h index 4bba934..5a483c6 100644 --- a/include/linux/vga_switcheroo.h +++ b/include/linux/vga_switcheroo.h @@ -44,6 +44,7 @@ struct vga_switcheroo_client_ops { void (*reprobe)(struct pci_dev *dev); void (*reprobe_connectors)(struct pci_dev *dev); bool (*can_switch)(struct pci_dev *dev); + void (*enable)(struct pci_dev *dev); }; #if defined(CONFIG_VGA_SWITCHEROO) @@ -67,6 +68,7 @@ int vga_switcheroo_process_delayed_switch(void); int vga_switcheroo_get_client_state(struct pci_dev *dev); +void vga_switcheroo_set_dynamic_support(struct pci_dev *pdev, bool dynamic); void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic); int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain); @@ -94,6 +96,7 @@ static inline void vga_switcheroo_unregister_handler(void) {} static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return VGA_SWITCHEROO_ON; } +static inline void vga_switcheroo_set_dynamic_support(struct pci_dev *pdev, bool dynamic) {} static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {} static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }