From patchwork Sun Jun 15 00:41:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 4353811 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6F01ABEEAA for ; Sun, 15 Jun 2014 00:42:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BF5320279 for ; Sun, 15 Jun 2014 00:42:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8629D20259 for ; Sun, 15 Jun 2014 00:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751881AbaFOAmF (ORCPT ); Sat, 14 Jun 2014 20:42:05 -0400 Received: from mail-pb0-f48.google.com ([209.85.160.48]:53764 "EHLO mail-pb0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751844AbaFOAmE (ORCPT ); Sat, 14 Jun 2014 20:42:04 -0400 Received: by mail-pb0-f48.google.com with SMTP id rq2so1200888pbb.21 for ; Sat, 14 Jun 2014 17:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gDuM7LVDawRM2u7By/BynYXP2ddhNvNbzjy4A4oSjig=; b=fUd4Yw7xRBoQLzJ9Jo7+Aor1mCN96nSU6tGEl/9SMYfDiKdsy6oVTo6Uf3wbwhOPFr yaudnZrscyNfGzJEbE7dErGSWzDy46lKiuTDEP9VYmq4QRADhcRMbII5wns52uvhlGZF +iWldd1Iomf39aAQCP5L5BHVfBFGcu7xlJ3RcZeSGLDp3wYnF6UPzGBqVt+rXUkhVJYN t1PF8OE1rWwuGSZA9FLI89lzuo0dFGK7ruUuVHkUj9Sp1TRit/VGSKXWSES++20XfAjl HUfM4nYFjcaLbJIuk1TuxnK2XHSz4T7dYq1sbYJ/IbJ5kEeAbh9J2geecY3gYnEZ/eSX 9nzw== X-Received: by 10.66.124.225 with SMTP id ml1mr1224179pab.33.1402792923781; Sat, 14 Jun 2014 17:42:03 -0700 (PDT) Received: from localhost.localdomain ([180.169.136.70]) by mx.google.com with ESMTPSA id iv2sm10884050pbc.19.2014.06.14.17.41.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Jun 2014 17:42:03 -0700 (PDT) From: Lv Zheng To: "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , , linux-acpi@vger.kernel.org Subject: [PATCH v2 3/7] ACPI/EC: Remove duplicated ec_wait_ibf0() waiter. Date: Sun, 15 Jun 2014 08:41:48 +0800 Message-Id: <5f8350870bcee8d92704eef1285d03725a576c26.1402792240.git.lv.zheng@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: References: Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Lv Zheng After we've added the first command byte write into advance_transaction(), the IBF=0 waiter is duplicated with the command completion waiter implemented in the ec_poll() because: If IBF=1 blocked the first command byte write invoked in the task context ec_poll(), it would be kicked off upon IBF=0 interrupt or timed out and retried again in the task context. This patch removes this seperate and duplicate IBF=0 waiter, by doing so, we can reduce the overall number of times to access the EC_SC(R) status register. Reference: https://bugzilla.kernel.org/show_bug.cgi?id=70891 Signed-off-by: Lv Zheng Reported-and-tested-by: Gareth Williams Tested-by: Steffen Weber [zetalog: first affected by:] Cc: # 2.6.11: 7c6db4e0: ACPI: EC: do transaction from interrupt context [zetalog: cleanly applying to:] Cc: # 3.14.x: 42b946bb: ACPI / EC: disable GPE before removing GPE handler --- drivers/acpi/ec.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index f09386e..d016ea3 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -281,23 +281,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, return ret; } -static int ec_check_ibf0(struct acpi_ec *ec) -{ - u8 status = acpi_ec_read_status(ec); - return (status & ACPI_EC_FLAG_IBF) == 0; -} - -static int ec_wait_ibf0(struct acpi_ec *ec) -{ - unsigned long delay = jiffies + msecs_to_jiffies(ec_delay); - /* interrupt wait manually if GPE mode is not active */ - while (time_before(jiffies, delay)) - if (wait_event_timeout(ec->wait, ec_check_ibf0(ec), - msecs_to_jiffies(1))) - return 0; - return -ETIME; -} - static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) { int status; @@ -318,12 +301,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) goto unlock; } } - if (ec_wait_ibf0(ec)) { - pr_err("input buffer is not empty, " - "aborting transaction\n"); - status = -ETIME; - goto end; - } pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n", t->command, t->wdata ? t->wdata[0] : 0); /* disable GPE during transaction if storm is detected */ @@ -347,7 +324,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) set_bit(EC_FLAGS_GPE_STORM, &ec->flags); } pr_debug("transaction end\n"); -end: if (ec->global_lock) acpi_release_global_lock(glk); unlock: @@ -653,8 +629,7 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, spin_lock_irqsave(&ec->lock, flags); advance_transaction(ec); spin_unlock_irqrestore(&ec->lock, flags); - if (ec_transaction_completed(ec) && - (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { + if (ec_transaction_completed(ec)) { wake_up(&ec->wait); ec_check_sci(ec, acpi_ec_read_status(ec)); }