Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp192895lql; Fri, 12 Apr 2024 07:42:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWH+Y8Q+skB8V4FhBbeqBo64bCY51P2ThUqoilSglnKuOKh8r/S2sXVwMFEPTSX4bF7YapVxyKFBqJKCne6CK31Ez6wZn/vmJwG0X8NA== X-Google-Smtp-Source: AGHT+IGvjpblFzRP4SvkL3+kwQ/HdMAMLBe519q85QwdVxq2sPlgz7Vje3m2rd9i0NGnbYjAlQBj X-Received: by 2002:a17:906:2bce:b0:a52:3ca9:9bda with SMTP id n14-20020a1709062bce00b00a523ca99bdamr1171989ejg.22.1712932974182; Fri, 12 Apr 2024 07:42:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712932974; cv=pass; d=google.com; s=arc-20160816; b=p8HAYLxfH8ylPy4F+dYnHqFyNsSbGux9FomqwzlZ4803mjdbYEBlVlu7EXHljnP1jz Tf9w1QkAY6OFR2t1bo18T+FsXrWo0wzd5vOalGPBUljvf762gynZ3Q6qcigZe7xCCJFX KvKwxjTt6kDWKrdSP+mFFx21Tbv7pzaq3g7IvJgqc9bk9k9f4z+rgIbuAoKR8T17cv+h qRwMptXu4ukUU+qggcaRLdlDPvb1k3k0XX7LeCEjgR6Ir1hXRAko6tev416R1gJ2VB4U i8aU8Ze5YDtFGwC4hP766HZRz05OpDbfUn5+QkHymw6YZqhvpGSyi7Kfnt9t9FbfW3wr jCAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=kAqMIlcpZMz6FTRHenJ2M/vgj8emyxXh4LbgZ9CvG4M=; fh=8XQHdFtte3XOHSEIytMgmfctfSZlTmw2q6RqB5HTTCI=; b=T1BBSOszyus5UESBnoe3FfWIN8T3gA6N2VPrFAiNBMmmrNiu5uJCh5bQRjY5Kk+UxO r5KoWUFb12RUMb9TGpDCaIGcBp2lM5xlQNX/t/VevAK8Jthyi5nOwrUP0nTjBmP09mYu 2CeKJiXQgRnwSOw9dyqEDxqVXshvEn2RqkSfu3DQemHTIMm85hK8lrqcZp9m6odC+QZW U2g2Yl5jgQ3osjf7+cJ8+Yek/ZRJydD56cFMVUimcLmkrnUgTxNskYlewap6TGq4B2De +KOjeaGUzWsZ19lgXuBzdcSZWV6sC+vUt7E3fvGBuCSoVa+3mymbSnbub+O7Etq1jPnK 692w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-142861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ci15-20020a170906c34f00b00a52223e2d4bsi1649267ejb.550.2024.04.12.07.42.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 07:42:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-142861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D76311F25105 for ; Fri, 12 Apr 2024 14:42:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 545D6142E8E; Fri, 12 Apr 2024 14:41:57 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47E9212BF36; Fri, 12 Apr 2024 14:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712932916; cv=none; b=EcE1h00ITV0fLP+guU/DwfdbkyjKr99h94qTv8e5K6r71nqOTkm7I7vEhVR/cJjWCIo8z9+daPXTbr84q75c4xo73jRb70Dv6qiyXpU7Wz2EyX9HuYeeYbxKUQipJJ99uKRm92cKmmYhbiOp8VuXoy+DqgHZCLGHIL8BM7cUXTo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712932916; c=relaxed/simple; bh=UZlhSbbgxvmCDpuKqnBh552fwklRGUKBiILYhkwfa80=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W8BchQsjafNo7V1cg9Wbcg232MgY5Yu93Q3i8kOBs2WHKQPA3iI1hkY6kKVM49wGi+20JjTgGQr7OWS0izOLIwpRXu7BmLctttiVUoe0lgG8/11FnV69O1ZwL+CLLF4cl5GO+18uhunDHiYeZegliibmM2xWLTflfuyutvsQ/1Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4VGK3W4VpYz6J9bP; Fri, 12 Apr 2024 22:40:07 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 624C81402CD; Fri, 12 Apr 2024 22:41:53 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 12 Apr 2024 15:41:52 +0100 From: Jonathan Cameron To: , , , , , , , , Russell King , "Rafael J . Wysocki" , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Catalin Marinas , Will Deacon CC: , , Subject: [PATCH v5 09/18] ACPI: Check _STA present bit before making CPUs not present Date: Fri, 12 Apr 2024 15:37:10 +0100 Message-ID: <20240412143719.11398-10-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412143719.11398-1-Jonathan.Cameron@huawei.com> References: <20240412143719.11398-1-Jonathan.Cameron@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: lhrpeml500006.china.huawei.com (7.191.161.198) To lhrpeml500005.china.huawei.com (7.191.163.240) From: James Morse When called acpi_processor_post_eject() unconditionally make a CPU not-present and unregisters it. To add support for AML events where the CPU has become disabled, but remains present, the _STA method should be checked before calling acpi_processor_remove(). Rename acpi_processor_post_eject() acpi_processor_remove_possible(), and check the _STA before calling. Adding the function prototype for arch_unregister_cpu() allows the preprocessor guards to be removed. After this change CPUs will remain registered and visible to user-space as offline if buggy firmware triggers an eject-request, but doesn't clear the corresponding _STA bits after _EJ0 has been called. Signed-off-by: James Morse Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) Signed-off-by: Jonathan Cameron --- v5: No change --- drivers/acpi/acpi_processor.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 15d89f80857b..0403eddb3f80 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -462,16 +462,13 @@ static int acpi_processor_add(struct acpi_device *device, } /* Removal */ -static void acpi_processor_post_eject(struct acpi_device *device) +static void acpi_processor_make_not_present(struct acpi_device *device) { struct acpi_processor *pr; if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_CPU)) return; - if (!device || !acpi_driver_data(device)) - return; - pr = acpi_driver_data(device); if (pr->id >= nr_cpu_ids) goto out; @@ -508,6 +505,29 @@ static void acpi_processor_post_eject(struct acpi_device *device) kfree(pr); } +static void acpi_processor_post_eject(struct acpi_device *device) +{ + struct acpi_processor *pr; + unsigned long long sta; + acpi_status status; + + if (!device) + return; + + pr = acpi_driver_data(device); + if (!pr || pr->id >= nr_cpu_ids || invalid_phys_cpuid(pr->phys_id)) + return; + + status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return; + + if (cpu_present(pr->id) && !(sta & ACPI_STA_DEVICE_PRESENT)) { + acpi_processor_make_not_present(device); + return; + } +} + #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC bool __init processor_physically_present(acpi_handle handle) { -- 2.39.2