Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp425126pxa; Fri, 21 Aug 2020 10:44:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJbTrmtxzrhrQ7ckXAMCDKqkFaA87tNcKn4PTpCsgKVHQxRwDzi73QXQudufbTD5wcRM73 X-Received: by 2002:a17:906:34c7:: with SMTP id h7mr533617ejb.50.1598031867670; Fri, 21 Aug 2020 10:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598031867; cv=none; d=google.com; s=arc-20160816; b=VG2kkamQ38fsRH3S11nDVWImM5B7izqqdZiL7X6W/kkdswWkYjhc8Jf3YtnA7itSL9 WB7xL7QD/c6fIIZdXj5Q6B+K6dOl8tyB0J4DdtZwslQpPF/IqErVeRUI+i2y8fjhvA0q IM6x4F8KtoaYCEfRkNHrJn7TDWCd3DO8BmPkoo3MxN5O4FvGbU7N2mPhUwuVmz9fQhLa FwdamhUke8lAV9BVsl/NI2+H42ScTGv3yiFOyZOE8K7O4Bs6A6x4NvA4K2sWz9CZnvg+ MW2L2Uge0CWZP0sWrww93dDks8K/VYblCm5420xzOO61UzWRkUHZdIZIj92QhCs2nCzK sasQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vhres10VJT9B7cEPqV/RioclznxMH+tE5dKaCfNGfxw=; b=kZhlhHgVFRN9wl3+eDpWgKTKrcPNbIoWvPNSQim7dEXQLnwgu37Buj1bwNDtJKCo6D 31fNtCnrF3TuT1HExFVKW3m49KgZqSSdSi5DVfKwvFclBgxxneKRvsS35VpS/0RSAG15 9HDvSwawx5gTlba3YIKEFVWrIEn+bSGDyGdXQVuEQJVxfuu8JILVwvLGSg6Z9WW6Srrn UdC/UGlx29i8mipHCWlaNTtaohM+1OV0r7VIDmwRAfIBXja6L6jaRUOcDXpw7gtif2kF GpKdb2NP1rBx7cM6iNznwiohMFZAaCYf5GNC+9Yq1CxtVIpif8HT2N7aXGo4fRr5EiJb 4Gyg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si1550553edx.39.2020.08.21.10.44.04; Fri, 21 Aug 2020 10:44:27 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbgHURnD (ORCPT + 99 others); Fri, 21 Aug 2020 13:43:03 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:48108 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726870AbgHURm7 (ORCPT ); Fri, 21 Aug 2020 13:42:59 -0400 Received: from 89-64-88-37.dynamic.chello.pl (89.64.88.37) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.459) id ca2fab7cdb976c2f; Fri, 21 Aug 2020 19:42:56 +0200 From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Mika Westerberg , "Krogerus, Heikki" , "Kenneth R. Crudup" Subject: [PATCH] ACPI: OSL: Prevent acpi_release_memory() from returning too early Date: Fri, 21 Aug 2020 19:42:55 +0200 Message-ID: <6142241.0H6QnnlUA7@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki After commit 1757659d022b ("ACPI: OSL: Implement deferred unmapping of ACPI memory") in some cases acpi_release_memory() may return before the target memory mappings actually go away, because they are released asynchronously now. Prevent it from returning prematurely by making it wait for the next RCU grace period to elapse, for all of the RCU callbacks to complete and for all of the scheduled work items to be flushed before returning. Fixes: 1757659d022b ("ACPI: OSL: Implement deferred unmapping of ACPI memory") Reported-by: Kenneth R. Crudup Signed-off-by: Rafael J. Wysocki --- drivers/acpi/osl.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) Index: linux-pm/drivers/acpi/osl.c =================================================================== --- linux-pm.orig/drivers/acpi/osl.c +++ linux-pm/drivers/acpi/osl.c @@ -1575,11 +1575,26 @@ static acpi_status acpi_deactivate_mem_r acpi_status acpi_release_memory(acpi_handle handle, struct resource *res, u32 level) { + acpi_status status; + if (!(res->flags & IORESOURCE_MEM)) return AE_TYPE; - return acpi_walk_namespace(ACPI_TYPE_REGION, handle, level, - acpi_deactivate_mem_region, NULL, res, NULL); + status = acpi_walk_namespace(ACPI_TYPE_REGION, handle, level, + acpi_deactivate_mem_region, NULL, + res, NULL); + if (ACPI_FAILURE(status)) + return status; + + /* + * Wait for all of the mappings queued up for removal by + * acpi_deactivate_mem_region() to actually go away. + */ + synchronize_rcu(); + rcu_barrier(); + flush_scheduled_work(); + + return AE_OK; } EXPORT_SYMBOL_GPL(acpi_release_memory);