Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp637885lqb; Wed, 29 May 2024 06:35:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXEnC9VMNEcFNiwcWdy5KEgLusoCDX8YzbiM7WplXsP0QPnmZr6TrrIAa0hOnvyzKf4eTz4/IEsSrF58vQSNwcHsY8kLqw0hD9C9OOkw== X-Google-Smtp-Source: AGHT+IHQvavb3ZKckbDjNsl9i3SFBLKHxnH2dlJCT9edAJ2pX/va7Xp81D/R0XcEYYZ5XRAiFKWl X-Received: by 2002:a05:6a00:2917:b0:6f0:be31:8577 with SMTP id d2e1a72fcca58-6f8f3d6906emr16010329b3a.22.1716989750055; Wed, 29 May 2024 06:35:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716989750; cv=pass; d=google.com; s=arc-20160816; b=gVNuvSn40vkaTwTNhzO7aOKNIjSqKYgiqX1RE9Xxa08HmZqwBU3nyEkoVM34APxOks OO659bUQbCwh02vGwjtRo9MeYI/slmwWxDBHQW9V3YPtb6MsQCDgsvArF45ViVM+dXCf WNvT7mmdaXvjZ6QHVBYAQhLf0LQGb2rkzvr++6pV3r9oirmhFJSDFYB3kKmetcdbNF9o IIJ4tg50XslzEuogOrORIpAKw+1h6e995KHkpb5EHIkBdw1TaNqYLiujk+Dxky2Oyoyc vQMe7hcXOT9kl0bspYH8ywPG+i4dphlMFxAn0XP6atFbTRIvJsy6s7CBlD7bAr0TOgQA 8WJA== 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=Eyoi1oH0DGODK4D21YfVpd85t39bphIsH8UPYBzAsvU=; fh=NxmCHexitX7P6x/7ARv3vZBmyAUGQGWkF2RSnxwWsIo=; b=stbWokxZxlMD8JJWUm0ANF3BlHlZOlatInI857oifQpoF6BokSHtA+IXkpuKaEeu+L T45SNCrMVDJRzUHo7dYIIWbvt93HucR3RPyk1lRYSksjXYWpnATmcJFg3r4SNiePyW31 CYr0pWl8RT1DGpte3hLxXSbxnyZrruBK24Op+KDopmzrpeRu4PU3O4FlWO9Rj5isBM90 8vv7Z+imeRxC92FQ+Ac4thv+4c0N92CKWJ4LX8k9YSel+CWsuK9NMVKypeLs5S+tpBhq /oxETL/p5YLrbFbES5Llrab3EX2Js7Xtz4zivrvf73S0i//RJRr+8jP2i96aXS7dh7bU Fxqw==; 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-194163-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194163-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-68222db0c99si10485509a12.227.2024.05.29.06.35.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 06:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194163-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-194163-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194163-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1B692B23BF5 for ; Wed, 29 May 2024 13:35:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2126817591; Wed, 29 May 2024 13:35:23 +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 13EF114285; Wed, 29 May 2024 13:35:19 +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=1716989722; cv=none; b=JaPP/AUwhvw8tX1j45WWDEMC4EQsWNPp+2kIHbJOni5rJMGWP1r5dxFndI6EOroDMW/Y8YboUnUJR6LHttkN3jMAjGfoyQsHjqGt9kIirk0IkqTLlFAQtn88YMKFDDbcdj7RGUqeecnQpHW/KpQ3WPFSkk4aZBJwTvbfDywqxlo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716989722; c=relaxed/simple; bh=dPnwCsSoAPRF5Yo9GA/tedtgzsrrohoLJ+H3YwSuhPE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VqdVqoJul072hKZWS5tei6Gw/3SXJdip+ycdM2py3knrWgJZplqudrXhwBdiqhJqAR54uFRNXH6aK0dNjcY4qmqeiWk4HdxOx/xZCwx3ybJixMQqZge5mz3aOh442cV80Dh/K4qJp5xokFRu/fnwvcGnfaeSxiu/E94e8uECAu8= 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 4Vq9JQ6HTWz6JBGg; Wed, 29 May 2024 21:31:18 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 0421A140C98; Wed, 29 May 2024 21:35:18 +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.39; Wed, 29 May 2024 14:35:17 +0100 From: Jonathan Cameron To: Marc Zyngier , Will Deacon , Catalin Marinas , , , , , CC: Mark Rutland , Thomas Gleixner , Peter Zijlstra , , , Russell King , "Rafael J . Wysocki" , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Hanjun Guo , Gavin Shan , Ingo Molnar , Borislav Petkov , Dave Hansen , , , Subject: [PATCH v10 01/19] ACPI: processor: Simplify initial onlining to use same path for cold and hotplug Date: Wed, 29 May 2024 14:34:28 +0100 Message-ID: <20240529133446.28446-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240529133446.28446-1-Jonathan.Cameron@huawei.com> References: <20240529133446.28446-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: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) Separate code paths, combined with a flag set in acpi_processor.c to indicate a struct acpi_processor was for a hotplugged CPU ensured that per CPU data was only set up the first time that a CPU was initialized. This appears to be unnecessary as the paths can be combined by letting the online logic also handle any CPUs online at the time of driver load. Motivation for this change, beyond simplification, is that ARM64 virtual CPU HP uses the same code paths for hotplug and cold path in acpi_processor.c so had no easy way to set the flag for hotplug only. Removing this necessity will enable ARM64 vCPU HP to reuse the existing code paths. Acked-by: Rafael J. Wysocki Reviewed-by: Hanjun Guo Tested-by: Miguel Luis Reviewed-by: Gavin Shan Reviewed-by: Miguel Luis Signed-off-by: Jonathan Cameron --- drivers/acpi/acpi_processor.c | 7 +++--- drivers/acpi/processor_driver.c | 43 +++++++++------------------------ include/acpi/processor.h | 2 +- 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 7a0dd35d62c9..b2f0b6c19482 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -211,12 +211,11 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) } /* - * CPU got hot-added, but cpu_data is not initialized yet. Set a flag - * to delay cpu_idle/throttling initialization and do it when the CPU - * gets online for the first time. + * CPU got hot-added, but cpu_data is not initialized yet. Do + * cpu_idle/throttling initialization when the CPU gets online for + * the first time. */ pr_info("CPU%d has been hot-added\n", pr->id); - pr->flags.need_hotplug_init = 1; out: cpus_write_unlock(); diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 67db60eda370..cb52dd000b95 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -33,7 +33,6 @@ MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_DESCRIPTION("ACPI Processor Driver"); MODULE_LICENSE("GPL"); -static int acpi_processor_start(struct device *dev); static int acpi_processor_stop(struct device *dev); static const struct acpi_device_id processor_device_ids[] = { @@ -47,7 +46,6 @@ static struct device_driver acpi_processor_driver = { .name = "processor", .bus = &cpu_subsys, .acpi_match_table = processor_device_ids, - .probe = acpi_processor_start, .remove = acpi_processor_stop, }; @@ -115,12 +113,9 @@ static int acpi_soft_cpu_online(unsigned int cpu) * CPU got physically hotplugged and onlined for the first time: * Initialize missing things. */ - if (pr->flags.need_hotplug_init) { + if (!pr->flags.previously_online) { int ret; - pr_info("Will online and init hotplugged CPU: %d\n", - pr->id); - pr->flags.need_hotplug_init = 0; ret = __acpi_processor_start(device); WARN(ret, "Failed to start CPU: %d\n", pr->id); } else { @@ -167,9 +162,6 @@ static int __acpi_processor_start(struct acpi_device *device) if (!pr) return -ENODEV; - if (pr->flags.need_hotplug_init) - return 0; - result = acpi_cppc_processor_probe(pr); if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS)) dev_dbg(&device->dev, "CPPC data invalid or not present\n"); @@ -185,32 +177,21 @@ static int __acpi_processor_start(struct acpi_device *device) status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify, device); - if (ACPI_SUCCESS(status)) - return 0; + if (!ACPI_SUCCESS(status)) { + result = -ENODEV; + goto err_thermal_exit; + } + pr->flags.previously_online = 1; - result = -ENODEV; - acpi_processor_thermal_exit(pr, device); + return 0; +err_thermal_exit: + acpi_processor_thermal_exit(pr, device); err_power_exit: acpi_processor_power_exit(pr); return result; } -static int acpi_processor_start(struct device *dev) -{ - struct acpi_device *device = ACPI_COMPANION(dev); - int ret; - - if (!device) - return -ENODEV; - - /* Protect against concurrent CPU hotplug operations */ - cpu_hotplug_disable(); - ret = __acpi_processor_start(device); - cpu_hotplug_enable(); - return ret; -} - static int acpi_processor_stop(struct device *dev) { struct acpi_device *device = ACPI_COMPANION(dev); @@ -279,9 +260,9 @@ static int __init acpi_processor_driver_init(void) if (result < 0) return result; - result = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, - "acpi/cpu-drv:online", - acpi_soft_cpu_online, NULL); + result = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, + "acpi/cpu-drv:online", + acpi_soft_cpu_online, NULL); if (result < 0) goto err; hp_online = result; diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 3f34ebb27525..e6f6074eadbf 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -217,7 +217,7 @@ struct acpi_processor_flags { u8 has_lpi:1; u8 power_setup_done:1; u8 bm_rld_set:1; - u8 need_hotplug_init:1; + u8 previously_online:1; }; struct acpi_processor { -- 2.39.2