From patchwork Tue Oct 25 05:21:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9394005 X-Patchwork-Delegate: rjw@sisk.pl 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 7903C60231 for ; Tue, 25 Oct 2016 05:23:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E76B28D94 for ; Tue, 25 Oct 2016 05:23:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 622D728EB0; Tue, 25 Oct 2016 05:23:15 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 E85BF28D94 for ; Tue, 25 Oct 2016 05:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941502AbcJYFWn (ORCPT ); Tue, 25 Oct 2016 01:22:43 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:35180 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754886AbcJYFWA (ORCPT ); Tue, 25 Oct 2016 01:22:00 -0400 Received: by mail-oi0-f66.google.com with SMTP id n202so1756889oig.2; Mon, 24 Oct 2016 22:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G/p+rvXw90H2Kc0ZUaSdLHQal5Ifq6vtZ7uc4cYJOWA=; b=XwLtVJm5U+A14pQRRCc/nCcOes0QBPG9UN7yFhMA01P90Wz+jyDYTpZ3eCoFAnzdTj RmWfSQu3+pPk/Rp5r/PcezIm+0AcHtx0i+l2xq2fwtUYnprdMIYEItrv8STTEhfYon7X znd9RpDzwGAY7darwgXF8pEOIyukzefqk+MTPNeMGRcifP3hwLmRYq7VFrhIukNbhRz8 irBf0xYfATMWktItyJbpP2JF43YPF+5L+oBZdTJoqJ++HWQocTnou3o3nkf1lK59HIq+ YPna/eZYfS3Ty694VFeLG9ZqNQYpDhxVD0WpyDufNzslQ/1QCkwD3v8P4oA3VpZfm1RA TTKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G/p+rvXw90H2Kc0ZUaSdLHQal5Ifq6vtZ7uc4cYJOWA=; b=iZoEJOyq/GzzNw0hpgE79EcSJDoOhIjT/axYq1rSCHO31Y6ZqtHkbP3ggHc89iuhOT P43iZyXuvPv8MEsSbhONIyDHkrU6qvCWtR6bP9L+Qvn8Sc9lXADvviTFZPELupJiELjs mv9tlcs2+oSMPTdlCxVOQZuyZhO6wYy87zhZLXzYShzKSgUViWI3cF21hHDF0DkhC+Y/ 6WhPxJEkG+IZKQzw0tuyCtqA3pJ4FD0JrtjhcJJpKaDkCb/poLJuolq6YirU6zr5Sox2 ddwcurRNaRi0c5xuXVGi+Cgon662OIs/9o2jWOPP9vdb9MMomdnXJHZRyzKpXG0XjPfF wNJQ== X-Gm-Message-State: ABUngvfIRa1hKI94JwVSqF0h/G9Xu8SZzi2rmV8Wy88sTuLUFtpPHNn/++OvXKGP6Xm+8g== X-Received: by 10.157.60.168 with SMTP id z37mr4019193otc.129.1477372886578; Mon, 24 Oct 2016 22:21:26 -0700 (PDT) Received: from localhost.localdomain (h3.246.129.40.static.ip.windstream.net. [40.129.246.3]) by smtp.gmail.com with ESMTPSA id k1sm2364685otb.35.2016.10.24.22.21.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 22:21:26 -0700 (PDT) From: Lv Zheng X-Google-Original-From: Lv Zheng To: "Rafael J . Wysocki" , "Rafael J . Wysocki" , Len Brown Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Lv Zheng Subject: [PATCH 3/6] ACPICA: Dispatcher: Tune interpreter lock around acpi_ev_initialize_region() Date: Tue, 25 Oct 2016 13:21:23 +0800 Message-Id: <003bcff1ffb3ccc1d417f44f521e9450ee1ba2b6.1477372449.git.lv.zheng@intel.com> 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 In code path of acpi_ev_initialize_region(), there are namespace modification code unlocked. This patch tunes the code to make sure such modification are locked. Lv Zheng. Reported-by: Imre Deak Signed-off-by: Lv Zheng --- drivers/acpi/acpica/dsinit.c | 11 +++-------- drivers/acpi/acpica/dsmethod.c | 12 +++--------- drivers/acpi/acpica/dswload2.c | 2 -- drivers/acpi/acpica/evrgnini.c | 3 +++ drivers/acpi/acpica/nsload.c | 2 ++ 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c index f1e6dcc..54d48b9 100644 --- a/drivers/acpi/acpica/dsinit.c +++ b/drivers/acpi/acpica/dsinit.c @@ -46,6 +46,7 @@ #include "acdispat.h" #include "acnamesp.h" #include "actables.h" +#include "acinterp.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME("dsinit") @@ -214,23 +215,17 @@ acpi_ds_initialize_objects(u32 table_index, /* Walk entire namespace from the supplied root */ - status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - /* * We don't use acpi_walk_namespace since we do not want to acquire * the namespace reader lock. */ status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object, - NULL, &info, NULL); + 0, acpi_ds_init_one_object, NULL, &info, + NULL); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); } - (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); status = acpi_get_table_by_index(table_index, &table); if (ACPI_FAILURE(status)) { diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c index 5997e59..2b3210f 100644 --- a/drivers/acpi/acpica/dsmethod.c +++ b/drivers/acpi/acpica/dsmethod.c @@ -99,14 +99,11 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node, "Method auto-serialization parse [%4.4s] %p\n", acpi_ut_get_node_name(node), node)); - acpi_ex_enter_interpreter(); - /* Create/Init a root op for the method parse tree */ op = acpi_ps_alloc_op(AML_METHOD_OP, obj_desc->method.aml_start); if (!op) { - status = AE_NO_MEMORY; - goto unlock; + return_ACPI_STATUS(AE_NO_MEMORY); } acpi_ps_set_name(op, node->name.integer); @@ -118,8 +115,7 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node, acpi_ds_create_walk_state(node->owner_id, NULL, NULL, NULL); if (!walk_state) { acpi_ps_free_op(op); - status = AE_NO_MEMORY; - goto unlock; + return_ACPI_STATUS(AE_NO_MEMORY); } status = acpi_ds_init_aml_walk(walk_state, op, node, @@ -128,7 +124,7 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node, if (ACPI_FAILURE(status)) { acpi_ds_delete_walk_state(walk_state); acpi_ps_free_op(op); - goto unlock; + return_ACPI_STATUS(status); } walk_state->descending_callback = acpi_ds_detect_named_opcodes; @@ -138,8 +134,6 @@ acpi_ds_auto_serialize_method(struct acpi_namespace_node *node, status = acpi_ps_parse_aml(walk_state); acpi_ps_delete_parse_tree(op); -unlock: - acpi_ex_exit_interpreter(); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c index 028b22a..e362182 100644 --- a/drivers/acpi/acpica/dswload2.c +++ b/drivers/acpi/acpica/dswload2.c @@ -607,11 +607,9 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) } } - acpi_ex_exit_interpreter(); status = acpi_ev_initialize_region (acpi_ns_get_attached_object(node), FALSE); - acpi_ex_enter_interpreter(); if (ACPI_FAILURE(status)) { /* diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c index 3843f1f..75ddd16 100644 --- a/drivers/acpi/acpica/evrgnini.c +++ b/drivers/acpi/acpica/evrgnini.c @@ -45,6 +45,7 @@ #include "accommon.h" #include "acevents.h" #include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME("evrgnini") @@ -597,9 +598,11 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj, } } + acpi_ex_exit_interpreter(); status = acpi_ev_execute_reg_method(region_obj, ACPI_REG_CONNECT); + acpi_ex_enter_interpreter(); if (acpi_ns_locked) { status = diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c index 334d3c5..d1f2014 100644 --- a/drivers/acpi/acpica/nsload.c +++ b/drivers/acpi/acpica/nsload.c @@ -137,7 +137,9 @@ unlock: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Begin Table Object Initialization\n")); + acpi_ex_enter_interpreter(); status = acpi_ds_initialize_objects(table_index, node); + acpi_ex_exit_interpreter(); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "**** Completed Table Object Initialization\n"));