From patchwork Tue Jul 15 03:07:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 4550651 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 C6733C0514 for ; Tue, 15 Jul 2014 03:09:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F040620158 for ; Tue, 15 Jul 2014 03:08:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0FBDD2012D for ; Tue, 15 Jul 2014 03:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757750AbaGODHz (ORCPT ); Mon, 14 Jul 2014 23:07:55 -0400 Received: from mga11.intel.com ([192.55.52.93]:8693 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757741AbaGODHt (ORCPT ); Mon, 14 Jul 2014 23:07:49 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 14 Jul 2014 20:07:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,662,1400050800"; d="scan'208";a="561821073" Received: from ywang18-mobl.ccr.corp.intel.com (HELO lvzheng-z530.sh.intel.com) ([10.239.37.127]) by fmsmga001.fm.intel.com with ESMTP; 14 Jul 2014 20:07:46 -0700 From: Lv Zheng To: "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , , linux-acpi@vger.kernel.org Subject: [PATCH v2 5/9] ACPICA: Events: Fix an issue that acpi_set_gpe() cannot unconditionally enable GPEs. Date: Tue, 15 Jul 2014 11:07:44 +0800 Message-Id: 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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch adds unconditional GPE enabling support into acpi_set_gpe(). Originally this function checks if the GPE has been enabled with handlers and performs acknowledging before enabling it. First, IRQ enabling/disabling has 2 use cases: 1. When upper layers (the users of the driver) submit requests to the drivers, it means they care about the underlying hardware. For this case, acpi_enable_gpe() should be invoked. When the reference count is increased from 0 to 1, driver enables the hardware IRQ. And acpi_disable_gpe() is used as the reversal when the users have completed the submitted requests. 2. Driver may temporarily disables the IRQ and wants to re-enable it later, this case is normally used in order to prevent IRQ storm. When a driver cannot fully solve the condition that triggered the IRQ in the IRQ context, in order not to trigger IRQ storm, driver has to disable IRQ and re-enables it in the defered execution environment - which should be in a task context. This API should be used exactly for this purpose. Second, since the acpi_set_gpe() should be invoked from an IRQ handler, the handler check is useless for this API. Third, given the fact that drivers should complete all outstanding requests before putting themselves into the sleep states, as this API is executed for outstanding requests, it should also have nothing to do with the "RUN"/"WAKE" distinguishing. That's why the acpi_set_gpe(ACPI_GPE_ENABLE) should not be implemented by acpi_hw_low_set_gpe(ACPI_GPE_CONDITIONAL_ENABLE). Fourth, GPE clearing is used to acknowledge the GPE. The combination of acknowledging and enabling may not be expected by the hardware drivers. For GPE clearing, we have a seperate API acpi_clear_gpe(). There are cases drivers do want the 2 operations to be split. For example, a high IO throughput IRQ requires the IRQ to be cleared in the IRQ context. In order to avoid GPE storm, same driver need to invoke IRQ re-enabling in the task context. So splitting these 2 operations could facilitates drivers the maximum possibilities to achieve success. For a combined one, we already have acpi_finish_gpe() ready to be invoked. This patch converts acpi_set_gpe(ACPI_GPE_ENABLE) into acpi_hw_low_set_gpe(ACPI_GPE_ENABLE) to achieve a seperate GPE enabling API. Drivers are encouraged to use this API when they need to handle the above mentioned cases. Lv Zheng. Signed-off-by: Lv Zheng --- drivers/acpi/acpica/evxfgpe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index d66d50b..6c53633 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c @@ -218,7 +218,7 @@ acpi_status acpi_set_gpe(acpi_handle gpe_device, u32 gpe_number, u8 action) switch (action) { case ACPI_GPE_ENABLE: - status = acpi_ev_enable_gpe(gpe_event_info); + status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE); break; case ACPI_GPE_DISABLE: