From patchwork Mon May 16 09:11:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9099271 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 185D39F30C for ; Mon, 16 May 2016 09:11:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22B22201B4 for ; Mon, 16 May 2016 09:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B7E12028D for ; Mon, 16 May 2016 09:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752432AbcEPJLl (ORCPT ); Mon, 16 May 2016 05:11:41 -0400 Received: from mga14.intel.com ([192.55.52.115]:62070 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753299AbcEPJL2 (ORCPT ); Mon, 16 May 2016 05:11:28 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 16 May 2016 02:11:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,626,1455004800"; d="scan'208";a="967756881" Received: from lvzheng-z530.sh.intel.com ([10.239.159.67]) by fmsmga001.fm.intel.com with ESMTP; 16 May 2016 02:11:25 -0700 From: Lv Zheng To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , , linux-acpi@vger.kernel.org Subject: [PATCH 3/3] ACPI / sysfs: Provide quirk mechanism to prevent GPE flooding Date: Mon, 16 May 2016 17:11:24 +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=-8.3 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 Sometimes, the users may require a quirk to be provided from ACPI subsystem core to prevent a GPE from flooding. Normally, if a GPE cannot be dispatched, ACPICA core automatically prevents the GPE from firing. But there are cases the GPE is dispatched by _Lxx/_Exx provided via AML table, and OSPM is lacking of the knowledge to get _Lxx/_Exx correctly executed to handle the GPE, thus the GPE flooding may still occur. This patch provides a quirk mechanism to stop this kind of GPE flooding. Link: https://bugzilla.kernel.org/show_bug.cgi?id=53071 Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/887793 Signed-off-by: Lv Zheng --- drivers/acpi/internal.h | 1 + drivers/acpi/scan.c | 1 + drivers/acpi/sleep.c | 2 ++ drivers/acpi/sysfs.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 9bb0773..d0f1744 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -37,6 +37,7 @@ void acpi_amba_init(void); static inline void acpi_amba_init(void) {} #endif int acpi_sysfs_init(void); +void acpi_gpe_apply_blocked_gpes(void); void acpi_container_init(void); void acpi_memory_hotplug_init(void); #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5f28cf7..5ff366c 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1958,6 +1958,7 @@ int __init acpi_scan_init(void) } } + acpi_gpe_apply_blocked_gpes(); acpi_update_all_gpes(); out: diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index d00544c..daba3ba 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -414,6 +414,7 @@ static void acpi_pm_finish(void) acpi_state); acpi_disable_wakeup_devices(acpi_state); acpi_leave_sleep_state(acpi_state); + acpi_gpe_apply_blocked_gpes(); /* reset firmware waking vector */ acpi_set_waking_vector(0); @@ -774,6 +775,7 @@ static void acpi_pm_thaw(void) { acpi_ec_unblock_transactions(); acpi_enable_all_runtime_gpes(); + acpi_gpe_apply_blocked_gpes(); } static const struct platform_hibernation_ops acpi_hibernation_ops = { diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 7f33c90..a2fb524 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -715,6 +715,62 @@ end: return result ? result : size; } +/* + * A Quirk Mechanism for GPE Flooding Prevention: + * + * Quirks may be needed to prevent GPE flooding on a specific GPE. The + * flooding typically cannot be detected and automatically prevented by + * ACPI_GPE_DISPATCH_NONE check because there is a _Lxx/_Exx prepared in + * the AML tables. This normally indicates a feature gap in Linux, thus + * instead of providing endless quirk tables, we provide a boot parameter + * for those who want this quirk. For example, if the users want to prevent + * the GPE flooding for GPE 00, they need to specify the following boot + * parameter: + * acpi.block_gpe=0x00 + * The blocking status can be modified by the following runtime controlling + * interface: + * echo unblock > /sys/firmware/acpi/interrupts/gpe00 + */ + +/* + * Currently, the GPE flooding prevention only supports to block the GPEs + * numbered from 00 to 63. + */ +#define ACPI_BLOCKABLE_GPE_MAX 64 + +static u64 acpi_blocked_gpes; + +static int __init acpi_gpe_set_blocked_gpes(char *val) +{ + u8 gpe; + + if (kstrtou8(val, 0, &gpe) || gpe > ACPI_BLOCKABLE_GPE_MAX) + return -EINVAL; + acpi_blocked_gpes |= ((u64)1<