diff options
| -rw-r--r-- | arch/arm/mach-imx/clk-imx27.c | 2 | ||||
| -rw-r--r-- | arch/arm/mach-imx/clk-imx51-imx53.c | 2 | ||||
| -rw-r--r-- | arch/arm/mach-imx/mach-imx6q.c | 9 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/clock-r8a73a4.c | 2 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/clock-sh73a0.c | 2 | ||||
| -rw-r--r-- | drivers/cpufreq/cpufreq-cpu0.c | 7 | ||||
| -rw-r--r-- | drivers/cpufreq/cpufreq.c | 31 | ||||
| -rw-r--r-- | drivers/cpufreq/imx6q-cpufreq.c | 7 |
8 files changed, 43 insertions, 19 deletions
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c index c3cfa4116dc0..c6b40f386786 100644 --- a/arch/arm/mach-imx/clk-imx27.c +++ b/arch/arm/mach-imx/clk-imx27.c | |||
| @@ -285,7 +285,7 @@ int __init mx27_clocks_init(unsigned long fref) | |||
| 285 | clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL); | 285 | clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL); |
| 286 | clk_register_clkdev(clk[rtc_ipg_gate], NULL, "imx21-rtc"); | 286 | clk_register_clkdev(clk[rtc_ipg_gate], NULL, "imx21-rtc"); |
| 287 | clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL); | 287 | clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL); |
| 288 | clk_register_clkdev(clk[cpu_div], NULL, "cpufreq-cpu0.0"); | 288 | clk_register_clkdev(clk[cpu_div], NULL, "cpu0"); |
| 289 | clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL); | 289 | clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL); |
| 290 | 290 | ||
| 291 | mxc_timer_init(MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR), MX27_INT_GPT1); | 291 | mxc_timer_init(MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR), MX27_INT_GPT1); |
diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c index 1a56a3319997..de1964c7b8bc 100644 --- a/arch/arm/mach-imx/clk-imx51-imx53.c +++ b/arch/arm/mach-imx/clk-imx51-imx53.c | |||
| @@ -328,7 +328,7 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil, | |||
| 328 | clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1"); | 328 | clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1"); |
| 329 | clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2"); | 329 | clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2"); |
| 330 | clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma"); | 330 | clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma"); |
| 331 | clk_register_clkdev(clk[cpu_podf], NULL, "cpufreq-cpu0.0"); | 331 | clk_register_clkdev(clk[cpu_podf], NULL, "cpu0"); |
| 332 | clk_register_clkdev(clk[iim_gate], "iim", NULL); | 332 | clk_register_clkdev(clk[iim_gate], "iim", NULL); |
| 333 | clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0"); | 333 | clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0"); |
| 334 | clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1"); | 334 | clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1"); |
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index 85a1b51346c8..90372a21087f 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c | |||
| @@ -233,10 +233,15 @@ put_node: | |||
| 233 | of_node_put(np); | 233 | of_node_put(np); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | static void __init imx6q_opp_init(struct device *cpu_dev) | 236 | static void __init imx6q_opp_init(void) |
| 237 | { | 237 | { |
| 238 | struct device_node *np; | 238 | struct device_node *np; |
| 239 | struct device *cpu_dev = get_cpu_device(0); | ||
| 239 | 240 | ||
| 241 | if (!cpu_dev) { | ||
| 242 | pr_warn("failed to get cpu0 device\n"); | ||
| 243 | return; | ||
| 244 | } | ||
| 240 | np = of_node_get(cpu_dev->of_node); | 245 | np = of_node_get(cpu_dev->of_node); |
| 241 | if (!np) { | 246 | if (!np) { |
| 242 | pr_warn("failed to find cpu0 node\n"); | 247 | pr_warn("failed to find cpu0 node\n"); |
| @@ -268,7 +273,7 @@ static void __init imx6q_init_late(void) | |||
| 268 | imx6q_cpuidle_init(); | 273 | imx6q_cpuidle_init(); |
| 269 | 274 | ||
| 270 | if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ)) { | 275 | if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ)) { |
| 271 | imx6q_opp_init(&imx6q_cpufreq_pdev.dev); | 276 | imx6q_opp_init(); |
| 272 | platform_device_register(&imx6q_cpufreq_pdev); | 277 | platform_device_register(&imx6q_cpufreq_pdev); |
| 273 | } | 278 | } |
| 274 | } | 279 | } |
diff --git a/arch/arm/mach-shmobile/clock-r8a73a4.c b/arch/arm/mach-shmobile/clock-r8a73a4.c index 8ea5ef6c79cc..5bd2e851e3c7 100644 --- a/arch/arm/mach-shmobile/clock-r8a73a4.c +++ b/arch/arm/mach-shmobile/clock-r8a73a4.c | |||
| @@ -555,7 +555,7 @@ static struct clk_lookup lookups[] = { | |||
| 555 | CLKDEV_CON_ID("pll2h", &pll2h_clk), | 555 | CLKDEV_CON_ID("pll2h", &pll2h_clk), |
| 556 | 556 | ||
| 557 | /* CPU clock */ | 557 | /* CPU clock */ |
| 558 | CLKDEV_DEV_ID("cpufreq-cpu0", &z_clk), | 558 | CLKDEV_DEV_ID("cpu0", &z_clk), |
| 559 | 559 | ||
| 560 | /* DIV6 */ | 560 | /* DIV6 */ |
| 561 | CLKDEV_CON_ID("zb", &div6_clks[DIV6_ZB]), | 561 | CLKDEV_CON_ID("zb", &div6_clks[DIV6_ZB]), |
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c index 1942eaef5181..c92c023f0d27 100644 --- a/arch/arm/mach-shmobile/clock-sh73a0.c +++ b/arch/arm/mach-shmobile/clock-sh73a0.c | |||
| @@ -616,7 +616,7 @@ static struct clk_lookup lookups[] = { | |||
| 616 | CLKDEV_DEV_ID("smp_twd", &twd_clk), /* smp_twd */ | 616 | CLKDEV_DEV_ID("smp_twd", &twd_clk), /* smp_twd */ |
| 617 | 617 | ||
| 618 | /* DIV4 clocks */ | 618 | /* DIV4 clocks */ |
| 619 | CLKDEV_DEV_ID("cpufreq-cpu0", &div4_clks[DIV4_Z]), | 619 | CLKDEV_DEV_ID("cpu0", &div4_clks[DIV4_Z]), |
| 620 | 620 | ||
| 621 | /* DIV6 clocks */ | 621 | /* DIV6 clocks */ |
| 622 | CLKDEV_CON_ID("vck1_clk", &div6_clks[DIV6_VCK1]), | 622 | CLKDEV_CON_ID("vck1_clk", &div6_clks[DIV6_VCK1]), |
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index cbfffa91ebdd..78c49d8e0f4a 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 13 | 13 | ||
| 14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
| 15 | #include <linux/cpu.h> | ||
| 15 | #include <linux/cpufreq.h> | 16 | #include <linux/cpufreq.h> |
| 16 | #include <linux/err.h> | 17 | #include <linux/err.h> |
| 17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| @@ -177,7 +178,11 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
| 177 | struct device_node *np; | 178 | struct device_node *np; |
| 178 | int ret; | 179 | int ret; |
| 179 | 180 | ||
| 180 | cpu_dev = &pdev->dev; | 181 | cpu_dev = get_cpu_device(0); |
| 182 | if (!cpu_dev) { | ||
| 183 | pr_err("failed to get cpu0 device\n"); | ||
| 184 | return -ENODEV; | ||
| 185 | } | ||
| 181 | 186 | ||
| 182 | np = of_node_get(cpu_dev->of_node); | 187 | np = of_node_get(cpu_dev->of_node); |
| 183 | if (!np) { | 188 | if (!np) { |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 43c24aa756f6..89b3c52cd5c3 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
| @@ -952,9 +952,20 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | |||
| 952 | if (cpu == policy->cpu) | 952 | if (cpu == policy->cpu) |
| 953 | return; | 953 | return; |
| 954 | 954 | ||
| 955 | /* | ||
| 956 | * Take direct locks as lock_policy_rwsem_write wouldn't work here. | ||
| 957 | * Also lock for last cpu is enough here as contention will happen only | ||
| 958 | * after policy->cpu is changed and after it is changed, other threads | ||
| 959 | * will try to acquire lock for new cpu. And policy is already updated | ||
| 960 | * by then. | ||
| 961 | */ | ||
| 962 | down_write(&per_cpu(cpu_policy_rwsem, policy->cpu)); | ||
| 963 | |||
| 955 | policy->last_cpu = policy->cpu; | 964 | policy->last_cpu = policy->cpu; |
| 956 | policy->cpu = cpu; | 965 | policy->cpu = cpu; |
| 957 | 966 | ||
| 967 | up_write(&per_cpu(cpu_policy_rwsem, policy->last_cpu)); | ||
| 968 | |||
| 958 | #ifdef CONFIG_CPU_FREQ_TABLE | 969 | #ifdef CONFIG_CPU_FREQ_TABLE |
| 959 | cpufreq_frequency_table_update_policy_cpu(policy); | 970 | cpufreq_frequency_table_update_policy_cpu(policy); |
| 960 | #endif | 971 | #endif |
| @@ -1125,7 +1136,7 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, | |||
| 1125 | int ret; | 1136 | int ret; |
| 1126 | 1137 | ||
| 1127 | /* first sibling now owns the new sysfs dir */ | 1138 | /* first sibling now owns the new sysfs dir */ |
| 1128 | cpu_dev = get_cpu_device(cpumask_first(policy->cpus)); | 1139 | cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu)); |
| 1129 | 1140 | ||
| 1130 | /* Don't touch sysfs files during light-weight tear-down */ | 1141 | /* Don't touch sysfs files during light-weight tear-down */ |
| 1131 | if (frozen) | 1142 | if (frozen) |
| @@ -1189,12 +1200,9 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, | |||
| 1189 | policy->governor->name, CPUFREQ_NAME_LEN); | 1200 | policy->governor->name, CPUFREQ_NAME_LEN); |
| 1190 | #endif | 1201 | #endif |
| 1191 | 1202 | ||
| 1192 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1203 | lock_policy_rwsem_read(cpu); |
| 1193 | cpus = cpumask_weight(policy->cpus); | 1204 | cpus = cpumask_weight(policy->cpus); |
| 1194 | 1205 | unlock_policy_rwsem_read(cpu); | |
| 1195 | if (cpus > 1) | ||
| 1196 | cpumask_clear_cpu(cpu, policy->cpus); | ||
| 1197 | unlock_policy_rwsem_write(cpu); | ||
| 1198 | 1206 | ||
| 1199 | if (cpu != policy->cpu) { | 1207 | if (cpu != policy->cpu) { |
| 1200 | if (!frozen) | 1208 | if (!frozen) |
| @@ -1203,9 +1211,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, | |||
| 1203 | 1211 | ||
| 1204 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); | 1212 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); |
| 1205 | if (new_cpu >= 0) { | 1213 | if (new_cpu >= 0) { |
| 1206 | WARN_ON(lock_policy_rwsem_write(cpu)); | ||
| 1207 | update_policy_cpu(policy, new_cpu); | 1214 | update_policy_cpu(policy, new_cpu); |
| 1208 | unlock_policy_rwsem_write(cpu); | ||
| 1209 | 1215 | ||
| 1210 | if (!frozen) { | 1216 | if (!frozen) { |
| 1211 | pr_debug("%s: policy Kobject moved to cpu: %d " | 1217 | pr_debug("%s: policy Kobject moved to cpu: %d " |
| @@ -1237,9 +1243,12 @@ static int __cpufreq_remove_dev_finish(struct device *dev, | |||
| 1237 | return -EINVAL; | 1243 | return -EINVAL; |
| 1238 | } | 1244 | } |
| 1239 | 1245 | ||
| 1240 | lock_policy_rwsem_read(cpu); | 1246 | WARN_ON(lock_policy_rwsem_write(cpu)); |
| 1241 | cpus = cpumask_weight(policy->cpus); | 1247 | cpus = cpumask_weight(policy->cpus); |
| 1242 | unlock_policy_rwsem_read(cpu); | 1248 | |
| 1249 | if (cpus > 1) | ||
| 1250 | cpumask_clear_cpu(cpu, policy->cpus); | ||
| 1251 | unlock_policy_rwsem_write(cpu); | ||
| 1243 | 1252 | ||
| 1244 | /* If cpu is last user of policy, free policy */ | 1253 | /* If cpu is last user of policy, free policy */ |
| 1245 | if (cpus == 1) { | 1254 | if (cpus == 1) { |
| @@ -2095,7 +2104,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
| 2095 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 2104 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 2096 | if (cpufreq_driver) { | 2105 | if (cpufreq_driver) { |
| 2097 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 2106 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 2098 | return -EBUSY; | 2107 | return -EEXIST; |
| 2099 | } | 2108 | } |
| 2100 | cpufreq_driver = driver_data; | 2109 | cpufreq_driver = driver_data; |
| 2101 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 2110 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 3e396543aea4..c3fd2a101ca0 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <linux/clk.h> | 9 | #include <linux/clk.h> |
| 10 | #include <linux/cpu.h> | ||
| 10 | #include <linux/cpufreq.h> | 11 | #include <linux/cpufreq.h> |
| 11 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
| 12 | #include <linux/err.h> | 13 | #include <linux/err.h> |
| @@ -202,7 +203,11 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) | |||
| 202 | unsigned long min_volt, max_volt; | 203 | unsigned long min_volt, max_volt; |
| 203 | int num, ret; | 204 | int num, ret; |
| 204 | 205 | ||
| 205 | cpu_dev = &pdev->dev; | 206 | cpu_dev = get_cpu_device(0); |
| 207 | if (!cpu_dev) { | ||
| 208 | pr_err("failed to get cpu0 device\n"); | ||
| 209 | return -ENODEV; | ||
| 210 | } | ||
| 206 | 211 | ||
| 207 | np = of_node_get(cpu_dev->of_node); | 212 | np = of_node_get(cpu_dev->of_node); |
| 208 | if (!np) { | 213 | if (!np) { |
