3 * @author Vasiliy Ulyanov <v.ulyanov@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Copyright (C) Samsung Electronics, 2014
25 * @section DESCRIPTION
27 * CPU controls implementation.
30 #include <linux/cpumask.h>
31 #include <linux/cpu.h>
32 #include <ksyms/ksyms.h>
35 static void (*swap_cpu_maps_update_begin)(void);
36 static void (*swap_cpu_maps_update_done)(void);
37 static int (*swap_cpu_down)(unsigned int, int);
38 static int (*swap_cpu_up)(unsigned int, int);
41 * @brief Disables nonboot CPUs lock.
43 * @param mask Pointer to CPU mask struct.
44 * @return 0 on success, error code on error.
46 int swap_disable_nonboot_cpus_lock(struct cpumask *mask)
51 swap_cpu_maps_update_begin();
54 boot_cpu = cpumask_first(cpu_online_mask);
56 for_each_online_cpu(cpu) {
59 ret = swap_cpu_down(cpu, 0);
61 cpumask_set_cpu(cpu, mask);
62 printk(KERN_INFO "===> SWAP CPU[%d] down(%d)\n", cpu, ret);
65 WARN_ON(num_online_cpus() > 1);
70 * @brief Enables nonboot CPUs unlock.
72 * @param mask Pointer to CPU mask struct.
73 * @return 0 on success, error code on error.
75 int swap_enable_nonboot_cpus_unlock(struct cpumask *mask)
79 if (cpumask_empty(mask))
82 for_each_cpu(cpu, mask) {
83 ret = swap_cpu_up(cpu, 0);
84 printk(KERN_INFO "===> SWAP CPU[%d] up(%d)\n", cpu, ret);
88 swap_cpu_maps_update_done();
94 * @brief Intializes CPU controls.
96 * @return 0 on success, error code on error.
98 int init_cpu_deps(void)
100 const char *sym = "cpu_maps_update_begin";
102 swap_cpu_maps_update_begin = (void *)swap_ksyms(sym);
103 if (!swap_cpu_maps_update_begin)
106 sym = "cpu_maps_update_done";
107 swap_cpu_maps_update_done = (void *)swap_ksyms(sym);
108 if (!swap_cpu_maps_update_done)
112 swap_cpu_up = (void *)swap_ksyms(sym);
117 swap_cpu_down = (void *)swap_ksyms(sym);
124 printk(KERN_INFO "ERROR: symbol %s(...) not found\n", sym);
128 #endif /* CONFIG_SMP */