psci_smp.c (37cf524f9360f9165d67459b7bf795c01824df98) psci_smp.c (be120397e7709d9d5ed88317a385ce864a2603bc)
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * Copyright (C) 2012 ARM Limited
12 *
13 * Author: Will Deacon <will.deacon@arm.com>
14 */
15
16#include <linux/init.h>
17#include <linux/smp.h>
18#include <linux/of.h>
19#include <linux/delay.h>
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * Copyright (C) 2012 ARM Limited
12 *
13 * Author: Will Deacon <will.deacon@arm.com>
14 */
15
16#include <linux/init.h>
17#include <linux/smp.h>
18#include <linux/of.h>
19#include <linux/delay.h>
20#include <linux/psci.h>
21
20#include <uapi/linux/psci.h>
21
22#include <asm/psci.h>
23#include <asm/smp_plat.h>
24
25/*
26 * psci_smp assumes that the following is true about PSCI:
27 *

--- 23 unchanged lines hidden (view full) ---

51{
52 if (psci_ops.cpu_on)
53 return psci_ops.cpu_on(cpu_logical_map(cpu),
54 virt_to_idmap(&secondary_startup));
55 return -ENODEV;
56}
57
58#ifdef CONFIG_HOTPLUG_CPU
22#include <uapi/linux/psci.h>
23
24#include <asm/psci.h>
25#include <asm/smp_plat.h>
26
27/*
28 * psci_smp assumes that the following is true about PSCI:
29 *

--- 23 unchanged lines hidden (view full) ---

53{
54 if (psci_ops.cpu_on)
55 return psci_ops.cpu_on(cpu_logical_map(cpu),
56 virt_to_idmap(&secondary_startup));
57 return -ENODEV;
58}
59
60#ifdef CONFIG_HOTPLUG_CPU
61int psci_cpu_disable(unsigned int cpu)
62{
63 /* Fail early if we don't have CPU_OFF support */
64 if (!psci_ops.cpu_off)
65 return -EOPNOTSUPP;
66
67 /* Trusted OS will deny CPU_OFF */
68 if (psci_tos_resident_on(cpu))
69 return -EPERM;
70
71 return 0;
72}
73
59void __ref psci_cpu_die(unsigned int cpu)
60{
74void __ref psci_cpu_die(unsigned int cpu)
75{
61 const struct psci_power_state ps = {
62 .type = PSCI_POWER_STATE_TYPE_POWER_DOWN,
63 };
76 u32 state = PSCI_POWER_STATE_TYPE_POWER_DOWN <<
77 PSCI_0_2_POWER_STATE_TYPE_SHIFT;
64
78
65 if (psci_ops.cpu_off)
66 psci_ops.cpu_off(ps);
79 if (psci_ops.cpu_off)
80 psci_ops.cpu_off(state);
67
81
68 /* We should never return */
69 panic("psci: cpu %d failed to shutdown\n", cpu);
82 /* We should never return */
83 panic("psci: cpu %d failed to shutdown\n", cpu);
70}
71
72int __ref psci_cpu_kill(unsigned int cpu)
73{
74 int err, i;
75
76 if (!psci_ops.affinity_info)
77 return 1;

--- 26 unchanged lines hidden (view full) ---

104{
105 /* is cpu_on available at least? */
106 return (psci_ops.cpu_on != NULL);
107}
108
109struct smp_operations __initdata psci_smp_ops = {
110 .smp_boot_secondary = psci_boot_secondary,
111#ifdef CONFIG_HOTPLUG_CPU
84}
85
86int __ref psci_cpu_kill(unsigned int cpu)
87{
88 int err, i;
89
90 if (!psci_ops.affinity_info)
91 return 1;

--- 26 unchanged lines hidden (view full) ---

118{
119 /* is cpu_on available at least? */
120 return (psci_ops.cpu_on != NULL);
121}
122
123struct smp_operations __initdata psci_smp_ops = {
124 .smp_boot_secondary = psci_boot_secondary,
125#ifdef CONFIG_HOTPLUG_CPU
126 .cpu_disable = psci_cpu_disable,
112 .cpu_die = psci_cpu_die,
113 .cpu_kill = psci_cpu_kill,
114#endif
115};
127 .cpu_die = psci_cpu_die,
128 .cpu_kill = psci_cpu_kill,
129#endif
130};