From 429aa4aa7fd3bc955066ab2aaeb8c157f4277866 Mon Sep 17 00:00:00 2001 From: Hirokazu Takata Date: Thu, 16 Sep 2004 22:08:43 -0700 Subject: [PATCH] [PATCH] m32r: fix to build SMP kernel Here is a patch to fix compile errors to build SMP kernel for m32r. Signed-off-by: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/kernel/smp.c | 21 +++++++++++++++------ arch/m32r/kernel/smpboot.c | 28 ++-------------------------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/arch/m32r/kernel/smp.c b/arch/m32r/kernel/smp.c index 20305d58b402a..f3c974ebfa484 100644 --- a/arch/m32r/kernel/smp.c +++ b/arch/m32r/kernel/smp.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -130,6 +131,7 @@ unsigned long send_IPI_mask_phys(cpumask_t, int, int); *==========================================================================*/ void smp_send_reschedule(int cpu_id) { + WARN_ON(cpu_is_offline(cpu_id)); send_IPI_mask(cpumask_of_cpu(cpu_id), RESCHEDULE_IPI, 1); } @@ -394,7 +396,6 @@ void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long va) static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm, struct vm_area_struct *vma, unsigned long va) { - cpumask_t tmp; unsigned long *mask; #ifdef DEBUG_SMP unsigned long flags; @@ -412,11 +413,14 @@ static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm, */ BUG_ON(cpus_empty(cpumask)); - cpus_and(tmp, cpumask, cpu_online_map); - BUG_ON(!cpus_equal(cpumask, tmp)); BUG_ON(cpu_isset(smp_processor_id(), cpumask)); BUG_ON(!mm); + /* If a CPU which we ran on has gone down, OK. */ + cpus_and(cpumask, cpumask, cpu_online_map); + if (cpus_empty(cpumask)) + return; + /* * i'm not happy about this global shared spinlock in the * MM hot path, but we'll see how contended it is. @@ -592,7 +596,7 @@ int smp_call_function(void (*func) (void *info), void *info, int nonatomic, int wait) { struct call_data_struct data; - int cpus = num_online_cpus() - 1; + int cpus; #ifdef DEBUG_SMP unsigned long flags; @@ -601,8 +605,14 @@ int smp_call_function(void (*func) (void *info), void *info, int nonatomic, BUG(); #endif /* DEBUG_SMP */ - if (!cpus) + /* Holding any lock stops cpus from going down. */ + spin_lock(&call_lock); + cpus = num_online_cpus() - 1; + + if (!cpus) { + spin_unlock(&call_lock); return 0; + } /* Can deadlock when called with interrupts disabled */ WARN_ON(irqs_disabled()); @@ -614,7 +624,6 @@ int smp_call_function(void (*func) (void *info), void *info, int nonatomic, if (wait) atomic_set(&data.finished, 0); - spin_lock(&call_lock); call_data = &data; mb(); diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c index 41d8f32eac2ba..6ac4f705e43e9 100644 --- a/arch/m32r/kernel/smpboot.c +++ b/arch/m32r/kernel/smpboot.c @@ -2,7 +2,7 @@ * linux/arch/m32r/kernel/smpboot.c * orig : i386 2.4.10 * - * MITSUBISHI M32R SMP booting functions + * M32R SMP booting functions * * Copyright (c) 2001, 2002, 2003 Hitoshi Yamamoto * @@ -39,8 +39,6 @@ * Martin J. Bligh : Added support for multi-quad systems */ -/* $Id$ */ - #include #include #include @@ -117,7 +115,6 @@ unsigned long cache_decay_ticks = HZ / 100; void smp_prepare_boot_cpu(void); void smp_prepare_cpus(unsigned int); -static struct task_struct *fork_by_hand(void); static void smp_tune_scheduling(void); static void init_ipi_lock(void); static void do_boot_cpu(int); @@ -238,20 +235,6 @@ smp_done: Dprintk("Boot done.\n"); } -/* - * fork_by_hand : This routin executes do_fork for APs idle process. - */ -static struct task_struct * __init fork_by_hand(void) -{ - struct pt_regs regs = { 0 }; - - /* - * don't care about the eip and regs settings since - * we'll never reschedule the forked task. - */ - return copy_process(CLONE_VM | CLONE_IDLETASK, 0, ®s, 0, NULL, NULL); -} - static void __init smp_tune_scheduling(void) { /* Nothing to do. */ @@ -297,18 +280,11 @@ static void __init do_boot_cpu(int phys_id) * We can't use kernel_thread since we must avoid to * reschedule the child. */ - idle = fork_by_hand(); + idle = fork_idle(cpu_id); if (IS_ERR(idle)) panic("failed fork for CPU#%d.", cpu_id); - wake_up_forked_process(idle); - /* - * We remove it from the pidhash and the runqueue - * once we got the process: - */ - init_idle(idle, cpu_id); idle->thread.lr = (unsigned long)start_secondary; - unhash_process(idle); map_cpu_to_physid(cpu_id, phys_id); -- 2.53.0