From patchwork Sun Jun 1 16:38:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 4279451 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 EF7E79F326 for ; Mon, 2 Jun 2014 00:52:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03726203AD for ; Mon, 2 Jun 2014 00:52:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1042E203AA for ; Mon, 2 Jun 2014 00:52:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 570206E4B5; Sun, 1 Jun 2014 17:52:09 -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 499686E08B for ; Sun, 1 Jun 2014 10:24:21 -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 1Wr8me-00062c-Oc; Sun, 01 Jun 2014 17:38:58 +0100 From: Matthew Garrett To: airlied@gmail.com Date: Sun, 1 Jun 2014 12:38:35 -0400 Message-Id: <1401640723-2058-4-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 03/11] vga_switcheroo: Add command line option 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 Add a command line option in order to allow the user to provide a perferred GPU at boot time. Signed-off-by: Matthew Garrett --- Documentation/kernel-parameters.txt | 5 +++++ drivers/gpu/vga/vga_switcheroo.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 30a8ad0d..6e6d505 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -3486,6 +3486,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted. This is actually a boot loader parameter; the value is passed to the kernel using a special protocol. + vga_switcheroo= [HW] Switches the enabled GPU at boot time. + Format: { IGD | DIS } + IGD -- enable the Integrated GPU + DIS -- enable the Discrete GPU + vmalloc=nn[KMG] [KNL,BOOT] Forces the vmalloc area to have an exact size of . This can be used to increase the minimum size (128MB on x86). It can also be used to diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index c06ad5f..6d95626 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -67,6 +67,11 @@ struct vgasr_priv { static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv); static void vga_switcheroo_debugfs_fini(struct vgasr_priv *priv); +static enum vga_switcheroo_client_id vga_switcheroo_default = -1; + +static int vga_switchto_stage1(struct vga_switcheroo_client *new_client); +static int vga_switchto_stage2(struct vga_switcheroo_client *new_client); + /* only one switcheroo per system */ static struct vgasr_priv vgasr_priv = { .clients = LIST_HEAD_INIT(vgasr_priv.clients), @@ -107,6 +112,18 @@ static void vga_switcheroo_enable(void) vgasr_priv.handler->switch_ddc(old_id); } } + + list_for_each_entry(client, &vgasr_priv.clients, list) { + if (!client->active && client->id == vga_switcheroo_default) { + ret = vga_switchto_stage1(client); + if (ret) + printk(KERN_ERR "vga_switcheroo: switching failed stage 1 %d\n", ret); + + ret = vga_switchto_stage2(client); + if (ret) + printk(KERN_ERR "vga_switcheroo: switching failed stage 2 %d\n", ret); + } + } vga_switcheroo_debugfs_init(&vgasr_priv); vgasr_priv.active = true; } @@ -748,3 +765,15 @@ int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct return -EINVAL; } EXPORT_SYMBOL(vga_switcheroo_init_domain_pm_optimus_hdmi_audio); + +static int __init vga_switcheroo_setup(char *str) +{ + if (!strcmp(str, "IGD")) + vga_switcheroo_default = VGA_SWITCHEROO_IGD; + else if (!strcmp(str, "DIS")) + vga_switcheroo_default = VGA_SWITCHEROO_DIS; + + return 1; +} + +__setup("vga_switcheroo=", vga_switcheroo_setup);