MIPS: support for generic clockevents broadcast
authorPaul Burton <paul.burton@imgtec.com>
Fri, 14 Feb 2014 09:24:58 +0000 (09:24 +0000)
committerPaul Burton <paul.burton@imgtec.com>
Fri, 2 May 2014 15:39:12 +0000 (16:39 +0100)
This patch adds support for generic clockevents broadcast using the a
dummy clockevent device and the tick_broadcast function introduced by
commit 12ad10004645 "clockevents: Add generic timer broadcast function".

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
arch/mips/Kconfig
arch/mips/kernel/smp.c

index 322bbe12412ee229cdb17187911f82f67767b728..5cdc53b1ba56421a335271d9c46af22c268aba97 100644 (file)
@@ -51,6 +51,7 @@ config MIPS
        select HAVE_DEBUG_STACKOVERFLOW
        select HAVE_CC_STACKPROTECTOR
        select CPU_PM if CPU_IDLE
+       select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
 
 menu "Machine selection"
 
index 0a022ee33b2a15c5c9722e2e9aa5504358ba05f4..9a5226443bc19f1bae2e056ae445410f1ae73e15 100644 (file)
@@ -404,3 +404,46 @@ void dump_send_ipi(void (*dump_ipi_callback)(void *))
 }
 EXPORT_SYMBOL(dump_send_ipi);
 #endif
+
+#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
+
+static DEFINE_PER_CPU(atomic_t, tick_broadcast_count);
+static DEFINE_PER_CPU(struct call_single_data, tick_broadcast_csd);
+
+void tick_broadcast(const struct cpumask *mask)
+{
+       atomic_t *count;
+       struct call_single_data *csd;
+       int cpu;
+
+       for_each_cpu(cpu, mask) {
+               count = &per_cpu(tick_broadcast_count, cpu);
+               csd = &per_cpu(tick_broadcast_csd, cpu);
+
+               if (atomic_inc_return(count) == 1)
+                       smp_call_function_single_async(cpu, csd);
+       }
+}
+
+static void tick_broadcast_callee(void *info)
+{
+       int cpu = smp_processor_id();
+       tick_receive_broadcast();
+       atomic_set(&per_cpu(tick_broadcast_count, cpu), 0);
+}
+
+static int __init tick_broadcast_init(void)
+{
+       struct call_single_data *csd;
+       int cpu;
+
+       for (cpu = 0; cpu < NR_CPUS; cpu++) {
+               csd = &per_cpu(tick_broadcast_csd, cpu);
+               csd->func = tick_broadcast_callee;
+       }
+
+       return 0;
+}
+early_initcall(tick_broadcast_init);
+
+#endif /* CONFIG_GENERIC_CLOCKEVENTS_BROADCAST */