From patchwork Fri Jan 6 08:58:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Yu C" X-Patchwork-Id: 9500219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 851E0606B5 for ; Fri, 6 Jan 2017 08:50:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79D0E283F0 for ; Fri, 6 Jan 2017 08:50:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A6D52841E; Fri, 6 Jan 2017 08:50:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E89EA283F0 for ; Fri, 6 Jan 2017 08:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751522AbdAFItr (ORCPT ); Fri, 6 Jan 2017 03:49:47 -0500 Received: from mga09.intel.com ([134.134.136.24]:38527 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751447AbdAFItA (ORCPT ); Fri, 6 Jan 2017 03:49:00 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 06 Jan 2017 00:48:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,323,1477983600"; d="scan'208";a="1108760862" Received: from yu-desktop-1.sh.intel.com ([10.239.160.134]) by fmsmga002.fm.intel.com with ESMTP; 06 Jan 2017 00:48:57 -0800 From: Chen Yu To: linux-acpi@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-kernel@vger.kernel.org, Lv Zheng Subject: [PATCH] ACPI / EC: Use busy polling mode when GPE is not enabled Date: Fri, 6 Jan 2017 16:58:23 +0800 Message-Id: <1483693104-14003-1-git-send-email-yu.c.chen@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lv Zheng Previously we have report that during system bootup, the EC command was running too slow because the EC GPE has not been enabled yet (For example, _REG tries to access the EC operation region, while the EC GPE has not been enabled at that stage). Actually we can optimize this scenario by using busy polling mode if GPE is disabled, which is much faster than the default behavior. Reported-and-tested-by: Chen Yu Signed-off-by: Lv Zheng --- drivers/acpi/ec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 48e19d0..457949d 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -342,6 +342,14 @@ static const char *acpi_ec_cmd_string(u8 cmd) * GPE Registers * -------------------------------------------------------------------------- */ +static inline bool acpi_ec_is_gpe_enabled(struct acpi_ec *ec) +{ + acpi_event_status gpe_status = 0; + + (void)acpi_get_gpe_status(NULL, ec->gpe, &gpe_status); + return (gpe_status & ACPI_EVENT_FLAG_ENABLE_SET) ? true : false; +} + static inline bool acpi_ec_is_gpe_raised(struct acpi_ec *ec) { acpi_event_status gpe_status = 0; @@ -734,7 +742,7 @@ static int ec_guard(struct acpi_ec *ec) /* Ensure guarding period before polling EC status */ do { - if (ec_busy_polling) { + if (!acpi_ec_is_gpe_enabled(ec) || ec_busy_polling) { /* Perform busy polling */ if (ec_transaction_completed(ec)) return 0;