From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757934AbcKCOuv (ORCPT ); Thu, 3 Nov 2016 10:50:51 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35431 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757868AbcKCOus (ORCPT ); Thu, 3 Nov 2016 10:50:48 -0400 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: rt@linutronix.de, Sebastian Andrzej Siewior , Greg Kroah-Hartman , Thomas Gleixner Subject: [PATCH 12/25] drivers base/cacheinfo: Convert to hotplug state machine Date: Thu, 3 Nov 2016 15:50:08 +0100 Message-Id: <20161103145021.28528-13-bigeasy@linutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161103145021.28528-1-bigeasy@linutronix.de> References: <20161103145021.28528-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. No functional change. Cc: Greg Kroah-Hartman Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner --- drivers/base/cacheinfo.c | 57 +++++++++++++-------------------------------= ---- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index e9fd32e91668..47983a2ba621 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -498,57 +498,30 @@ static int cache_add_dev(unsigned int cpu) return rc; } =20 -static void cache_remove_dev(unsigned int cpu) +static int cacheinfo_cpu_online(unsigned int cpu) { - if (!cpumask_test_cpu(cpu, &cache_dev_map)) - return; - cpumask_clear_cpu(cpu, &cache_dev_map); + int rc =3D detect_cache_attributes(cpu); =20 - cpu_cache_sysfs_exit(cpu); + if (rc) + return rc; + rc =3D cache_add_dev(cpu); + if (rc) + free_cache_attributes(cpu); + return rc; } =20 -static int cacheinfo_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int cacheinfo_cpu_pre_down(unsigned int cpu) { - unsigned int cpu =3D (unsigned long)hcpu; - int rc =3D 0; + if (cpumask_test_and_clear_cpu(cpu, &cache_dev_map)) + cpu_cache_sysfs_exit(cpu); =20 - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_ONLINE: - rc =3D detect_cache_attributes(cpu); - if (!rc) - rc =3D cache_add_dev(cpu); - break; - case CPU_DEAD: - cache_remove_dev(cpu); - free_cache_attributes(cpu); - break; - } - return notifier_from_errno(rc); + free_cache_attributes(cpu); + return 0; } =20 static int __init cacheinfo_sysfs_init(void) { - int cpu, rc =3D 0; - - cpu_notifier_register_begin(); - - for_each_online_cpu(cpu) { - rc =3D detect_cache_attributes(cpu); - if (rc) - goto out; - rc =3D cache_add_dev(cpu); - if (rc) { - free_cache_attributes(cpu); - pr_err("error populating cacheinfo..cpu%d\n", cpu); - goto out; - } - } - __hotcpu_notifier(cacheinfo_cpu_callback, 0); - -out: - cpu_notifier_register_done(); - return rc; + return cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "base/cacheinfo:online", + cacheinfo_cpu_online, cacheinfo_cpu_pre_down); } - device_initcall(cacheinfo_sysfs_init); --=20 2.10.2