From patchwork Thu May 28 06:40:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Moreau X-Patchwork-Id: 6496371 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 01B699F38C for ; Thu, 28 May 2015 06:38:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 288A32071B for ; Thu, 28 May 2015 06:38:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 03215202EC for ; Thu, 28 May 2015 06:38:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38E516EB2F; Wed, 27 May 2015 23:38:26 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp1-g21.free.fr (smtp1-g21.free.fr [212.27.42.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 20DF96EB24; Wed, 27 May 2015 23:38:23 -0700 (PDT) Received: from testlinux.localdomain (unknown [83.248.242.206]) (Authenticated sender: pierre.morrow) by smtp1-g21.free.fr (Postfix) with ESMTPSA id 0CCBA940049; Thu, 28 May 2015 08:34:39 +0200 (CEST) From: Pierre Moreau To: nouveau@lists.freedesktop.org Subject: [PATCH v2 9/9] acpi: Move detecting available _DSM outside of while loops Date: Thu, 28 May 2015 08:40:49 +0200 Message-Id: <1432795249-4458-9-git-send-email-pierre.morrow@free.fr> X-Mailer: git-send-email 2.4.2 In-Reply-To: <1432795249-4458-1-git-send-email-pierre.morrow@free.fr> References: <1432795249-4458-1-git-send-email-pierre.morrow@free.fr> Cc: bskeggs@redhat.com, dri-devel@lists.freedesktop.org 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=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, 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 Changes since v1: * Re-write the whole patch to detect available _DSMs when we enable them rather than on each loop run Signed-off-by: Pierre Moreau --- drm/nouveau/nouveau_acpi.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drm/nouveau/nouveau_acpi.c b/drm/nouveau/nouveau_acpi.c index ee5fcfa..a970e41 100644 --- a/drm/nouveau/nouveau_acpi.c +++ b/drm/nouveau/nouveau_acpi.c @@ -301,12 +301,9 @@ static bool nouveau_dsm_detect(void) char acpi_method_name[255] = { 0 }; struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name}; struct pci_dev *pdev = NULL; - int has_mux = 0; - int has_optimus = 0; - bool has_gmux = false; int vga_count = 0; bool guid_valid; - int retval; + int retval = 0; bool ret = false; /* lookup the MXM GUID */ @@ -319,43 +316,31 @@ static bool nouveau_dsm_detect(void) while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { vga_count++; - retval = nouveau_dsm_pci_probe(pdev); - if (retval & NOUVEAU_DSM_HAS_MUX) - has_mux |= 1; - if (retval & NOUVEAU_DSM_HAS_OPT) - has_optimus = 1; - if (retval & NOUVEAU_DSM_HAS_GMUX) - has_gmux = true; + retval |= nouveau_dsm_pci_probe(pdev); } while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_3D << 8, pdev)) != NULL) { vga_count++; - retval = nouveau_dsm_pci_probe(pdev); - if (retval & NOUVEAU_DSM_HAS_MUX) - has_mux |= 1; - if (retval & NOUVEAU_DSM_HAS_OPT) - has_optimus = 1; - if (retval & NOUVEAU_DSM_HAS_GMUX) - has_gmux = true; + retval |= nouveau_dsm_pci_probe(pdev); } /* find the optimus DSM, the mux DSM or the gmux DSM */ - if (has_optimus == 1) { + if (retval & NOUVEAU_DSM_HAS_OPT) { acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer); printk(KERN_INFO "VGA switcheroo: detected Optimus DSM method %s handle\n", acpi_method_name); nouveau_dsm_priv.optimus_detected = true; ret = true; - } else if (vga_count == 2 && has_mux && guid_valid) { + } else if (vga_count == 2 && (retval & NOUVEAU_DSM_HAS_MUX) && guid_valid) { acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer); printk(KERN_INFO "VGA switcheroo: detected mux DSM switching method %s handle\n", acpi_method_name); nouveau_dsm_priv.mux_detected = true; ret = true; - } else if (has_gmux) { + } else if (retval & NOUVEAU_DSM_HAS_GMUX) { acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer); printk(KERN_INFO "VGA switcheroo: detected gmux DSM switching method %s handle\n",