Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3952686rdb; Thu, 14 Sep 2023 07:40:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEA9NIGb0F1Na8g+NlGEyAHyDAccvL8jf2e7gqfZQv5ze5mFIsN57rJxUsV6iHhz9sfhkT1 X-Received: by 2002:a05:6a20:2454:b0:13c:ca8b:7e29 with SMTP id t20-20020a056a20245400b0013cca8b7e29mr5938759pzc.12.1694702401486; Thu, 14 Sep 2023 07:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694702401; cv=none; d=google.com; s=arc-20160816; b=EUl61I2THYIpNNO4FO6mOST5MlNlh6LzUM79SG1iDf0WLKTpb/QfP1lisaIRIMVlZP o6XQbzWkAI6aTZscmKOIdV08qh/JKkPn46xPoT6nqre9ohcfhO/XGlPXGPriRDjzxOFJ cbrRBW+m/VcURay8yjtnA9lUdBY6qWSIISR8cQS/xEu/UvyrDRENlIOWVMGimaBEPucH 5SWs+5YDzzg8avc6VoqCwj6DNfuKDuGD/6E1RqM1lNOS9W/JWiemFKGWwu9F7QamqUbO ajMc+RG+5paDa6YAoffFuOrLcLXJcSCzs1qmAWbtB2V29wiXrbWzdGEjWoiM+96oV7XU CT3Q== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=XOYdj4YRjVROV9rxaGn4LdQKqfomZoi2tP/SLESDcNo=; fh=oO43h3w0Gnh1/uzgjBLTRg+oe1Gv6aFHPIod5z8aS5s=; b=O0RRO4Y5LpHWBdGtjcVO/80rl8HpoUfQkJADFhGXwCGEzjbUOwZ0Z2nWxx4b0c+hx1 4kA/kq/WBHKD1j7Gjx1VHvFMaiS2TALEvfPGs6rPV8t8kcrcWNN1Zl3grbFDoj5iZn4d HP2FEyEvkp8l3fOWROT6xkqLG4JtOVNZZX1eeFSHcDrHUHuQcCzH8xnSSden0igKkl3B Xs1tQoKnDsRyzQeHAyxYRsZGAuO3DQ0cbEsHGZgQMfYLWLsCHRItiguKvHiK1yC7192L 0K8ud0JONYckAqTxLzxE+8sORgoR3XupqSkIA76lXPZg+xrUHxbhwGSudC8GIchOGCY5 OnWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e126-20020a636984000000b0056b4065299esi1723715pgc.621.2023.09.14.07.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 07:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2263380EFC73; Thu, 14 Sep 2023 07:31:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234071AbjINObV (ORCPT + 99 others); Thu, 14 Sep 2023 10:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240182AbjINObT (ORCPT ); Thu, 14 Sep 2023 10:31:19 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A5501A5; Thu, 14 Sep 2023 07:31:15 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Rmfqw1fxwz6FGNN; Thu, 14 Sep 2023 22:30:36 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 14 Sep 2023 15:31:11 +0100 Date: Thu, 14 Sep 2023 15:31:10 +0100 From: Jonathan Cameron To: James Morse CC: , , , , , , , , , Salil Mehta , Russell King , Jean-Philippe Brucker , , Subject: Re: [RFC PATCH v2 22/35] ACPI: Check _STA present bit before making CPUs not present Message-ID: <20230914153110.00003e38@Huawei.com> In-Reply-To: <20230913163823.7880-23-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> <20230913163823.7880-23-james.morse@arm.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 07:31:26 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email On Wed, 13 Sep 2023 16:38:10 +0000 James Morse wrote: > 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. Will be fun to see how many such buggy firmwares are out there. > > Signed-off-by: James Morse Comment inline but not directly related to this patch so with or without that change Reviewed-by: Jonathan Cameron > --- > drivers/acpi/acpi_processor.c | 31 +++++++++++++++++++++++++------ > include/linux/cpu.h | 1 + > 2 files changed, 26 insertions(+), 6 deletions(-) > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > index 00dcc23d49a8..2cafea1edc24 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -457,13 +457,12 @@ static int acpi_processor_add(struct acpi_device *device, > return result; > } > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > /* 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 (!device || !acpi_driver_data(device)) > + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) Would it be possible to do all the ifdef to IS_ENABLED changes in a separate patch? I haven't figure out if any of them have dependencies on the other changes, but they do create a bunch of noise I'd rather not see in the more complex corners of this. > return; > > pr = acpi_driver_data(device); > @@ -501,7 +500,29 @@ static void acpi_processor_post_eject(struct acpi_device *device) > free_cpumask_var(pr->throttling.shared_cpu_map); > kfree(pr); > } > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > + > +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) > @@ -626,9 +647,7 @@ static const struct acpi_device_id processor_device_ids[] = { > static struct acpi_scan_handler processor_handler = { > .ids = processor_device_ids, > .attach = acpi_processor_add, > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > .post_eject = acpi_processor_post_eject, > -#endif > .hotplug = { > .enabled = true, > }, > diff --git a/include/linux/cpu.h b/include/linux/cpu.h > index a71691d7c2ca..e117c06e0c6b 100644 > --- a/include/linux/cpu.h > +++ b/include/linux/cpu.h > @@ -81,6 +81,7 @@ struct device *cpu_device_create(struct device *parent, void *drvdata, > const struct attribute_group **groups, > const char *fmt, ...); > extern int arch_register_cpu(int cpu); > +extern void arch_unregister_cpu(int cpu); > #ifdef CONFIG_HOTPLUG_CPU > extern void unregister_cpu(struct cpu *cpu); > extern ssize_t arch_cpu_probe(const char *, size_t);