linux/arch/arm64/kernel/smp_spin_table.c
<<
>>
Prefs
   1/*
   2 * Spin Table SMP initialisation
   3 *
   4 * Copyright (C) 2013 ARM Ltd.
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License version 2 as
   8 * published by the Free Software Foundation.
   9 *
  10 * This program is distributed in the hope that it will be useful,
  11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 * GNU General Public License for more details.
  14 *
  15 * You should have received a copy of the GNU General Public License
  16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17 */
  18
  19#include <linux/init.h>
  20#include <linux/of.h>
  21#include <linux/smp.h>
  22
  23#include <asm/cacheflush.h>
  24
  25static phys_addr_t cpu_release_addr[NR_CPUS];
  26
  27static int __init smp_spin_table_init_cpu(struct device_node *dn, int cpu)
  28{
  29        /*
  30         * Determine the address from which the CPU is polling.
  31         */
  32        if (of_property_read_u64(dn, "cpu-release-addr",
  33                                 &cpu_release_addr[cpu])) {
  34                pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
  35                       cpu);
  36
  37                return -1;
  38        }
  39
  40        return 0;
  41}
  42
  43static int __init smp_spin_table_prepare_cpu(int cpu)
  44{
  45        void **release_addr;
  46
  47        if (!cpu_release_addr[cpu])
  48                return -ENODEV;
  49
  50        release_addr = __va(cpu_release_addr[cpu]);
  51        release_addr[0] = (void *)__pa(secondary_holding_pen);
  52        __flush_dcache_area(release_addr, sizeof(release_addr[0]));
  53
  54        /*
  55         * Send an event to wake up the secondary CPU.
  56         */
  57        sev();
  58
  59        return 0;
  60}
  61
  62const struct smp_enable_ops smp_spin_table_ops __initconst = {
  63        .name           = "spin-table",
  64        .init_cpu       = smp_spin_table_init_cpu,
  65        .prepare_cpu    = smp_spin_table_prepare_cpu,
  66};
  67