Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1201147pxj; Fri, 4 Jun 2021 08:25:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWjfE8jpdBzIyocVljTmFLVR8CMzk7+2JGoEpxMSXqaqHQPrDwA7rsRQy1O30WMiJ9cXIN X-Received: by 2002:a17:907:10cc:: with SMTP id rv12mr4606806ejb.533.1622820352390; Fri, 04 Jun 2021 08:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622820352; cv=none; d=google.com; s=arc-20160816; b=qsNTKV+AhdqD0otMqtQ+dbi5odF/E2INKK9JT3N3pkfnNADcsfXFmj+6CZefWQv/LG effgjucKPL2MMY2coYmxMBfjP5PdrSvI2znmSWxNU19w/1KWAux8IBPiBuge/U23/UOk 3CkAiOaqDw2oxi2J1sK9Hk/7rjYxHVhW0pKj1Pyp/eR1xA83TBz5ObzWMzdvRhxiCL0J 9sLvvMM02543I38OYhuDefgaClaaXDYkjXgYXvlV2BM8qsExu6aLBMf7x2dojkVaiTvr t4o0Dqbup3olrkLHppbQhel6OmWW5Q099nW/ACph3tNT3VPbPByPBP4FS785awXAARKV kL8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:cc:to :dkim-signature; bh=mdtQ42ZqV6kSWyMlaYCk3ZTM4zdnZjaKRpszophbqHY=; b=GYlz3MY+teSR2IW5+TXDOq06bLGIIOpI/qGXUOsZiIVzUsdQAYx2N5yJYRJa/mWLzU /Ry8HM49pD8BdOdCCVkREzGRDFgKOyKGo3VXgavq3C44EjNhDq2Xt3dFKHLqaU0Y5jI8 gAROkJB9mdcIrrsEcRQGiVbYrqS5C4F52kRxvVYhw3/sDMNwHJqgfyb+3zhwGFRDKd0R aCSd8SeUVnfetDwsxWLYwmdnnOFBmMUxMXiYfN2nQfPffyhPSS4UB1IV9tGbUhlVulAu +1vIIQvcplEviRBQv974E1eMmQ4mE3OnlgxbxGMOPtrLqHCQgmrFVMEfd0dzAXduXTI1 +Ouw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nbqpnL+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hh16si5047616ejb.532.2021.06.04.08.25.28; Fri, 04 Jun 2021 08:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nbqpnL+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbhFDPZp (ORCPT + 99 others); Fri, 4 Jun 2021 11:25:45 -0400 Received: from mail-ej1-f45.google.com ([209.85.218.45]:46762 "EHLO mail-ej1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbhFDPZp (ORCPT ); Fri, 4 Jun 2021 11:25:45 -0400 Received: by mail-ej1-f45.google.com with SMTP id b9so15030727ejc.13; Fri, 04 Jun 2021 08:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=mdtQ42ZqV6kSWyMlaYCk3ZTM4zdnZjaKRpszophbqHY=; b=nbqpnL+qOxNeYmEjuRyIAbnmeLIthnPSIYxgV3boyA2+HW4S1Y22Li/wwD7PE39iEP HpAcY/60nqn4Cs+4vP+CCEZJbkJss16wa9dkP8duTEbxndEl9CT0t6bEJyjvAXb40nHJ P/Yy5bmxWU3dP0Uh1W0CsTUV6uWGJyCghsm15oPSKqrpr6L5wrBvQLaaFQKoEo0/ka/y l8/j6byl4xiCeLGb/xBFuommDPxs+bVZzVwhUyaKl4lI8G3Q3oiiGd7qrX0mcJw09teQ 8lUjIU1Nd5x4lG44gYn7FsggIkfJxPhkq6MTqTRORRtglqH9n60PRUYb8/pv/vRJsV03 STCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=mdtQ42ZqV6kSWyMlaYCk3ZTM4zdnZjaKRpszophbqHY=; b=qbvFXGdBrmKryGos7opHdQPyeILDw77hba+BOVDBOgiFr8JM2fA9LwWdkqXvWUW+C+ 1d/S6DCXy0QeP5GSFImmI9+Dk7Hs3c8KwjgMfWy6vAv35yoAedk3dZjAVpolt1P7hzl2 TeoHo+g8lrbpZx2BehiGjGw9giLulr8qrPE3g9nF/T13Hy1Iaa1+r0p3ZQQtxrAgsLYP vAK/C4Jh+miDhs7K6CO4C1Cb/5Xsh7Tleg5oUO75SdB1KNl5nwrhLXlkfUm6CZdl8VMc Lu9HjCq2BX1eoCjJ8Swn/L1d37XBZC/alreEdKqG0cpJXwFffaysLt915aieiGDhr2e9 QFPg== X-Gm-Message-State: AOAM532h3TLTpl+DvI//SkgeZ47hyNR6GIIoBO8psG4fXcbU3I+ribGb iCH5Fd3yA3mg1gt6p+sC7U32cerN/KY= X-Received: by 2002:a17:907:20da:: with SMTP id qq26mr4529274ejb.42.1622820165389; Fri, 04 Jun 2021 08:22:45 -0700 (PDT) Received: from [192.168.178.194] ([171.33.179.232]) by smtp.gmail.com with ESMTPSA id w17sm3333128edd.44.2021.06.04.08.22.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jun 2021 08:22:44 -0700 (PDT) To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org From: =?UTF-8?Q?Lauren=c8=9biu_P=c4=83ncescu?= Subject: [PATCH] ACPI: EC: Look for ECDT EC after calling acpi_load_tables() Message-ID: Date: Fri, 4 Jun 2021 17:22:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit b1c0330823fe upstream. Backport of ACPI fix for #199981 for linux-4.9.y, tested on an Asus EeePC 1005PE running Debian Buster. Some systems have had functional issues since commit 5a8361f7ecce (ACPICA: Integrate package handling with module-level code) that, among other things, changed the initial values of the acpi_gbl_group_module_level_code and acpi_gbl_parse_table_as_term_list global flags in ACPICA which implicitly caused acpi_ec_ecdt_probe() to be called before acpi_load_tables() on the vast majority of platforms. Namely, before commit 5a8361f7ecce, acpi_load_tables() was called from acpi_early_init() if acpi_gbl_parse_table_as_term_list was FALSE and acpi_gbl_group_module_level_code was TRUE, which almost always was the case as FALSE and TRUE were their initial values, respectively. The acpi_gbl_parse_table_as_term_list value would be changed to TRUE for a couple of platforms in acpi_quirks_dmi_table[], but it remained FALSE in the vast majority of cases. After commit 5a8361f7ecce, the initial values of the two flags have been reversed, so in effect acpi_load_tables() has not been called from acpi_early_init() any more. That, in turn, affects acpi_ec_ecdt_probe() which is invoked before acpi_load_tables() now and it is not possible to evaluate the _REG method for the EC address space handler installed by it. That effectively causes the EC address space to be inaccessible to AML on platforms with an ECDT matching the EC device definition in the DSDT and functional problems ensue in there. Because the default behavior before commit 5a8361f7ecce was to call acpi_ec_ecdt_probe() after acpi_load_tables(), it should be safe to do that again. Moreover, the EC address space handler installed by acpi_ec_ecdt_probe() is only needed for AML to be able to access the EC address space and the only AML that can run during acpi_load_tables() is module-level code which only is allowed to access address spaces with default handlers (memory, I/O and PCI config space). For this reason, move the acpi_ec_ecdt_probe() invocation back to acpi_bus_init(), from where it was taken away by commit d737f333b211 (ACPI: probe ECDT before loading AML tables regardless of module-level code flag), and put it after the invocation of acpi_load_tables() to restore the original code ordering from before commit 5a8361f7ecce. Fixes: 5a8361f7ecce ("ACPICA: Integrate package handling with module-level code") Link: https://bugzilla.kernel.org/show_bug.cgi?id=199981 Reported-by: step-ali Reported-by: Charles Stanhope Tested-by: Charles Stanhope Reported-by: Paulo Nascimento Reported-by: David Purton Reported-by: Adam Harvey Reported-by: Zhang Rui Tested-by: Zhang Rui Tested-by: Jean-Marc Lenoir Tested-by: Laurentiu Pancescu Signed-off-by: Laurentiu Pancescu --- drivers/acpi/bus.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 92a146861086..cc88571c2cac 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1133,17 +1133,6 @@ static int __init acpi_bus_init(void) acpi_os_initialize1(); - /* - * ACPI 2.0 requires the EC driver to be loaded and work before - * the EC device is found in the namespace (i.e. before - * acpi_load_tables() is called). - * - * This is accomplished by looking for the ECDT table, and getting - * the EC parameters out of that. - */ - status = acpi_ec_ecdt_probe(); - /* Ignore result. Not having an ECDT is not fatal. */ - if (acpi_gbl_execute_tables_as_methods || !acpi_gbl_group_module_level_code) { status = acpi_load_tables(); @@ -1154,6 +1143,18 @@ static int __init acpi_bus_init(void) } } + /* + * ACPI 2.0 requires the EC driver to be loaded and work before the EC + * device is found in the namespace. + * + * This is accomplished by looking for the ECDT table and getting the EC + * parameters out of that. + * + * Do that before calling acpi_initialize_objects() which may trigger EC + * address space accesses. + */ + acpi_ec_ecdt_probe(); + status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE); if (ACPI_FAILURE(status)) { printk(KERN_ERR PREFIX -- 2.20.1