From patchwork Fri Aug 11 05:57:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9894989 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 04ED660236 for ; Fri, 11 Aug 2017 05:57:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE89D28BFA for ; Fri, 11 Aug 2017 05:57:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D14DD28BFC; Fri, 11 Aug 2017 05:57:54 +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=unavailable 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 59F3F28BFA for ; Fri, 11 Aug 2017 05:57:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752317AbdHKF5q (ORCPT ); Fri, 11 Aug 2017 01:57:46 -0400 Received: from mga11.intel.com ([192.55.52.93]:11321 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752269AbdHKF5n (ORCPT ); Fri, 11 Aug 2017 01:57:43 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Aug 2017 22:57:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,356,1498546800"; d="scan'208";a="122416411" Received: from unknown (HELO lvzheng-MOBLsp3.sh.intel.com) ([10.239.159.74]) by orsmga002.jf.intel.com with ESMTP; 10 Aug 2017 22:57:40 -0700 From: Lv Zheng To: "Rafael J . Wysocki" , Len Brown , Robert Moore , Lv Zheng , "David E . Box" Cc: Lv Zheng , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devel@acpica.org Subject: [PATCH 2/2] ACPICA: Events: Dispatch GPEs after enabling for the first time Date: Fri, 11 Aug 2017 13:57:39 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: 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 After being enabled for the first time, the GPEs may have STS bits already set. Setting EN bits is not sufficient to trigger the GPEs again, so this patch polls GPEs after enabling them for the first time. This is a simpler version on top of the "GPE clear" fix generated according to Mika's report and Rafael's original Linux based fix. Based on Linux commit originated from Rafael J. Wysocki, fixed by Lv Zheng, tested by Mika Westerberg. Original-by: Rafael J. Wysocki Signed-off-by: Lv Zheng Tested-by: Mika Westerberg --- drivers/acpi/acpica/evxfgpe.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index 57718a3..d8be21d 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c @@ -97,6 +97,14 @@ acpi_status acpi_update_all_gpes(void) unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); + /* + * Poll GPEs to handle already triggered events. + * It is not sufficient to trigger edge-triggered GPE with specific + * GPE chips, software need to poll once after enabling. + */ + if (acpi_gbl_all_gpes_initialized) { + acpi_ev_gpe_detect(acpi_gbl_gpe_xrupt_list_head); + } return_ACPI_STATUS(status); } @@ -120,6 +128,7 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) acpi_status status = AE_BAD_PARAMETER; struct acpi_gpe_event_info *gpe_event_info; acpi_cpu_flags flags; + u8 poll_gpes = FALSE; ACPI_FUNCTION_TRACE(acpi_enable_gpe); @@ -135,12 +144,25 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) != ACPI_GPE_DISPATCH_NONE) { status = acpi_ev_add_gpe_reference(gpe_event_info); + if (ACPI_SUCCESS(status) && + gpe_event_info->runtime_count == 1) { + poll_gpes = TRUE; + } } else { status = AE_NO_HANDLER; } } acpi_os_release_lock(acpi_gbl_gpe_lock, flags); + + /* + * Poll GPEs to handle already triggered events. + * It is not sufficient to trigger edge-triggered GPE with specific + * GPE chips, software need to poll once after enabling. + */ + if (poll_gpes && acpi_gbl_all_gpes_initialized) { + acpi_ev_gpe_detect(acpi_gbl_gpe_xrupt_list_head); + } return_ACPI_STATUS(status); } ACPI_EXPORT_SYMBOL(acpi_enable_gpe)