Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755125AbcKQSi4 (ORCPT ); Thu, 17 Nov 2016 13:38:56 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:49691 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754959AbcKQSgb (ORCPT ); Thu, 17 Nov 2016 13:36:31 -0500 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: rt@linuxtronix.de, Sebastian Andrzej Siewior , Will Deacon , Mark Rutland , Russell King , linux-arm-kernel@lists.infradead.org, Thomas Gleixner Subject: [PATCH 15/20] ARM/hw_breakpoint: Convert to hotplug state machine Date: Thu, 17 Nov 2016 19:35:36 +0100 Message-Id: <20161117183541.8588-16-bigeasy@linutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161117183541.8588-1-bigeasy@linutronix.de> References: <20161117183541.8588-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 Content-Length: 3724 Lines: 124 Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. smp_call_function_single() has been removed because the function is already invoked on the target CPU. Cc: Will Deacon Cc: Mark Rutland Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner --- arch/arm/kernel/hw_breakpoint.c | 44 ++++++++++++++++++-------------------= ---- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoin= t.c index b8df45883cf7..51cff5a8feff 100644 --- a/arch/arm/kernel/hw_breakpoint.c +++ b/arch/arm/kernel/hw_breakpoint.c @@ -925,9 +925,9 @@ static bool core_has_os_save_restore(void) } } =20 -static void reset_ctrl_regs(void *unused) +static void reset_ctrl_regs(unsigned int cpu) { - int i, raw_num_brps, err =3D 0, cpu =3D smp_processor_id(); + int i, raw_num_brps, err =3D 0; u32 val; =20 /* @@ -1020,25 +1020,20 @@ static void reset_ctrl_regs(void *unused) cpumask_or(&debug_err_mask, &debug_err_mask, cpumask_of(cpu)); } =20 -static int dbg_reset_notify(struct notifier_block *self, - unsigned long action, void *cpu) +static int dbg_reset_online(unsigned int cpu) { - if ((action & ~CPU_TASKS_FROZEN) =3D=3D CPU_ONLINE) - smp_call_function_single((int)cpu, reset_ctrl_regs, NULL, 1); - - return NOTIFY_OK; + local_irq_disable(); + reset_ctrl_regs(cpu); + local_irq_enable(); + return 0; } =20 -static struct notifier_block dbg_reset_nb =3D { - .notifier_call =3D dbg_reset_notify, -}; - #ifdef CONFIG_CPU_PM static int dbg_cpu_pm_notify(struct notifier_block *self, unsigned long ac= tion, void *v) { if (action =3D=3D CPU_PM_EXIT) - reset_ctrl_regs(NULL); + reset_ctrl_regs(smp_processor_id()); =20 return NOTIFY_OK; } @@ -1059,6 +1054,8 @@ static inline void pm_init(void) =20 static int __init arch_hw_breakpoint_init(void) { + int ret; + debug_arch =3D get_debug_arch(); =20 if (!debug_arch_supported()) { @@ -1072,8 +1069,6 @@ static int __init arch_hw_breakpoint_init(void) core_num_brps =3D get_num_brps(); core_num_wrps =3D get_num_wrps(); =20 - cpu_notifier_register_begin(); - /* * We need to tread carefully here because DBGSWENABLE may be * driven low on this core and there isn't an architected way to @@ -1082,15 +1077,18 @@ static int __init arch_hw_breakpoint_init(void) register_undef_hook(&debug_reg_hook); =20 /* - * Reset the breakpoint resources. We assume that a halting - * debugger will leave the world in a nice state for us. + * Register CPU notifier which resets the breakpoint resources. We + * assume that a halting debugger will leave the world in a nice state + * for us. */ - on_each_cpu(reset_ctrl_regs, NULL, 1); + ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "arm/hw_breakpoint:online", + dbg_reset_online, NULL); unregister_undef_hook(&debug_reg_hook); - if (!cpumask_empty(&debug_err_mask)) { + if (WARN_ON(ret < 0) || !cpumask_empty(&debug_err_mask)) { core_num_brps =3D 0; core_num_wrps =3D 0; - cpu_notifier_register_done(); + if (ret > 0) + cpuhp_remove_state_nocalls(ret); return 0; } =20 @@ -1109,11 +1107,7 @@ static int __init arch_hw_breakpoint_init(void) hook_ifault_code(FAULT_CODE_DEBUG, hw_breakpoint_pending, SIGTRAP, TRAP_HWBKPT, "breakpoint debug exception"); =20 - /* Register hotplug and PM notifiers. */ - __register_cpu_notifier(&dbg_reset_nb); - - cpu_notifier_register_done(); - + /* Register PM notifiers. */ pm_init(); return 0; } --=20 2.10.2