Release 4.14 arch/blackfin/mach-common/smp.c
/*
* IPI management based on arch/arm/kernel/smp.c (Copyright 2002 ARM Limited)
*
* Copyright 2007-2009 Analog Devices Inc.
* Philippe Gerum <rpm@xenomai.org>
*
* Licensed under the GPL-2.
*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/sched/mm.h>
#include <linux/sched/task_stack.h>
#include <linux/interrupt.h>
#include <linux/cache.h>
#include <linux/clockchips.h>
#include <linux/profile.h>
#include <linux/errno.h>
#include <linux/mm.h>
#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/cpumask.h>
#include <linux/seq_file.h>
#include <linux/irq.h>
#include <linux/slab.h>
#include <linux/atomic.h>
#include <asm/cacheflush.h>
#include <asm/irq_handler.h>
#include <asm/mmu_context.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
#include <asm/processor.h>
#include <asm/ptrace.h>
#include <asm/cpu.h>
#include <asm/time.h>
#include <linux/err.h>
/*
* Anomaly notes:
* 05000120 - we always define corelock as 32-bit integer in L2
*/
struct corelock_slot corelock __attribute__ ((__section__(".l2.bss")));
#ifdef CONFIG_ICACHE_FLUSH_L1
unsigned long blackfin_iflush_l1_entry[NR_CPUS];
#endif
struct blackfin_initial_pda initial_pda_coreb;
enum ipi_message_type {
BFIN_IPI_NONE,
BFIN_IPI_TIMER,
BFIN_IPI_RESCHEDULE,
BFIN_IPI_CALL_FUNC,
BFIN_IPI_CPU_STOP,
};
struct blackfin_flush_data {
unsigned long start;
unsigned long end;
};
void *secondary_stack;
static struct blackfin_flush_data smp_flush_data;
static DEFINE_SPINLOCK(stop_lock);
/* A magic number - stress test shows this is safe for common cases */
#define BFIN_IPI_MSGQ_LEN 5
/* Simple FIFO buffer, overflow leads to panic */
struct ipi_data {
atomic_t count;
atomic_t bits;
};
static DEFINE_PER_CPU(struct ipi_data, bfin_ipi);
static void ipi_cpu_stop(unsigned int cpu)
{
spin_lock(&stop_lock);
printk(KERN_CRIT "CPU%u: stopping\n", cpu);
dump_stack();
spin_unlock(&stop_lock);
set_cpu_online(cpu, false);
local_irq_disable();
while (1)
SSYNC();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 48 | 96.00% | 1 | 50.00% |
Motohiro Kosaki | 2 | 4.00% | 1 | 50.00% |
Total | 50 | 100.00% | 2 | 100.00% |
static void ipi_flush_icache(void *info)
{
struct blackfin_flush_data *fdata = info;
/* Invalidate the memory holding the bounds of the flushed region. */
blackfin_dcache_invalidate_range((unsigned long)fdata,
(unsigned long)fdata + sizeof(*fdata));
/* Make sure all write buffers in the data side of the core
* are flushed before trying to invalidate the icache. This
* needs to be after the data flush and before the icache
* flush so that the SSYNC does the right thing in preventing
* the instruction prefetcher from hitting things in cached
* memory at the wrong time -- it runs much further ahead than
* the pipeline.
*/
SSYNC();
/* ipi_flaush_icache is invoked by generic flush_icache_range,
* so call blackfin arch icache flush directly here.
*/
blackfin_icache_flush_range(fdata->start, fdata->end);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 48 | 87.27% | 1 | 50.00% |
Sonic Zhang | 7 | 12.73% | 1 | 50.00% |
Total | 55 | 100.00% | 2 | 100.00% |
/* Use IRQ_SUPPLE_0 to request reschedule.
* When returning from interrupt to user space,
* there is chance to reschedule */
static irqreturn_t ipi_handler_int0(int irq, void *dev_instance)
{
unsigned int cpu = smp_processor_id();
platform_clear_ipi(cpu, IRQ_SUPPLE_0);
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 26 | 86.67% | 1 | 50.00% |
Graf Yang | 4 | 13.33% | 1 | 50.00% |
Total | 30 | 100.00% | 2 | 100.00% |
DECLARE_PER_CPU(struct clock_event_device, coretmr_events);
void ipi_timer(void)
{
int cpu = smp_processor_id();
struct clock_event_device *evt = &per_cpu(coretmr_events, cpu);
evt->event_handler(evt);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bob Liu | 33 | 100.00% | 1 | 100.00% |
Total | 33 | 100.00% | 1 | 100.00% |
static irqreturn_t ipi_handler_int1(int irq, void *dev_instance)
{
struct ipi_data *bfin_ipi_data;
unsigned int cpu = smp_processor_id();
unsigned long pending;
unsigned long msg;
platform_clear_ipi(cpu, IRQ_SUPPLE_1);
smp_rmb();
bfin_ipi_data = this_cpu_ptr(&bfin_ipi);
while ((pending = atomic_xchg(&bfin_ipi_data->bits, 0)) != 0) {
msg = 0;
do {
msg = find_next_bit(&pending, BITS_PER_LONG, msg + 1);
switch (msg) {
case BFIN_IPI_TIMER:
ipi_timer();
break;
case BFIN_IPI_RESCHEDULE:
scheduler_ipi();
break;
case BFIN_IPI_CALL_FUNC:
generic_smp_call_function_interrupt();
break;
case BFIN_IPI_CPU_STOP:
ipi_cpu_stop(cpu);
break;
default:
goto out;
}
atomic_dec(&bfin_ipi_data->count);
} while (msg < BITS_PER_LONG);
}
out:
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Steven Miao | 67 | 44.08% | 4 | 40.00% |
Graf Yang | 57 | 37.50% | 1 | 10.00% |
Yi Li | 8 | 5.26% | 1 | 10.00% |
Bob Liu | 7 | 4.61% | 1 | 10.00% |
Peter Zijlstra | 7 | 4.61% | 1 | 10.00% |
Sonic Zhang | 4 | 2.63% | 1 | 10.00% |
Christoph Lameter | 2 | 1.32% | 1 | 10.00% |
Total | 152 | 100.00% | 10 | 100.00% |
static void bfin_ipi_init(void)
{
unsigned int cpu;
struct ipi_data *bfin_ipi_data;
for_each_possible_cpu(cpu) {
bfin_ipi_data = &per_cpu(bfin_ipi, cpu);
atomic_set(&bfin_ipi_data->bits, 0);
atomic_set(&bfin_ipi_data->count, 0);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 31 | 58.49% | 1 | 25.00% |
Steven Miao | 19 | 35.85% | 2 | 50.00% |
Yi Li | 3 | 5.66% | 1 | 25.00% |
Total | 53 | 100.00% | 4 | 100.00% |
void send_ipi(const struct cpumask *cpumask, enum ipi_message_type msg)
{
unsigned int cpu;
struct ipi_data *bfin_ipi_data;
unsigned long flags;
local_irq_save(flags);
for_each_cpu(cpu, cpumask) {
bfin_ipi_data = &per_cpu(bfin_ipi, cpu);
atomic_or((1 << msg), &bfin_ipi_data->bits);
atomic_inc(&bfin_ipi_data->count);
}
local_irq_restore(flags);
smp_wmb();
for_each_cpu(cpu, cpumask)
platform_send_ipi_cpu(cpu, IRQ_SUPPLE_1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Steven Miao | 43 | 45.74% | 3 | 42.86% |
Graf Yang | 33 | 35.11% | 1 | 14.29% |
Yi Li | 13 | 13.83% | 1 | 14.29% |
Motohiro Kosaki | 4 | 4.26% | 1 | 14.29% |
Peter Zijlstra | 1 | 1.06% | 1 | 14.29% |
Total | 94 | 100.00% | 7 | 100.00% |
void arch_send_call_function_single_ipi(int cpu)
{
send_ipi(cpumask_of(cpu), BFIN_IPI_CALL_FUNC);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 10 | 55.56% | 1 | 20.00% |
Steven Miao | 5 | 27.78% | 1 | 20.00% |
Jiang Liu | 1 | 5.56% | 1 | 20.00% |
Motohiro Kosaki | 1 | 5.56% | 1 | 20.00% |
Yi Li | 1 | 5.56% | 1 | 20.00% |
Total | 18 | 100.00% | 5 | 100.00% |
void arch_send_call_function_ipi_mask(const struct cpumask *mask)
{
send_ipi(mask, BFIN_IPI_CALL_FUNC);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 8 | 44.44% | 1 | 33.33% |
Steven Miao | 7 | 38.89% | 1 | 33.33% |
Yi Li | 3 | 16.67% | 1 | 33.33% |
Total | 18 | 100.00% | 3 | 100.00% |
void smp_send_reschedule(int cpu)
{
send_ipi(cpumask_of(cpu), BFIN_IPI_RESCHEDULE);
return;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yi Li | 7 | 36.84% | 1 | 25.00% |
Steven Miao | 6 | 31.58% | 2 | 50.00% |
Graf Yang | 6 | 31.58% | 1 | 25.00% |
Total | 19 | 100.00% | 4 | 100.00% |
void smp_send_msg(const struct cpumask *mask, unsigned long type)
{
send_ipi(mask, type);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bob Liu | 21 | 95.45% | 1 | 50.00% |
Steven Miao | 1 | 4.55% | 1 | 50.00% |
Total | 22 | 100.00% | 2 | 100.00% |
void smp_timer_broadcast(const struct cpumask *mask)
{
smp_send_msg(mask, BFIN_IPI_TIMER);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bob Liu | 18 | 100.00% | 1 | 100.00% |
Total | 18 | 100.00% | 1 | 100.00% |
void smp_send_stop(void)
{
cpumask_t callmap;
preempt_disable();
cpumask_copy(&callmap, cpu_online_mask);
cpumask_clear_cpu(smp_processor_id(), &callmap);
if (!cpumask_empty(&callmap))
send_ipi(&callmap, BFIN_IPI_CPU_STOP);
preempt_enable();
return;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 31 | 60.78% | 1 | 20.00% |
Motohiro Kosaki | 10 | 19.61% | 1 | 20.00% |
Sonic Zhang | 7 | 13.73% | 1 | 20.00% |
Steven Miao | 2 | 3.92% | 1 | 20.00% |
Yi Li | 1 | 1.96% | 1 | 20.00% |
Total | 51 | 100.00% | 5 | 100.00% |
int __cpu_up(unsigned int cpu, struct task_struct *idle)
{
int ret;
secondary_stack = task_stack_page(idle) + THREAD_SIZE;
ret = platform_boot_secondary(cpu, idle);
secondary_stack = NULL;
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 37 | 88.10% | 2 | 50.00% |
Thomas Gleixner | 5 | 11.90% | 2 | 50.00% |
Total | 42 | 100.00% | 4 | 100.00% |
static void setup_secondary(unsigned int cpu)
{
unsigned long ilat;
bfin_write_IMASK(0);
CSYNC();
ilat = bfin_read_ILAT();
CSYNC();
bfin_write_ILAT(ilat);
CSYNC();
/* Enable interrupt levels IVG7-15. IARs have been already
* programmed by the boot CPU. */
bfin_irq_flags |= IMASK_IVG15 |
IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 60 | 98.36% | 1 | 50.00% |
Mike Frysinger | 1 | 1.64% | 1 | 50.00% |
Total | 61 | 100.00% | 2 | 100.00% |
void secondary_start_kernel(void)
{
unsigned int cpu = smp_processor_id();
struct mm_struct *mm = &init_mm;
if (_bfin_swrst & SWRST_DBL_FAULT_B) {
printk(KERN_EMERG "CoreB Recovering from DOUBLE FAULT event\n");
#ifdef CONFIG_DEBUG_DOUBLEFAULT
printk(KERN_EMERG " While handling exception (EXCAUSE = %#x) at %pF\n",
initial_pda_coreb.seqstat_doublefault & SEQSTAT_EXCAUSE,
initial_pda_coreb.retx_doublefault);
printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %pF\n",
initial_pda_coreb.dcplb_doublefault_addr);
printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %pF\n",
initial_pda_coreb.icplb_doublefault_addr);
#endif
printk(KERN_NOTICE " The instruction at %pF caused a double exception\n",
initial_pda_coreb.retx);
}
/*
* We want the D-cache to be enabled early, in case the atomic
* support code emulates cache coherence (see
* __ARCH_SYNC_CORE_DCACHE).
*/
init_exception_vectors();
local_irq_disable();
/* Attach the new idle task to the global mm. */
mmget(mm);
mmgrab(mm);
current->active_mm = mm;
preempt_disable();
setup_secondary(cpu);
platform_secondary_init(cpu);
/* setup local core timer */
bfin_local_timer_setup();
local_irq_enable();
bfin_setup_caches(cpu);
notify_cpu_starting(cpu);
/*
* Calibrate loops per jiffy value.
* IRQs need to be enabled here - D-cache can be invalidated
* in timer irq handler, so core B can read correct jiffies.
*/
calibrate_delay();
/* We are done with local CPU inits, unblock the boot CPU. */
set_cpu_online(cpu, true);
cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 107 | 67.72% | 1 | 9.09% |
Mike Frysinger | 16 | 10.13% | 1 | 9.09% |
Steven Miao | 13 | 8.23% | 2 | 18.18% |
Yi Li | 11 | 6.96% | 2 | 18.18% |
Bob Liu | 5 | 3.16% | 1 | 9.09% |
Thomas Gleixner | 4 | 2.53% | 2 | 18.18% |
Vegard Nossum | 2 | 1.27% | 2 | 18.18% |
Total | 158 | 100.00% | 11 | 100.00% |
void __init smp_prepare_boot_cpu(void)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 7 | 100.00% | 1 | 100.00% |
Total | 7 | 100.00% | 1 | 100.00% |
void __init smp_prepare_cpus(unsigned int max_cpus)
{
platform_prepare_cpus(max_cpus);
bfin_ipi_init();
platform_request_ipi(IRQ_SUPPLE_0, ipi_handler_int0);
platform_request_ipi(IRQ_SUPPLE_1, ipi_handler_int1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 21 | 65.62% | 1 | 33.33% |
Yi Li | 10 | 31.25% | 1 | 33.33% |
Steven Miao | 1 | 3.12% | 1 | 33.33% |
Total | 32 | 100.00% | 3 | 100.00% |
void __init smp_cpus_done(unsigned int max_cpus)
{
unsigned long bogosum = 0;
unsigned int cpu;
for_each_online_cpu(cpu)
bogosum += loops_per_jiffy;
printk(KERN_INFO "SMP: Total of %d processors activated "
"(%lu.%02lu BogoMIPS).\n",
num_online_cpus(),
bogosum / (500000/HZ),
(bogosum / (5000/HZ)) % 100);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 58 | 100.00% | 1 | 100.00% |
Total | 58 | 100.00% | 1 | 100.00% |
void smp_icache_flush_range_others(unsigned long start, unsigned long end)
{
smp_flush_data.start = start;
smp_flush_data.end = end;
preempt_disable();
if (smp_call_function(&ipi_flush_icache, &smp_flush_data, 1))
printk(KERN_WARNING "SMP: failed to run I-cache flush request on other CPUs\n");
preempt_enable();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 43 | 86.00% | 1 | 50.00% |
Steven Miao | 7 | 14.00% | 1 | 50.00% |
Total | 50 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(smp_icache_flush_range_others);
#ifdef __ARCH_SYNC_CORE_ICACHE
unsigned long icache_invld_count[NR_CPUS];
void resync_core_icache(void)
{
unsigned int cpu = get_cpu();
blackfin_invalidate_entire_icache();
icache_invld_count[cpu]++;
put_cpu();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sonic Zhang | 22 | 84.62% | 1 | 50.00% |
Graf Yang | 4 | 15.38% | 1 | 50.00% |
Total | 26 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(resync_core_icache);
#endif
#ifdef __ARCH_SYNC_CORE_DCACHE
unsigned long dcache_invld_count[NR_CPUS];
unsigned long barrier_mask __attribute__ ((__section__(".l2.bss")));
void resync_core_dcache(void)
{
unsigned int cpu = get_cpu();
blackfin_invalidate_entire_dcache();
dcache_invld_count[cpu]++;
put_cpu();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 26 | 100.00% | 2 | 100.00% |
Total | 26 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(resync_core_dcache);
#endif
#ifdef CONFIG_HOTPLUG_CPU
int __cpu_disable(void)
{
unsigned int cpu = smp_processor_id();
if (cpu == 0)
return -EPERM;
set_cpu_online(cpu, false);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 34 | 100.00% | 1 | 100.00% |
Total | 34 | 100.00% | 1 | 100.00% |
int __cpu_die(unsigned int cpu)
{
return cpu_wait_death(cpu, 5);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 14 | 82.35% | 1 | 50.00% |
Paul E. McKenney | 3 | 17.65% | 1 | 50.00% |
Total | 17 | 100.00% | 2 | 100.00% |
void cpu_die(void)
{
(void)cpu_report_death();
atomic_dec(&init_mm.mm_users);
atomic_dec(&init_mm.mm_count);
local_irq_disable();
platform_cpu_die();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 30 | 85.71% | 1 | 50.00% |
Paul E. McKenney | 5 | 14.29% | 1 | 50.00% |
Total | 35 | 100.00% | 2 | 100.00% |
#endif
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Graf Yang | 896 | 63.50% | 6 | 14.29% |
Steven Miao | 187 | 13.25% | 7 | 16.67% |
Bob Liu | 96 | 6.80% | 1 | 2.38% |
Yi Li | 91 | 6.45% | 3 | 7.14% |
Sonic Zhang | 62 | 4.39% | 5 | 11.90% |
Mike Frysinger | 23 | 1.63% | 3 | 7.14% |
Motohiro Kosaki | 17 | 1.20% | 1 | 2.38% |
Thomas Gleixner | 9 | 0.64% | 4 | 9.52% |
Peter Zijlstra | 8 | 0.57% | 2 | 4.76% |
Paul E. McKenney | 8 | 0.57% | 1 | 2.38% |
Ingo Molnar | 4 | 0.28% | 2 | 4.76% |
Tejun Heo | 3 | 0.21% | 1 | 2.38% |
Christoph Lameter | 2 | 0.14% | 1 | 2.38% |
Vegard Nossum | 2 | 0.14% | 2 | 4.76% |
Robin Getz | 1 | 0.07% | 1 | 2.38% |
Arun Sharma | 1 | 0.07% | 1 | 2.38% |
Jiang Liu | 1 | 0.07% | 1 | 2.38% |
Total | 1411 | 100.00% | 42 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.