From patchwork Thu Aug 17 02:21:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9904813 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 D085760231 for ; Thu, 17 Aug 2017 02:21:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCD6528949 for ; Thu, 17 Aug 2017 02:21:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1C4728995; Thu, 17 Aug 2017 02:21:10 +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=ham 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 2317728949 for ; Thu, 17 Aug 2017 02:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751944AbdHQCVJ (ORCPT ); Wed, 16 Aug 2017 22:21:09 -0400 Received: from mga01.intel.com ([192.55.52.88]:18325 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751752AbdHQCVJ (ORCPT ); Wed, 16 Aug 2017 22:21:09 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Aug 2017 19:21:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,385,1498546800"; d="scan'208";a="1206586902" Received: from unknown (HELO lvzheng-MOBLsp3.sh.intel.com) ([10.239.159.74]) by fmsmga002.fm.intel.com with ESMTP; 16 Aug 2017 19:21:07 -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 v2 1/2] ACPI: EC: Fix a regression related to wrong ECDT initialization order Date: Thu, 17 Aug 2017 10:21:04 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: <756461e045cbddb16418685a1b12c3c9a491d328.1502868457.git.lv.zheng@intel.com> References: <756461e045cbddb16418685a1b12c3c9a491d328.1502868457.git.lv.zheng@intel.com> 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 The following commit is bisected out to be a regression culprit: Commit: c712bb58d8278465b1a91f362a08f5c79ad077e4 Subject: ACPI / EC: Add support to skip boot stage DSDT probe However the problem is actually originated from the following commit: Commit: 2a5708409e4e05446eb1a89ecb48641d6fd5d5a9 Subject: ACPI / EC: Fix a gap that ECDT EC cannot handle EC events Commit 2a570840 introduces acpi_ec_ecdt_start(), but invokes it too early: earlier before acpi_ec_query_init(). Thus when EC event is flagged after boot, ec_query_wq is not valid, resulting in a kernel warning: [ 3.580017] BUG: unable to handle kernel NULL pointer dereference at 0000000000000102 ... [ 4.380005] Workqueue: events acpi_ec_event_handler [ 4.380005] task: ffff9f539790dac0 task.stack: ffffb437c0e10000 [ 4.380005] RIP: 0010:__queue_work+0x32/0x430 Normally DSDT EC should always be valid. Thus acpi_ec_ecdt_start() is actually a no-op in most of the cases. While the commit c712bb58 skips probing DSDT EC as boot EC when ECDT EC is valid, making this bug surfaced. This patch fixes this issue by invoking acpi_ec_ecdt_start() after acpi_ec_query_init() in acpi_ec_init(). Link: https://jira01.devtools.intel.com/browse/LCK-4348 Fixes: 2a5708409e4e ("ACPI / EC: Fix a gap that ECDT EC cannot handle EC events") Fixes: c712bb58d827 ("ACPI / EC: Add support to skip boot stage DSDT probe") Reported-by: Wang Wendy Tested-by: Feng Chenzhou Signed-off-by: Lv Zheng --- drivers/acpi/ec.c | 17 +++++++---------- drivers/acpi/internal.h | 1 - drivers/acpi/scan.c | 2 -- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 62068a5..ae3d6d1 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1741,7 +1741,7 @@ int __init acpi_ec_dsdt_probe(void) * functioning ECDT EC first in order to handle the events. * https://bugzilla.kernel.org/show_bug.cgi?id=115021 */ -int __init acpi_ec_ecdt_start(void) +static int __init acpi_ec_ecdt_start(void) { acpi_handle handle; @@ -2003,20 +2003,17 @@ static inline void acpi_ec_query_exit(void) int __init acpi_ec_init(void) { int result; + int ecdt_fail, dsdt_fail; /* register workqueue for _Qxx evaluations */ result = acpi_ec_query_init(); if (result) - goto err_exit; - /* Now register the driver for the EC */ - result = acpi_bus_register_driver(&acpi_ec_driver); - if (result) - goto err_exit; + return result; -err_exit: - if (result) - acpi_ec_query_exit(); - return result; + /* Drivers must be started after acpi_ec_query_init() */ + ecdt_fail = acpi_ec_ecdt_start(); + dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver); + return ecdt_fail && dsdt_fail ? -ENODEV : 0; } /* EC driver currently not unloadable */ diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index ee066d7..4361c44 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -185,7 +185,6 @@ typedef int (*acpi_ec_query_func) (void *data); int acpi_ec_init(void); int acpi_ec_ecdt_probe(void); int acpi_ec_dsdt_probe(void); -int acpi_ec_ecdt_start(void); void acpi_ec_block_transactions(void); void acpi_ec_unblock_transactions(void); int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index c3bf049..602f8ff 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2166,8 +2166,6 @@ int __init acpi_scan_init(void) } } - acpi_ec_ecdt_start(); - acpi_scan_initialized = true; out: