~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to arch/arm/kernel/smp.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#include <linux/cache.h>
17
17
#include <linux/profile.h>
18
18
#include <linux/errno.h>
19
 
#include <linux/ftrace.h>
20
19
#include <linux/mm.h>
21
20
#include <linux/err.h>
22
21
#include <linux/cpu.h>
27
26
#include <linux/clockchips.h>
28
27
#include <linux/completion.h>
29
28
 
30
 
#include <asm/atomic.h>
 
29
#include <linux/atomic.h>
31
30
#include <asm/cacheflush.h>
32
31
#include <asm/cpu.h>
33
32
#include <asm/cputype.h>
 
33
#include <asm/exception.h>
 
34
#include <asm/topology.h>
34
35
#include <asm/mmu_context.h>
35
36
#include <asm/pgtable.h>
36
37
#include <asm/pgalloc.h>
39
40
#include <asm/tlbflush.h>
40
41
#include <asm/ptrace.h>
41
42
#include <asm/localtimer.h>
 
43
#include <asm/smp_plat.h>
42
44
 
43
45
/*
44
46
 * as from 2.5, kernels no longer have an init_tasks structure
259
261
}
260
262
#endif /* CONFIG_HOTPLUG_CPU */
261
263
 
 
264
int __cpu_logical_map[NR_CPUS];
 
265
 
 
266
void __init smp_setup_processor_id(void)
 
267
{
 
268
        int i;
 
269
        u32 cpu = is_smp() ? read_cpuid_mpidr() & 0xff : 0;
 
270
 
 
271
        cpu_logical_map(0) = cpu;
 
272
        for (i = 1; i < NR_CPUS; ++i)
 
273
                cpu_logical_map(i) = i == cpu ? 0 : i;
 
274
 
 
275
        printk(KERN_INFO "Booting Linux on physical CPU %d\n", cpu);
 
276
}
 
277
 
262
278
/*
263
279
 * Called by both boot and secondaries to move global data into
264
280
 * per-processor storage.
268
284
        struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
269
285
 
270
286
        cpu_info->loops_per_jiffy = loops_per_jiffy;
 
287
 
 
288
        store_cpu_topology(cpuid);
271
289
}
272
290
 
273
291
/*
301
319
         */
302
320
        platform_secondary_init(cpu);
303
321
 
304
 
        /*
305
 
         * Enable local interrupts.
306
 
         */
307
322
        notify_cpu_starting(cpu);
308
 
        local_irq_enable();
309
 
        local_fiq_enable();
310
 
 
311
 
        /*
312
 
         * Setup the percpu timer for this CPU.
313
 
         */
314
 
        percpu_timer_setup();
315
323
 
316
324
        calibrate_delay();
317
325
 
323
331
         * before we continue.
324
332
         */
325
333
        set_cpu_online(cpu, true);
 
334
 
 
335
        /*
 
336
         * Setup the percpu timer for this CPU.
 
337
         */
 
338
        percpu_timer_setup();
 
339
 
326
340
        while (!cpu_active(cpu))
327
341
                cpu_relax();
328
342
 
329
343
        /*
 
344
         * cpu_active bit is set, so it's safe to enalbe interrupts
 
345
         * now.
 
346
         */
 
347
        local_irq_enable();
 
348
        local_fiq_enable();
 
349
 
 
350
        /*
330
351
         * OK, it's off to the idle thread for us
331
352
         */
332
353
        cpu_idle();
358
379
{
359
380
        unsigned int ncores = num_possible_cpus();
360
381
 
 
382
        init_cpu_topology();
 
383
 
361
384
        smp_store_cpu_info(smp_processor_id());
362
385
 
363
386
        /*
365
388
         */
366
389
        if (max_cpus > ncores)
367
390
                max_cpus = ncores;
368
 
 
369
 
        if (max_cpus > 1) {
 
391
        if (ncores > 1 && max_cpus) {
370
392
                /*
371
393
                 * Enable the local timer or broadcast device for the
372
394
                 * boot CPU, but only if we have more than one CPU.
374
396
                percpu_timer_setup();
375
397
 
376
398
                /*
 
399
                 * Initialise the present map, which describes the set of CPUs
 
400
                 * actually populated at the present time. A platform should
 
401
                 * re-initialize the map in platform_smp_prepare_cpus() if
 
402
                 * present != possible (e.g. physical hotplug).
 
403
                 */
 
404
                init_cpu_present(&cpu_possible_map);
 
405
 
 
406
                /*
377
407
                 * Initialise the SCU if there are more than one CPU
378
408
                 * and let them know where to start.
379
409
                 */
430
460
        for (i = 0; i < NR_IPI; i++)
431
461
                sum += __get_irq_stat(cpu, ipi_irqs[i]);
432
462
 
433
 
#ifdef CONFIG_LOCAL_TIMERS
434
 
        sum += __get_irq_stat(cpu, local_timer_irqs);
435
 
#endif
436
 
 
437
463
        return sum;
438
464
}
439
465
 
450
476
        irq_exit();
451
477
}
452
478
 
453
 
#ifdef CONFIG_LOCAL_TIMERS
454
 
asmlinkage void __exception_irq_entry do_local_timer(struct pt_regs *regs)
455
 
{
456
 
        struct pt_regs *old_regs = set_irq_regs(regs);
457
 
        int cpu = smp_processor_id();
458
 
 
459
 
        if (local_timer_ack()) {
460
 
                __inc_irq_stat(cpu, local_timer_irqs);
461
 
                ipi_timer();
462
 
        }
463
 
 
464
 
        set_irq_regs(old_regs);
465
 
}
466
 
 
467
 
void show_local_irqs(struct seq_file *p, int prec)
468
 
{
469
 
        unsigned int cpu;
470
 
 
471
 
        seq_printf(p, "%*s: ", prec, "LOC");
472
 
 
473
 
        for_each_present_cpu(cpu)
474
 
                seq_printf(p, "%10u ", __get_irq_stat(cpu, local_timer_irqs));
475
 
 
476
 
        seq_printf(p, " Local timer interrupts\n");
477
 
}
478
 
#endif
479
 
 
480
479
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
481
480
static void smp_timer_broadcast(const struct cpumask *mask)
482
481
{
527
526
        unsigned int cpu = smp_processor_id();
528
527
        struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
529
528
 
530
 
        evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
 
529
        local_timer_stop(evt);
531
530
}
532
531
#endif
533
532
 
534
 
static DEFINE_SPINLOCK(stop_lock);
 
533
static DEFINE_RAW_SPINLOCK(stop_lock);
535
534
 
536
535
/*
537
536
 * ipi_cpu_stop - handle IPI from smp_send_stop()
540
539
{
541
540
        if (system_state == SYSTEM_BOOTING ||
542
541
            system_state == SYSTEM_RUNNING) {
543
 
                spin_lock(&stop_lock);
 
542
                raw_spin_lock(&stop_lock);
544
543
                printk(KERN_CRIT "CPU%u: stopping\n", cpu);
545
544
                dump_stack();
546
 
                spin_unlock(&stop_lock);
 
545
                raw_spin_unlock(&stop_lock);
547
546
        }
548
547
 
549
548
        set_cpu_online(cpu, false);
560
559
 */
561
560
asmlinkage void __exception_irq_entry do_IPI(int ipinr, struct pt_regs *regs)
562
561
{
 
562
        handle_IPI(ipinr, regs);
 
563
}
 
564
 
 
565
void handle_IPI(int ipinr, struct pt_regs *regs)
 
566
{
563
567
        unsigned int cpu = smp_processor_id();
564
568
        struct pt_regs *old_regs = set_irq_regs(regs);
565
569