All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Sebastian Andrzej Siewior <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, james.hogan@imgtec.com,
	ralf@linux-mips.org, bigeasy@linutronix.de, peterz@infradead.org,
	tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com
Subject: [tip:smp/hotplug] MIPS/BUS/CDMM: Convert to hotplug state machine
Date: Tue, 6 Sep 2016 09:42:46 -0700	[thread overview]
Message-ID: <tip-e8483b578b229774382a95891439b2ebd9c92fc5@git.kernel.org> (raw)
In-Reply-To: <20160818125731.27256-14-bigeasy@linutronix.de>

Commit-ID:  e8483b578b229774382a95891439b2ebd9c92fc5
Gitweb:     http://git.kernel.org/tip/e8483b578b229774382a95891439b2ebd9c92fc5
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Thu, 18 Aug 2016 14:57:28 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 6 Sep 2016 18:30:25 +0200

MIPS/BUS/CDMM: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160818125731.27256-14-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/bus/mips_cdmm.c | 70 +++++++++----------------------------------------
 1 file changed, 12 insertions(+), 58 deletions(-)

diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
index cad49bc..1b14256 100644
--- a/drivers/bus/mips_cdmm.c
+++ b/drivers/bus/mips_cdmm.c
@@ -596,19 +596,20 @@ BUILD_PERDEV_HELPER(cpu_down)       /* int mips_cdmm_cpu_down_helper(...) */
 BUILD_PERDEV_HELPER(cpu_up)         /* int mips_cdmm_cpu_up_helper(...) */
 
 /**
- * mips_cdmm_bus_down() - Tear down the CDMM bus.
- * @data:	Pointer to unsigned int CPU number.
+ * mips_cdmm_cpu_down_prep() - Callback for CPUHP DOWN_PREP:
+ *			       Tear down the CDMM bus.
+ * @cpu:	unsigned int CPU number.
  *
  * This function is executed on the hotplugged CPU and calls the CDMM
  * driver cpu_down callback for all devices on that CPU.
  */
-static long mips_cdmm_bus_down(void *data)
+static int mips_cdmm_cpu_down_prep(unsigned int cpu)
 {
 	struct mips_cdmm_bus *bus;
 	long ret;
 
 	/* Inform all the devices on the bus */
-	ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, data,
+	ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, &cpu,
 			       mips_cdmm_cpu_down_helper);
 
 	/*
@@ -623,8 +624,8 @@ static long mips_cdmm_bus_down(void *data)
 }
 
 /**
- * mips_cdmm_bus_up() - Bring up the CDMM bus.
- * @data:	Pointer to unsigned int CPU number.
+ * mips_cdmm_cpu_online() - Callback for CPUHP ONLINE: Bring up the CDMM bus.
+ * @cpu:	unsigned int CPU number.
  *
  * This work_on_cpu callback function is executed on a given CPU to discover
  * CDMM devices on that CPU, or to call the CDMM driver cpu_up callback for all
@@ -634,7 +635,7 @@ static long mips_cdmm_bus_down(void *data)
  * initialisation. When CPUs are brought online the function is
  * invoked directly on the hotplugged CPU.
  */
-static long mips_cdmm_bus_up(void *data)
+static int mips_cdmm_cpu_online(unsigned int cpu)
 {
 	struct mips_cdmm_bus *bus;
 	long ret;
@@ -651,51 +652,13 @@ static long mips_cdmm_bus_up(void *data)
 		mips_cdmm_bus_discover(bus);
 	else
 		/* Inform all the devices on the bus */
-		ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, data,
+		ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, &cpu,
 				       mips_cdmm_cpu_up_helper);
 
 	return ret;
 }
 
 /**
- * mips_cdmm_cpu_notify() - Take action when a CPU is going online or offline.
- * @nb:		CPU notifier block .
- * @action:	Event that has taken place (CPU_*).
- * @data:	CPU number.
- *
- * This notifier is used to keep the CDMM buses updated as CPUs are offlined and
- * onlined. When CPUs go offline or come back online, so does their CDMM bus, so
- * devices must be informed. Also when CPUs come online for the first time the
- * devices on the CDMM bus need discovering.
- *
- * Returns:	NOTIFY_OK if event was used.
- *		NOTIFY_DONE if we didn't care.
- */
-static int mips_cdmm_cpu_notify(struct notifier_block *nb,
-				unsigned long action, void *data)
-{
-	unsigned int cpu = (unsigned int)data;
-
-	switch (action & ~CPU_TASKS_FROZEN) {
-	case CPU_ONLINE:
-	case CPU_DOWN_FAILED:
-		mips_cdmm_bus_up(&cpu);
-		break;
-	case CPU_DOWN_PREPARE:
-		mips_cdmm_bus_down(&cpu);
-		break;
-	default:
-		return NOTIFY_DONE;
-	}
-
-	return NOTIFY_OK;
-}
-
-static struct notifier_block mips_cdmm_cpu_nb = {
-	.notifier_call = mips_cdmm_cpu_notify,
-};
-
-/**
  * mips_cdmm_init() - Initialise CDMM bus.
  *
  * Initialise CDMM bus, discover CDMM devices for online CPUs, and arrange for
@@ -703,7 +666,6 @@ static struct notifier_block mips_cdmm_cpu_nb = {
  */
 static int __init mips_cdmm_init(void)
 {
-	unsigned int cpu;
 	int ret;
 
 	/* Register the bus */
@@ -712,19 +674,11 @@ static int __init mips_cdmm_init(void)
 		return ret;
 
 	/* We want to be notified about new CPUs */
-	ret = register_cpu_notifier(&mips_cdmm_cpu_nb);
-	if (ret) {
+	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "bus/cdmm:online",
+				mips_cdmm_cpu_online, mips_cdmm_cpu_down_prep);
+	if (ret < 0)
 		pr_warn("cdmm: Failed to register CPU notifier\n");
-		goto out;
-	}
-
-	/* Discover devices on CDMM of online CPUs */
-	for_each_online_cpu(cpu)
-		work_on_cpu(cpu, mips_cdmm_bus_up, &cpu);
 
-	return 0;
-out:
-	bus_unregister(&mips_cdmm_bustype);
 	return ret;
 }
 subsys_initcall(mips_cdmm_init);

  parent reply	other threads:[~2016-09-06 16:43 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18 12:57 cpu hotplug: convert more drivers Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 01/16] cpuhotplug: Remove CPU_STARTING and CPU_DYING notifier Sebastian Andrzej Siewior
2016-09-06 15:19   ` [tip:smp/hotplug] cpu/hotplug: " tip-bot for Thomas Gleixner
2016-09-06 16:37   ` tip-bot for Thomas Gleixner
2016-08-18 12:57 ` [PATCH 02/16] relayfs: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-09-06 15:20   ` [tip:smp/hotplug] " tip-bot for Richard Weinberger
2016-09-06 16:38   ` tip-bot for Richard Weinberger
2016-08-18 12:57 ` [PATCH 03/16] slab: " Sebastian Andrzej Siewior
2016-08-18 12:57   ` Sebastian Andrzej Siewior
2016-08-18 17:08   ` Sebastian Andrzej Siewior
2016-08-18 17:08     ` Sebastian Andrzej Siewior
2016-08-23 12:53     ` [PATCH 03/16 v2] " Sebastian Andrzej Siewior
2016-08-23 12:53       ` Sebastian Andrzej Siewior
2016-09-06 15:21       ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:38       ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 04/16] slub: " Sebastian Andrzej Siewior
2016-08-18 12:57   ` Sebastian Andrzej Siewior
2016-09-06 15:21   ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:38   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 05/16] mm: writeback: " Sebastian Andrzej Siewior
2016-08-18 12:57   ` Sebastian Andrzej Siewior
2016-09-06 15:22   ` [tip:smp/hotplug] mm/writeback: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:39   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 06/16] kernel: softirq: " Sebastian Andrzej Siewior
2016-09-06 15:22   ` [tip:smp/hotplug] kernel/softirq: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:39   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 07/16] rcu: rcutorture: " Sebastian Andrzej Siewior
2016-08-18 16:20   ` Paul E. McKenney
2016-08-18 12:57 ` [PATCH 08/16] net: mvneta: " Sebastian Andrzej Siewior
2016-09-06 15:23   ` [tip:smp/hotplug] net/mvneta: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:40   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 09/16] md: raid5: " Sebastian Andrzej Siewior
2016-09-06 15:23   ` [tip:smp/hotplug] md/raid5: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:40   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 10/16] cpuidle: pseries: " Sebastian Andrzej Siewior
2016-08-22 16:09   ` Daniel Lezcano
2016-08-22 19:04     ` Sebastian Andrzej Siewior
2016-08-23 14:16       ` Daniel Lezcano
2016-08-23 16:32         ` Sebastian Andrzej Siewior
2016-08-24  9:09           ` [PATCH 10/16 v2] " Sebastian Andrzej Siewior
2016-09-06 15:24   ` [tip:smp/hotplug] cpuidle/pseries: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:41   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 11/16] cpuidle: powernv: " Sebastian Andrzej Siewior
2016-08-24  9:12   ` Sebastian Andrzej Siewior
2016-09-06 15:24     ` [tip:smp/hotplug] cpuidle/powernv: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:41     ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 12/16] cpuidle: coupled: " Sebastian Andrzej Siewior
2016-08-23 14:24   ` Daniel Lezcano
2016-08-24  9:14     ` [PATCH 12/16 v2] " Sebastian Andrzej Siewior
2016-09-06 15:25       ` [tip:smp/hotplug] cpuidle/coupled: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:42       ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 13/16] MIPS: BUS: CDMM: " Sebastian Andrzej Siewior
2016-09-06 15:25   ` [tip:smp/hotplug] MIPS/BUS/CDMM: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:42   ` tip-bot for Sebastian Andrzej Siewior [this message]
2016-08-18 12:57 ` [PATCH 14/16] x86: kvm: " Sebastian Andrzej Siewior
2016-08-18 17:06   ` Paolo Bonzini
2016-09-06 15:25   ` [tip:smp/hotplug] x86/kvm: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:43   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 15/16] powerpc: powermac: " Sebastian Andrzej Siewior
2016-09-06 15:26   ` [tip:smp/hotplug] powerpc/powermac: " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:43   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 12:57 ` [PATCH 16/16] powerpc: mmu nohash: " Sebastian Andrzej Siewior
2016-09-06 15:26   ` [tip:smp/hotplug] powerpc/mmu " tip-bot for Sebastian Andrzej Siewior
2016-09-06 16:44   ` tip-bot for Sebastian Andrzej Siewior
2016-08-18 13:40 ` cpu hotplug: convert more drivers Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-e8483b578b229774382a95891439b2ebd9c92fc5@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bigeasy@linutronix.de \
    --cc=hpa@zytor.com \
    --cc=james.hogan@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ralf@linux-mips.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.