From patchwork Fri Jul 30 06:21:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenji Kaneshige X-Patchwork-Id: 115407 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6U6KtH4009840 for ; Fri, 30 Jul 2010 06:22:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752386Ab0G3GVu (ORCPT ); Fri, 30 Jul 2010 02:21:50 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:33750 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752285Ab0G3GVu (ORCPT ); Fri, 30 Jul 2010 02:21:50 -0400 Received: from m2.gw.fujitsu.co.jp ([10.0.50.72]) by fgwmail6.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o6U6LlIE018717 (envelope-from kaneshige.kenji@jp.fujitsu.com); Fri, 30 Jul 2010 15:21:48 +0900 Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id BEF9E45DE4F; Fri, 30 Jul 2010 15:21:47 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 9DF7845DE4E; Fri, 30 Jul 2010 15:21:47 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 83A661DB8038; Fri, 30 Jul 2010 15:21:47 +0900 (JST) Received: from m107.s.css.fujitsu.com (m107.s.css.fujitsu.com [10.249.87.107]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 2F1111DB803C; Fri, 30 Jul 2010 15:21:47 +0900 (JST) Received: from m107.css.fujitsu.com (m107 [127.0.0.1]) by m107.s.css.fujitsu.com (Postfix) with ESMTP id 00154670003; Fri, 30 Jul 2010 15:21:46 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.102.21]) by m107.s.css.fujitsu.com (Postfix) with ESMTP id 7A75B670001; Fri, 30 Jul 2010 15:21:46 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Received: from KANE-LIFEBOOK[10.124.102.21] by KANE-LIFEBOOK (FujitsuOutboundMailChecker v1.3.1/9992[10.124.102.21]); Fri, 30 Jul 2010 15:21:24 +0900 (JST) Message-ID: <4C526F5B.2050202@jp.fujitsu.com> Date: Fri, 30 Jul 2010 15:21:15 +0900 From: Kenji Kaneshige User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6 MIME-Version: 1.0 To: "Rafael J. Wysocki" CC: Jesse Barnes , Len Brown , ACPI Devel Maling List , linux-pm@lists.linux-foundation.org, linux-pci@vger.kernel.org, Matthew Garrett , Hidetoshi Seto Subject: [PATCH 2/6] ACPI/PCI: do not preserve query result References: <201007282323.56351.rjw@sisk.pl> <20100728144358.5e2c12ce@virtuousgeek.org> <4C510B90.9070302@jp.fujitsu.com> <201007291745.39285.rjw@sisk.pl> <4C526A85.3070902@jp.fujitsu.com> <4C526E3E.3000600@jp.fujitsu.com> In-Reply-To: <4C526E3E.3000600@jp.fujitsu.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 30 Jul 2010 06:22:05 +0000 (UTC) Index: linux-2.6.35-rc6/drivers/acpi/pci_root.c =================================================================== --- linux-2.6.35-rc6.orig/drivers/acpi/pci_root.c +++ linux-2.6.35-rc6/drivers/acpi/pci_root.c @@ -230,35 +230,42 @@ static acpi_status acpi_pci_run_osc(acpi return status; } -static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root, u32 flags) +static acpi_status acpi_pci_osc_control_query(struct acpi_pci_root *root, + u32 flags, u32 *result) { - acpi_status status; - u32 result; - - /* do _OSC query for all possible controls */ - flags &= OSC_PCI_SUPPORT_MASKS; - status = acpi_pci_run_osc(root->device->handle, - root->osc_support_set | flags, - OSC_PCI_CONTROL_MASKS, - true, &result); - if (ACPI_SUCCESS(status)) { - root->osc_support_set |= flags; - root->osc_control_qry = result; - root->osc_queried = 1; + /* No need to run _OSC if requested control bits are already granted */ + flags &= OSC_PCI_CONTROL_MASKS; + if ((root->osc_control_set & flags) == flags) { + *result = root->osc_control_set; + return AE_OK; } - return status; + return acpi_pci_run_osc(root->device->handle, + root->osc_support_set, + root->osc_control_set | flags, + true, result); } static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags) { acpi_status status; acpi_handle tmp; + u32 result; status = acpi_get_handle(root->device->handle, "_OSC", &tmp); if (ACPI_FAILURE(status)) return status; mutex_lock(&osc_lock); - status = acpi_pci_query_osc(root, flags); + /* No need to run _OSC if requested support bits are already set */ + flags &= OSC_PCI_SUPPORT_MASKS; + if ((root->osc_support_set & flags) == flags) + goto out; + status = acpi_pci_run_osc(root->device->handle, + root->osc_support_set | flags, + root->osc_control_set, + true, &result); + if (ACPI_SUCCESS(status)) + root->osc_support_set |= flags; +out: mutex_unlock(&osc_lock); return status; } @@ -399,12 +406,10 @@ acpi_status acpi_pci_osc_control_set(acp goto out; /* Need to query controls first before requesting them */ - if (!root->osc_queried) { - status = acpi_pci_query_osc(root, root->osc_support_set); - if (ACPI_FAILURE(status)) - goto out; - } - if ((root->osc_control_qry & control_req) != control_req) { + status = acpi_pci_osc_control_query(root, control_req, &result); + if (ACPI_FAILURE(status)) + goto out; + if ((result & control_req) != control_req) { printk(KERN_DEBUG "Firmware did not grant requested _OSC control\n"); status = AE_SUPPORT; Index: linux-2.6.35-rc6/include/acpi/acpi_bus.h =================================================================== --- linux-2.6.35-rc6.orig/include/acpi/acpi_bus.h +++ linux-2.6.35-rc6/include/acpi/acpi_bus.h @@ -377,9 +377,6 @@ struct acpi_pci_root { u32 osc_support_set; /* _OSC state of support bits */ u32 osc_control_set; /* _OSC state of control bits */ - u32 osc_control_qry; /* the latest _OSC query result */ - - u32 osc_queried:1; /* has _OSC control been queried? */ }; /* helper */