Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935107AbcKVWqX (ORCPT ); Tue, 22 Nov 2016 17:46:23 -0500 Received: from terminus.zytor.com ([198.137.202.10]:33006 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935057AbcKVWqV (ORCPT ); Tue, 22 Nov 2016 17:46:21 -0500 Date: Tue, 22 Nov 2016 14:45:06 -0800 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: linux@armlinux.org.uk, hpa@zytor.com, will.deacon@arm.com, mingo@kernel.org, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, mark.rutland@arm.com, tglx@linutronix.de Reply-To: mingo@kernel.org, bigeasy@linutronix.de, hpa@zytor.com, will.deacon@arm.com, linux@armlinux.org.uk, tglx@linutronix.de, linux-kernel@vger.kernel.org, mark.rutland@arm.com In-Reply-To: <20161117183541.8588-16-bigeasy@linutronix.de> References: <20161117183541.8588-16-bigeasy@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] ARM/hw_breakpoint: Convert to hotplug state machine Git-Commit-ID: 9b377e217f0bd07f972d89ed0963df92818beffd X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4248 Lines: 138 Commit-ID: 9b377e217f0bd07f972d89ed0963df92818beffd Gitweb: http://git.kernel.org/tip/9b377e217f0bd07f972d89ed0963df92818beffd Author: Sebastian Andrzej Siewior AuthorDate: Thu, 17 Nov 2016 19:35:36 +0100 Committer: Thomas Gleixner CommitDate: Tue, 22 Nov 2016 23:34:41 +0100 ARM/hw_breakpoint: Convert to hotplug state machine 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. [ tglx: Added protection agaist hotplug back according to discussion with Will ] Signed-off-by: Sebastian Andrzej Siewior Cc: Mark Rutland Cc: rt@linuxtronix.de Cc: Will Deacon Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20161117183541.8588-16-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner --- arch/arm/kernel/hw_breakpoint.c | 47 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c index b8df458..188180b 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) } } -static void reset_ctrl_regs(void *unused) +static void reset_ctrl_regs(unsigned int cpu) { - int i, raw_num_brps, err = 0, cpu = smp_processor_id(); + int i, raw_num_brps, err = 0; u32 val; /* @@ -1020,25 +1020,20 @@ out_mdbgen: cpumask_or(&debug_err_mask, &debug_err_mask, cpumask_of(cpu)); } -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) == 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; } -static struct notifier_block dbg_reset_nb = { - .notifier_call = dbg_reset_notify, -}; - #ifdef CONFIG_CPU_PM static int dbg_cpu_pm_notify(struct notifier_block *self, unsigned long action, void *v) { if (action == CPU_PM_EXIT) - reset_ctrl_regs(NULL); + reset_ctrl_regs(smp_processor_id()); return NOTIFY_OK; } @@ -1059,6 +1054,8 @@ static inline void pm_init(void) static int __init arch_hw_breakpoint_init(void) { + int ret; + debug_arch = get_debug_arch(); if (!debug_arch_supported()) { @@ -1072,25 +1069,28 @@ static int __init arch_hw_breakpoint_init(void) core_num_brps = get_num_brps(); core_num_wrps = get_num_wrps(); - 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 * determine that. */ + get_online_cpus(); register_undef_hook(&debug_reg_hook); /* - * 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 = 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 = 0; core_num_wrps = 0; - cpu_notifier_register_done(); + if (ret > 0) + cpuhp_remove_state_nocalls(ret); + put_online_cpus(); return 0; } @@ -1108,12 +1108,9 @@ static int __init arch_hw_breakpoint_init(void) TRAP_HWBKPT, "watchpoint debug exception"); hook_ifault_code(FAULT_CODE_DEBUG, hw_breakpoint_pending, SIGTRAP, TRAP_HWBKPT, "breakpoint debug exception"); + put_online_cpus(); - /* Register hotplug and PM notifiers. */ - __register_cpu_notifier(&dbg_reset_nb); - - cpu_notifier_register_done(); - + /* Register PM notifiers. */ pm_init(); return 0; }