Received: by 10.213.65.68 with SMTP id h4csp2113917imn; Sun, 8 Apr 2018 20:04:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx482XS0siqwDbbDI0B6sjEK5fqedGdWsgw5kXT/MgQOMluqq3gMZdfVmzF2gd8LSHzZxozDP X-Received: by 2002:a17:902:bb8c:: with SMTP id m12-v6mr19248218pls.119.1523243040792; Sun, 08 Apr 2018 20:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243040; cv=none; d=google.com; s=arc-20160816; b=AfGHnHo/q+Wei5Uk0bg3902qMu/1MASlzZcNlMhjPOUdhCuIZWo41iwab8V0vwIMME uNKXdQhVkjnbKoUm42yNLD4i1FsSfjD8GboiPu38nDDg5rvobFeO0uARUKO5UZX3qD2a rJgR3c8oIHhfbUpFgRa7x5Sy+e5BoaLBKS/c+5zhwr2TEGIP+zpcogVzBh6AxHivOgp/ VS6u9BNxqp2xjOnQ988qIDnHNOvKJyNx3YPrQAwWk4rwIgBf8AgtEJAjor02KIUErFWH jLj35fyk+CNYxohXKsKL9E2cLxZK0gSvgld7RsgIC62PBju31iJ/YY1FEWBbItOCbk4+ Q23g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=YEDQNPuQVkiq57B9ck0a0x1BvKp6aoOiQRveSfpqOOU=; b=n/f1blTtnngMkcB/Uo6psifY8GPSJT06/QluiDiqaF9q4zNT8K7pVdkkUOKO7hsSPW RJdjfIEKlm4mOGVXT2N3S8hKOH89T7Jp/NkF6aPva9UhtJKLDW9IoOif2qyevCR5ySa9 jUzsNdzK+F4BScLujqwXAGwxUN5WOSgEsrWRkjeKhJURubTqDnLGSBdSOS5amzuqhOcu /9N0SRUgBHNxIY9rHPFV3vXrcDqxafTcwE2VbvERRpxu1CnJPyXqJHq2ia5FCFHmV9v/ RgEE5zF467ZbDry9zl0n2rzmqxVxlrSTGSy+Jq6ONq71LGssR+E24o8pjLgtApJn0YGd hUcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=A6VZra8K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si9890034pfi.53.2018.04.08.20.03.23; Sun, 08 Apr 2018 20:04:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=A6VZra8K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756187AbeDIAbL (ORCPT + 99 others); Sun, 8 Apr 2018 20:31:11 -0400 Received: from mail-by2nam03on0135.outbound.protection.outlook.com ([104.47.42.135]:16544 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754852AbeDIAbI (ORCPT ); Sun, 8 Apr 2018 20:31:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YEDQNPuQVkiq57B9ck0a0x1BvKp6aoOiQRveSfpqOOU=; b=A6VZra8KxP0IznTrLTMqVdvW9I0kKLMdXUzLGGIqhqk/RTZ5gbglUbnz7zMO9DoE5nxTmdW3lydT+PseTcNp21ufMGK+U07w8igXMidNVs/SU9f81qFXg2cQ4zFBKEsGD3D4mTCGk8DT0lrKSf6/fMEQI627zPR2i6wBuzr8CI0= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0917.namprd21.prod.outlook.com (52.132.132.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:31:06 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:31:06 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Lv Zheng , "Rafael J . Wysocki" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 153/293] ACPI: EC: Fix an EC event IRQ storming issue Thread-Topic: [PATCH AUTOSEL for 4.9 153/293] ACPI: EC: Fix an EC event IRQ storming issue Thread-Index: AQHTz5ktzhihB7tgB0uOmopJKil5EA== Date: Mon, 9 Apr 2018 00:24:53 +0000 Message-ID: <20180409002239.163177-153-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0917;7:/Nd4iMK9c5Ih8/kNjwxWqkOnvUyBV9vIYMI8fNyao428G3pm0SVGRJ+TkgfyXnnrUCXAXSH+sjmQ2miqXdv4wa9rPaRqJu/lS3AUEPqatUf5FgAPO9Y3eltmIknBpYbUsCQt1/iWI/FSQQ8x+Fb8o46Ez/SjucGjeUVsH5wIc241XoevpG/+1b/IFZSNExjuNTvxKn7hRJ1U4uCtN6NoFrZsVhE93OcsyCLNuoPSWHgFVU6bz6mrsG6R1o1dLIiP;20:X3wJa2+BpWU/xJTSJbjDpVnFrByz3NuWu4cZodbk/dHBZdLoPh4UeUmMvGadRP+6CW/I5ngwAybJkQB3IsUwKehmgM1NFDuD/Kv+ROSNu0Qd9+kgHntkgppqEBqzefW4cRRYvCbWNK5Xa5Y3/jqe04U2CrvRoHxT9gvUwssnv9k= X-MS-Office365-Filtering-Correlation-Id: 1474fb5f-faef-4690-daf3-08d59db12ebb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB0917; x-ms-traffictypediagnostic: DM5PR2101MB0917: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0917;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0917; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(366004)(396003)(346002)(376002)(189003)(199004)(99286004)(22452003)(106356001)(26005)(110136005)(478600001)(54906003)(10290500003)(316002)(1076002)(72206003)(186003)(4326008)(97736004)(66066001)(11346002)(25786009)(86362001)(575784001)(476003)(446003)(2906002)(6666003)(6486002)(105586002)(86612001)(3280700002)(3660700001)(6512007)(3846002)(6116002)(6436002)(2616005)(486006)(53936002)(7736002)(8676002)(81166006)(81156014)(8936002)(68736007)(305945005)(10090500001)(76176011)(6506007)(102836004)(36756003)(107886003)(59450400001)(2900100001)(2501003)(14454004)(5660300001)(5250100002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0917;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 2rl3bmY9NgLs8oXoIye6gB5vqhFerSDEYI3mQJCeT7tnWjeE3JvpsM1m3CP0unr1LexqUdBBxuacj6jOfbP/A8H+UW+rRcH7MbrjqHuHmVfVCMyfhVmK6MVyfXlra6eZ9NZgaEGYJQkYUdkMoUXo9Ci0qErTkYTPsbsRMbrdQsUucE2mkYXgyLMP81EbaTuPSaAL4Vrbi448InLaGv1u17nEf9mQ7JXnxU1+wV/D199KFPxoewMJBJ4k1Kf6I/Zzxr6QNwaF4+pDbs59eYc7Nmws+ZquyzJrji6Wl781fJi/xbsJHDajBpt1jzHTdwGePl2A4p798g4DvvxQfZ9utTd9G12peOkqrgkEOrbZ4GP3mZzt0Ge4vIWNwqvpUznfdWFS2Xiy5iLKj/BUMrXasQtTZTS+Q8do8Hh6c8rNS+o= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1474fb5f-faef-4690-daf3-08d59db12ebb X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:53.0188 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0917 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Zheng [ Upstream commit 1ab69f27cbb57e0f970bcd852d9f22ed34259b57 ] The EC event IRQ (SCI_EVT) can only be handled by submitting QR_EC. As the EC driver handles SCI_EVT in a workqueue, after SCI_EVT is flagged and before QR_EC is submitted, there is a period risking IRQ storming. EC IRQ must be masked for this period but linux EC driver never does so. No end user notices the IRQ storming and no developer fixes this known issue because: 1. The EC IRQ is always edge triggered GPE, and 2. The kernel can execute no-op EC IRQ handler very fast. For edge-triggered EC GPE platforms, it is only reported of post-resume EC event lost issues, there won't be an IRQ storming. For level triggered EC GPE platforms, fortunately the kernel is always fast enough to execute such a no-op EC IRQ handler so that the IRQ handler won't be accumulated to starve the task contexts, causing a real IRQ storming. But the IRQ storming actually can still happen when: 1. The EC IRQ performs like level triggered GPE, and 2. The kernel EC debugging log is turned on but the console is slow enough= . There are more and more platforms using EC GPE as wake GPE where the EC GPE is likely designed as level triggered. Then when EC debugging log is enabled, the EC IRQ handler is no longer a no-op but dumps IRQ status to the consoles. If the consoles are slow enough, the EC IRQs can arrive much faster than executing the handler. Finally the accumulated EC event IRQ handlers starve the task contexts, causing the IRQ storming to occur, and the kernel hangs can be observed during boot/resume. This patch fixes this issue by masking EC IRQ for this period: 1. Begins when there is an SCI_EVT IRQ pending, and 2. Ends when there is a QR_EC completed (SCI_EVT acknowledged). Tested-by: Wang Wendy Tested-by: Feng Chenzhou Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/ec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index c3bcb7f5986e..38136d608471 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -460,8 +460,10 @@ static bool acpi_ec_submit_flushable_request(struct ac= pi_ec *ec) =20 static void acpi_ec_submit_query(struct acpi_ec *ec) { - if (acpi_ec_event_enabled(ec) && - !test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { + acpi_ec_set_storm(ec, EC_FLAGS_COMMAND_STORM); + if (!acpi_ec_event_enabled(ec)) + return; + if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { ec_dbg_evt("Command(%s) submitted/blocked", acpi_ec_cmd_string(ACPI_EC_COMMAND_QUERY)); ec->nr_pending_queries++; @@ -471,11 +473,10 @@ static void acpi_ec_submit_query(struct acpi_ec *ec) =20 static void acpi_ec_complete_query(struct acpi_ec *ec) { - if (test_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { - clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); + if (test_and_clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) ec_dbg_evt("Command(%s) unblocked", acpi_ec_cmd_string(ACPI_EC_COMMAND_QUERY)); - } + acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); } =20 static inline void __acpi_ec_enable_event(struct acpi_ec *ec) --=20 2.15.1