Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2756294ybc; Mon, 25 Nov 2019 03:44:15 -0800 (PST) X-Google-Smtp-Source: APXvYqzQfjgpt0AH7rl5lLLcsDH60DYI8r/Znbu3KnogB7TOxBNutj7GoOiouMlaQRVlu7P5yCT8 X-Received: by 2002:a17:906:12d3:: with SMTP id l19mr35031463ejb.165.1574682255799; Mon, 25 Nov 2019 03:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574682255; cv=none; d=google.com; s=arc-20160816; b=uJ41wQtHYMJTNl3nomvhk038PuJEj6rMQGZUEwMPhTUbDgC7WSYqu/DXmW8Hruk+jB IFxWtNZbTeSsZa6XM9dd1NJoHT/s7oz5QJp5lY1sMuY8Kculz0XibiQ8ZYeIstB7qHoE J3uqlyG/mLvaYRp8Imc89s7hvBD/IJm72XykFJS1lQGLRA2weBBEFBrNPVW3KTPw0MAi zaIxbHkQ0KPOExV0PrdnuCJgUEEfiP26++N1fYjh2cTW5Rva8uSGK6CGHbbFzMI16wvE +AhXEiVFFwHLJQIkqvOF0NBqT9ATEkXTVXWRdRgvIkkC1Q7jF4UgGByyPUr1LtIHLzfV 2DJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Fxl0EJ8uItVssLJlkw/UwfXbkhVpRbvSicXbj6kyUpU=; b=WyX+Hv2RKPDO0S0ChZFlPBGP3Q9sa5g5odUwVD/Yex+c/xjIXDsmve5TWnmsnvvkny lUZ/4iI2Lr9XRrxvofh7ltUpr3szsKQcVvxoGxpKHqO01FmeWoD8SE5lT5qrOQ0f81i1 NHujZgMA+/u7OtSQRpP++IllIvrCt5SxW+LXl/gF9iYKMQ3IJ95WJXWe57d2HW9UZQ/W XJLmDkeVn4H2uIqlOn6igClOLazOs93a/3Cmd5Je2ZRqv64WFl/OErkiVXHD9zfsXyOT a/60LivedJVjTb/ID++M65OxIfBuBRsofVeDTOiCUvvAFG/dXcI8UHn7rbEQjZzHOlem JNIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si4256913ejf.418.2019.11.25.03.43.52; Mon, 25 Nov 2019 03:44:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbfKYL2a (ORCPT + 99 others); Mon, 25 Nov 2019 06:28:30 -0500 Received: from foss.arm.com ([217.140.110.172]:49138 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbfKYL21 (ORCPT ); Mon, 25 Nov 2019 06:28:27 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F7771045; Mon, 25 Nov 2019 03:28:26 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7E313F52E; Mon, 25 Nov 2019 03:28:24 -0800 (PST) From: Qais Yousef To: Thomas Gleixner , Greg Kroah-Hartman Cc: Qais Yousef , "Rafael J. Wysocki" , Josh Poimboeuf , Nicholas Piggin , "Peter Zijlstra (Intel)" , Jiri Kosina , Daniel Lezcano , Eiichi Tsukata , Zhenzhong Duan , Ingo Molnar , Pavankumar Kondeti , linux-kernel@vger.kernel.org Subject: [PATCH v2 14/14] cpu: Hide cpu_up/down Date: Mon, 25 Nov 2019 11:27:54 +0000 Message-Id: <20191125112754.25223-15-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191125112754.25223-1-qais.yousef@arm.com> References: <20191125112754.25223-1-qais.yousef@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a special exported function for the device core to bring a cpu up/down and hide the real cpu_up/down as they are treated as private functions. cpu_up/down are lower level API and users outside the cpu subsystem should use device_online/offline which will take care of extra housekeeping work like keeping sysfs in sync. Signed-off-by: Qais Yousef CC: Greg Kroah-Hartman CC: "Rafael J. Wysocki" CC: Thomas Gleixner CC: Josh Poimboeuf CC: Nicholas Piggin CC: "Peter Zijlstra (Intel)" CC: Jiri Kosina CC: Daniel Lezcano CC: Eiichi Tsukata CC: Zhenzhong Duan CC: Ingo Molnar CC: Pavankumar Kondeti CC: linux-kernel@vger.kernel.org --- drivers/base/cpu.c | 4 ++-- include/linux/cpu.h | 4 ++-- kernel/cpu.c | 32 ++++++++++++++++++++++++++++---- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 6265871a4af2..9a134cd362ee 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -55,7 +55,7 @@ static int cpu_subsys_online(struct device *dev) if (from_nid == NUMA_NO_NODE) return -ENODEV; - ret = cpu_up(cpuid); + ret = cpu_subsys_up(dev); /* * When hot adding memory to memoryless node and enabling a cpu * on the node, node number of the cpu may internally change. @@ -69,7 +69,7 @@ static int cpu_subsys_online(struct device *dev) static int cpu_subsys_offline(struct device *dev) { - return cpu_down(dev->id); + return cpu_subsys_down(dev); } void unregister_cpu(struct cpu *cpu) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index b5d9287899d1..bd9c5870c26f 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -88,7 +88,7 @@ extern ssize_t arch_cpu_release(const char *, size_t); #ifdef CONFIG_SMP extern bool cpuhp_tasks_frozen; -int cpu_up(unsigned int cpu); +int cpu_subsys_up(struct device *dev); void notify_cpu_starting(unsigned int cpu); extern void cpu_maps_update_begin(void); extern void cpu_maps_update_done(void); @@ -119,7 +119,7 @@ extern void lockdep_assert_cpus_held(void); extern void cpu_hotplug_disable(void); extern void cpu_hotplug_enable(void); void clear_tasks_mm_cpumask(int cpu); -int cpu_down(unsigned int cpu); +int cpu_subsys_down(struct device *dev); extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu); #else /* CONFIG_HOTPLUG_CPU */ diff --git a/kernel/cpu.c b/kernel/cpu.c index 3631184a284f..8b29e0aa95ba 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1052,11 +1052,23 @@ static int do_cpu_down(unsigned int cpu, enum cpuhp_state target) return err; } -int cpu_down(unsigned int cpu) +static int cpu_down(unsigned int cpu) { return do_cpu_down(cpu, CPUHP_OFFLINE); } -EXPORT_SYMBOL(cpu_down); + +/** + * cpu_subsys_down - Bring down a cpu device + * @dev: Pointer to the cpu device to offline + * + * This function is meant to be used by device core cpu subsystem only. + * + * Other subsystems should use device_offline(get_cpu_device(cpu)) instead. + */ +int cpu_subsys_down(struct device *dev) +{ + return cpu_down(dev->id); +} void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { @@ -1215,11 +1227,23 @@ static int do_cpu_up(unsigned int cpu, enum cpuhp_state target) return err; } -int cpu_up(unsigned int cpu) +static int cpu_up(unsigned int cpu) { return do_cpu_up(cpu, CPUHP_ONLINE); } -EXPORT_SYMBOL_GPL(cpu_up); + +/** + * cpu_subsys_up - Bring up a cpu device + * @dev: Pointer to the cpu device to online + * + * This function is meant to be used by device core cpu subsystem only. + * + * Other subsystems should use device_online(get_cpu_device(cpu)) instead. + */ +int cpu_subsys_up(struct device *dev) +{ + return cpu_up(dev->id); +} /** * bringup_hibernate_cpu - Bring up the CPU that we hibernated on -- 2.17.1