Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2468424imw; Wed, 6 Jul 2022 06:31:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8NOPLKxGfqFGrk5rKGBMx6i/bkprfui7asUN0zzOAIFRxlE9aScqlh6KYNt4mrFrK5a// X-Received: by 2002:a17:902:bd93:b0:16b:a91d:5e77 with SMTP id q19-20020a170902bd9300b0016ba91d5e77mr38183884pls.110.1657114296478; Wed, 06 Jul 2022 06:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657114296; cv=none; d=google.com; s=arc-20160816; b=XBpRDVzCcqXV1sGgP23EN9pLIP5Sg9GZELsDox4sc5fxxmcUZI4P8YzZ3+JPTpY4C8 DXvrBjSkKjElB1n8uJVDBu0ODmRXvt8qwKjGKKTL307e90wtjCmf4+lLqDyYkpEhS40L a3228ooqSK7xdfM0/rct7lpgUfvCbxFA0v3WxrhvegkGXaNFE9BOa1Vvrf2zfupQiSnV Qh2z55Ej12vDOedxCDGc5OC8o4nqkLadeGggTYxP0/nR7q9H2xe7ifvE5svB/Fzad5C8 TbmmTOPYVLaLOHW9HhK/PGRXprPE8/Wa/LbdtXfBpXflbMHW30Ez0N5h8lkJP6fM2P2z mvkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=hSfHVYXNFeEy3tsy0JVnxam7d+rb85fYFmjYwl1pFlg=; b=mhsCV4y1TXQFngXj1Y22pcC/UHdgaoYo1dyAu3C/kh8yVqJr145T3na6lZ9QY1Q6RI TVDxpBLNx/cJReM8umzDuqIDP7i3v1hmk3owxChU2Tf3iAt154CkaqRSFmmOFcBlTfVT pkMog9tFzb/ICfg+31AcmyhYCWUoHPKTFbzTjiYgp/AY8AECZfsQT84I586dxmV/P4Xq oCu4ecLMitR6q7TEil/hwZGwyQYrJnWGzLoYyZwzMh7yCf3ARwnUimG8LqNcEBLxhDXR lGl6yw1R1ISGbXGTj922idms9oXDDNV1ocRpesIo3U1v4yo+/ZWPlV/qvpLITjeAkOEj 2nng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a170902be0400b00163937195dfsi29460125pls.201.2022.07.06.06.31.23; Wed, 06 Jul 2022 06:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232245AbiGFMh4 (ORCPT + 99 others); Wed, 6 Jul 2022 08:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231192AbiGFMhz (ORCPT ); Wed, 6 Jul 2022 08:37:55 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88EC71E3F0; Wed, 6 Jul 2022 05:37:53 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id ffb56cd6bc48098d; Wed, 6 Jul 2022 14:37:50 +0200 Received: from kreacher.localnet (unknown [213.134.187.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 44F5B66CAEB; Wed, 6 Jul 2022 14:37:50 +0200 (CEST) From: "Rafael J. Wysocki" To: Hans de Goede , Linux ACPI Cc: LKML Subject: [RFC][PATCH] ACPI: EC: Make evaluate acpi_ec_add() _REG for EC operation regions Date: Wed, 06 Jul 2022 14:37:49 +0200 Message-ID: <5592689.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.187.2 X-CLIENT-HOSTNAME: 213.134.187.2 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrudeifedgheefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepudejvdevgfegkeffffduhfeuleejieeivdeitdektdeiiedtiedvjeejudduteeknecuffhomhgrihhnpehuvghfihdrohhrghdpghhithhhuhgsrdgtohhmnecukfhppedvudefrddufeegrddukeejrddvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekjedrvddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepfedprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki acpi_ec_ecdt_probe() is called between acpi_load_tables() and acpi_enable_subsystem(). It passes ACPI_ROOT_OBJECT as ec->handle to acpi_ec_setup() and so ACPI_ROOT_OBJECT is passed to acpi_install_address_space_handler() via ec_install_handlers(). Next, acpi_ns_validate_handle() converts it to acpi_gbl_root_node which is passed to acpi_ev_install_space_handler() and the handler is installed for acpi_gbl_root_node. Now, acpi_gbl_root_node is passed to acpi_ev_execute_reg_methods() which evaluates _REG for any ACPI_ADR_SPACE_EC regions it can find in the namespace which should not be necessary, because the OS is expected to make the ECDT operation regions available before evaluating any AML, so in particular AML is not expected to check the evaluation of _REG before it accesses these operation regions (see ACPI 6.4, Section 6.5.4, exception 2 [1]). Doing that is also problematic, because the _REG methods for the ACPI_ADR_SPACE_EC regions may depend on various _INI, so they should be be evaluated before running acpi_initialize_objects() [2]. Address this problem by modifying acpi_install_address_space_handler() to avoid evaluating _REG for ACPI_ADR_SPACE_EC regions when the handler is installed for acpi_gbl_root_node which indicates the ECDT case. However, this needs to be accompanied by an EC driver change to actually trigger the evaluation of _REG for the ACPI_ADR_SPACE_EC regions when it finds the EC object in the namespace. Link: https://uefi.org/specs/ACPI/6.4/06_Device_Configuration/Device_Configuration.html#reg-region # [1] Link: https://github.com/acpica/acpica/pull/786 # [2] Signed-off-by: Rafael J. Wysocki --- Note: This change doesn't make any practical difference on any of the systems in my office. --- drivers/acpi/acpica/evxfregn.c | 12 ++++++++++++ drivers/acpi/ec.c | 7 +++++++ 2 files changed, 19 insertions(+) Index: linux-pm/drivers/acpi/ec.c =================================================================== --- linux-pm.orig/drivers/acpi/ec.c +++ linux-pm/drivers/acpi/ec.c @@ -1632,6 +1632,13 @@ static int acpi_ec_add(struct acpi_devic acpi_handle_debug(ec->handle, "duplicated.\n"); acpi_ec_free(ec); ec = boot_ec; + /* + * Uninstall the EC address space handler and let + * acpi_ec_setup() install it again along with + * evaluating _REG methogs associated with + * ACPI_ADR_SPACE_EC operation regions. + */ + ec_remove_handlers(ec); } } Index: linux-pm/drivers/acpi/acpica/evxfregn.c =================================================================== --- linux-pm.orig/drivers/acpi/acpica/evxfregn.c +++ linux-pm/drivers/acpi/acpica/evxfregn.c @@ -78,6 +78,18 @@ acpi_install_address_space_handler(acpi_ goto unlock_and_exit; } + /* + * Avoid evaluating _REG methods if an EC address space handler is + * installed for acpi_gbl_root_node, because this is done in order to + * make Embedded Controller operation regions, accessed via the Embedded + * Controllers described in ECDT, available early (see ACPI 6.4, Section + * 6.5.4, exception 2). + */ + + if (node == acpi_gbl_root_node || space_id == ACPI_ADR_SPACE_EC) { + goto unlock_and_exit; + } + /* Run all _REG methods for this address space */ acpi_ev_execute_reg_methods(node, space_id, ACPI_REG_CONNECT);