diff options
77 files changed, 2248 insertions, 1049 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 0b3de80ec8f6..52292b28b291 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
| @@ -1661,6 +1661,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
| 1661 | hwp_only | 1661 | hwp_only |
| 1662 | Only load intel_pstate on systems which support | 1662 | Only load intel_pstate on systems which support |
| 1663 | hardware P state control (HWP) if available. | 1663 | hardware P state control (HWP) if available. |
| 1664 | support_acpi_ppc | ||
| 1665 | Enforce ACPI _PPC performance limits. If the Fixed ACPI | ||
| 1666 | Description Table, specifies preferred power management | ||
| 1667 | profile as "Enterprise Server" or "Performance Server", | ||
| 1668 | then this feature is turned on by default. | ||
| 1664 | 1669 | ||
| 1665 | intremap= [X86-64, Intel-IOMMU] | 1670 | intremap= [X86-64, Intel-IOMMU] |
| 1666 | on enable Interrupt Remapping (default) | 1671 | on enable Interrupt Remapping (default) |
diff --git a/MAINTAINERS b/MAINTAINERS index a727d9959ecd..ac6d27f95bed 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -1322,6 +1322,7 @@ F: drivers/rtc/rtc-armada38x.c | |||
| 1322 | F: arch/arm/boot/dts/armada* | 1322 | F: arch/arm/boot/dts/armada* |
| 1323 | F: arch/arm/boot/dts/kirkwood* | 1323 | F: arch/arm/boot/dts/kirkwood* |
| 1324 | F: arch/arm64/boot/dts/marvell/armada* | 1324 | F: arch/arm64/boot/dts/marvell/armada* |
| 1325 | F: drivers/cpufreq/mvebu-cpufreq.c | ||
| 1325 | 1326 | ||
| 1326 | 1327 | ||
| 1327 | ARM/Marvell Berlin SoC support | 1328 | ARM/Marvell Berlin SoC support |
diff --git a/arch/arm/mach-berlin/berlin.c b/arch/arm/mach-berlin/berlin.c index 25d73870ccca..ac181c6797ee 100644 --- a/arch/arm/mach-berlin/berlin.c +++ b/arch/arm/mach-berlin/berlin.c | |||
| @@ -18,11 +18,6 @@ | |||
| 18 | #include <asm/hardware/cache-l2x0.h> | 18 | #include <asm/hardware/cache-l2x0.h> |
| 19 | #include <asm/mach/arch.h> | 19 | #include <asm/mach/arch.h> |
| 20 | 20 | ||
| 21 | static void __init berlin_init_late(void) | ||
| 22 | { | ||
| 23 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
| 24 | } | ||
| 25 | |||
| 26 | static const char * const berlin_dt_compat[] = { | 21 | static const char * const berlin_dt_compat[] = { |
| 27 | "marvell,berlin", | 22 | "marvell,berlin", |
| 28 | NULL, | 23 | NULL, |
| @@ -30,7 +25,6 @@ static const char * const berlin_dt_compat[] = { | |||
| 30 | 25 | ||
| 31 | DT_MACHINE_START(BERLIN_DT, "Marvell Berlin") | 26 | DT_MACHINE_START(BERLIN_DT, "Marvell Berlin") |
| 32 | .dt_compat = berlin_dt_compat, | 27 | .dt_compat = berlin_dt_compat, |
| 33 | .init_late = berlin_init_late, | ||
| 34 | /* | 28 | /* |
| 35 | * with DT probing for L2CCs, berlin_init_machine can be removed. | 29 | * with DT probing for L2CCs, berlin_init_machine can be removed. |
| 36 | * Note: 88DE3005 (Armada 1500-mini) uses pl310 l2cc | 30 | * Note: 88DE3005 (Armada 1500-mini) uses pl310 l2cc |
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c index bbf51a46f772..4d3b056fd786 100644 --- a/arch/arm/mach-exynos/exynos.c +++ b/arch/arm/mach-exynos/exynos.c | |||
| @@ -213,33 +213,6 @@ static void __init exynos_init_irq(void) | |||
| 213 | exynos_map_pmu(); | 213 | exynos_map_pmu(); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | static const struct of_device_id exynos_cpufreq_matches[] = { | ||
| 217 | { .compatible = "samsung,exynos3250", .data = "cpufreq-dt" }, | ||
| 218 | { .compatible = "samsung,exynos4210", .data = "cpufreq-dt" }, | ||
| 219 | { .compatible = "samsung,exynos4212", .data = "cpufreq-dt" }, | ||
| 220 | { .compatible = "samsung,exynos4412", .data = "cpufreq-dt" }, | ||
| 221 | { .compatible = "samsung,exynos5250", .data = "cpufreq-dt" }, | ||
| 222 | #ifndef CONFIG_BL_SWITCHER | ||
| 223 | { .compatible = "samsung,exynos5420", .data = "cpufreq-dt" }, | ||
| 224 | { .compatible = "samsung,exynos5800", .data = "cpufreq-dt" }, | ||
| 225 | #endif | ||
| 226 | { /* sentinel */ } | ||
| 227 | }; | ||
| 228 | |||
| 229 | static void __init exynos_cpufreq_init(void) | ||
| 230 | { | ||
| 231 | struct device_node *root = of_find_node_by_path("/"); | ||
| 232 | const struct of_device_id *match; | ||
| 233 | |||
| 234 | match = of_match_node(exynos_cpufreq_matches, root); | ||
| 235 | if (!match) { | ||
| 236 | platform_device_register_simple("exynos-cpufreq", -1, NULL, 0); | ||
| 237 | return; | ||
| 238 | } | ||
| 239 | |||
| 240 | platform_device_register_simple(match->data, -1, NULL, 0); | ||
| 241 | } | ||
| 242 | |||
| 243 | static void __init exynos_dt_machine_init(void) | 216 | static void __init exynos_dt_machine_init(void) |
| 244 | { | 217 | { |
| 245 | /* | 218 | /* |
| @@ -262,8 +235,6 @@ static void __init exynos_dt_machine_init(void) | |||
| 262 | of_machine_is_compatible("samsung,exynos5250")) | 235 | of_machine_is_compatible("samsung,exynos5250")) |
| 263 | platform_device_register(&exynos_cpuidle); | 236 | platform_device_register(&exynos_cpuidle); |
| 264 | 237 | ||
| 265 | exynos_cpufreq_init(); | ||
| 266 | |||
| 267 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 238 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 268 | } | 239 | } |
| 269 | 240 | ||
diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c index bd42d1bd10af..530a728c2acc 100644 --- a/arch/arm/mach-imx/imx27-dt.c +++ b/arch/arm/mach-imx/imx27-dt.c | |||
| @@ -18,15 +18,6 @@ | |||
| 18 | #include "common.h" | 18 | #include "common.h" |
| 19 | #include "mx27.h" | 19 | #include "mx27.h" |
| 20 | 20 | ||
| 21 | static void __init imx27_dt_init(void) | ||
| 22 | { | ||
| 23 | struct platform_device_info devinfo = { .name = "cpufreq-dt", }; | ||
| 24 | |||
| 25 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | ||
| 26 | |||
| 27 | platform_device_register_full(&devinfo); | ||
| 28 | } | ||
| 29 | |||
| 30 | static const char * const imx27_dt_board_compat[] __initconst = { | 21 | static const char * const imx27_dt_board_compat[] __initconst = { |
| 31 | "fsl,imx27", | 22 | "fsl,imx27", |
| 32 | NULL | 23 | NULL |
| @@ -36,6 +27,5 @@ DT_MACHINE_START(IMX27_DT, "Freescale i.MX27 (Device Tree Support)") | |||
| 36 | .map_io = mx27_map_io, | 27 | .map_io = mx27_map_io, |
| 37 | .init_early = imx27_init_early, | 28 | .init_early = imx27_init_early, |
| 38 | .init_irq = mx27_init_irq, | 29 | .init_irq = mx27_init_irq, |
| 39 | .init_machine = imx27_dt_init, | ||
| 40 | .dt_compat = imx27_dt_board_compat, | 30 | .dt_compat = imx27_dt_board_compat, |
| 41 | MACHINE_END | 31 | MACHINE_END |
diff --git a/arch/arm/mach-imx/mach-imx51.c b/arch/arm/mach-imx/mach-imx51.c index 6883fbaf9484..10a82a4f1e58 100644 --- a/arch/arm/mach-imx/mach-imx51.c +++ b/arch/arm/mach-imx/mach-imx51.c | |||
| @@ -50,13 +50,10 @@ static void __init imx51_ipu_mipi_setup(void) | |||
| 50 | 50 | ||
| 51 | static void __init imx51_dt_init(void) | 51 | static void __init imx51_dt_init(void) |
| 52 | { | 52 | { |
| 53 | struct platform_device_info devinfo = { .name = "cpufreq-dt", }; | ||
| 54 | |||
| 55 | imx51_ipu_mipi_setup(); | 53 | imx51_ipu_mipi_setup(); |
| 56 | imx_src_init(); | 54 | imx_src_init(); |
| 57 | 55 | ||
| 58 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 56 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 59 | platform_device_register_full(&devinfo); | ||
| 60 | } | 57 | } |
| 61 | 58 | ||
| 62 | static void __init imx51_init_late(void) | 59 | static void __init imx51_init_late(void) |
diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c index 86316a979297..18b5c5c136db 100644 --- a/arch/arm/mach-imx/mach-imx53.c +++ b/arch/arm/mach-imx/mach-imx53.c | |||
| @@ -40,8 +40,6 @@ static void __init imx53_dt_init(void) | |||
| 40 | static void __init imx53_init_late(void) | 40 | static void __init imx53_init_late(void) |
| 41 | { | 41 | { |
| 42 | imx53_pm_init(); | 42 | imx53_pm_init(); |
| 43 | |||
| 44 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
| 45 | } | 43 | } |
| 46 | 44 | ||
| 47 | static const char * const imx53_dt_board_compat[] __initconst = { | 45 | static const char * const imx53_dt_board_compat[] __initconst = { |
diff --git a/arch/arm/mach-imx/mach-imx7d.c b/arch/arm/mach-imx/mach-imx7d.c index 5a27f20c9a82..b450f525a670 100644 --- a/arch/arm/mach-imx/mach-imx7d.c +++ b/arch/arm/mach-imx/mach-imx7d.c | |||
| @@ -105,11 +105,6 @@ static void __init imx7d_init_irq(void) | |||
| 105 | irqchip_init(); | 105 | irqchip_init(); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | static void __init imx7d_init_late(void) | ||
| 109 | { | ||
| 110 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
| 111 | } | ||
| 112 | |||
| 113 | static const char *const imx7d_dt_compat[] __initconst = { | 108 | static const char *const imx7d_dt_compat[] __initconst = { |
| 114 | "fsl,imx7d", | 109 | "fsl,imx7d", |
| 115 | NULL, | 110 | NULL, |
| @@ -117,7 +112,6 @@ static const char *const imx7d_dt_compat[] __initconst = { | |||
| 117 | 112 | ||
| 118 | DT_MACHINE_START(IMX7D, "Freescale i.MX7 Dual (Device Tree)") | 113 | DT_MACHINE_START(IMX7D, "Freescale i.MX7 Dual (Device Tree)") |
| 119 | .init_irq = imx7d_init_irq, | 114 | .init_irq = imx7d_init_irq, |
| 120 | .init_late = imx7d_init_late, | ||
| 121 | .init_machine = imx7d_init_machine, | 115 | .init_machine = imx7d_init_machine, |
| 122 | .dt_compat = imx7d_dt_compat, | 116 | .dt_compat = imx7d_dt_compat, |
| 123 | MACHINE_END | 117 | MACHINE_END |
diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c index ed8fda4cd055..b44442338e4e 100644 --- a/arch/arm/mach-mvebu/pmsu.c +++ b/arch/arm/mach-mvebu/pmsu.c | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | 20 | ||
| 21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
| 22 | #include <linux/cpu_pm.h> | 22 | #include <linux/cpu_pm.h> |
| 23 | #include <linux/cpufreq-dt.h> | ||
| 24 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
| 25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
| 26 | #include <linux/io.h> | 25 | #include <linux/io.h> |
| @@ -29,7 +28,6 @@ | |||
| 29 | #include <linux/of_address.h> | 28 | #include <linux/of_address.h> |
| 30 | #include <linux/of_device.h> | 29 | #include <linux/of_device.h> |
| 31 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
| 32 | #include <linux/pm_opp.h> | ||
| 33 | #include <linux/resource.h> | 31 | #include <linux/resource.h> |
| 34 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
| 35 | #include <linux/smp.h> | 33 | #include <linux/smp.h> |
| @@ -608,86 +606,3 @@ int mvebu_pmsu_dfs_request(int cpu) | |||
| 608 | 606 | ||
| 609 | return 0; | 607 | return 0; |
| 610 | } | 608 | } |
| 611 | |||
| 612 | struct cpufreq_dt_platform_data cpufreq_dt_pd = { | ||
| 613 | .independent_clocks = true, | ||
| 614 | }; | ||
| 615 | |||
| 616 | static int __init armada_xp_pmsu_cpufreq_init(void) | ||
| 617 | { | ||
| 618 | struct device_node *np; | ||
| 619 | struct resource res; | ||
| 620 | int ret, cpu; | ||
| 621 | |||
| 622 | if (!of_machine_is_compatible("marvell,armadaxp")) | ||
| 623 | return 0; | ||
| 624 | |||
| 625 | /* | ||
| 626 | * In order to have proper cpufreq handling, we need to ensure | ||
| 627 | * that the Device Tree description of the CPU clock includes | ||
| 628 | * the definition of the PMU DFS registers. If not, we do not | ||
| 629 | * register the clock notifier and the cpufreq driver. This | ||
| 630 | * piece of code is only for compatibility with old Device | ||
| 631 | * Trees. | ||
| 632 | */ | ||
| 633 | np = of_find_compatible_node(NULL, NULL, "marvell,armada-xp-cpu-clock"); | ||
| 634 | if (!np) | ||
| 635 | return 0; | ||
| 636 | |||
| 637 | ret = of_address_to_resource(np, 1, &res); | ||
| 638 | if (ret) { | ||
| 639 | pr_warn(FW_WARN "not enabling cpufreq, deprecated armada-xp-cpu-clock binding\n"); | ||
| 640 | of_node_put(np); | ||
| 641 | return 0; | ||
| 642 | } | ||
| 643 | |||
| 644 | of_node_put(np); | ||
| 645 | |||
| 646 | /* | ||
| 647 | * For each CPU, this loop registers the operating points | ||
| 648 | * supported (which are the nominal CPU frequency and half of | ||
| 649 | * it), and registers the clock notifier that will take care | ||
| 650 | * of doing the PMSU part of a frequency transition. | ||
| 651 | */ | ||
| 652 | for_each_possible_cpu(cpu) { | ||
| 653 | struct device *cpu_dev; | ||
| 654 | struct clk *clk; | ||
| 655 | int ret; | ||
| 656 | |||
| 657 | cpu_dev = get_cpu_device(cpu); | ||
| 658 | if (!cpu_dev) { | ||
| 659 | pr_err("Cannot get CPU %d\n", cpu); | ||
| 660 | continue; | ||
| 661 | } | ||
| 662 | |||
| 663 | clk = clk_get(cpu_dev, 0); | ||
| 664 | if (IS_ERR(clk)) { | ||
| 665 | pr_err("Cannot get clock for CPU %d\n", cpu); | ||
| 666 | return PTR_ERR(clk); | ||
| 667 | } | ||
| 668 | |||
| 669 | /* | ||
| 670 | * In case of a failure of dev_pm_opp_add(), we don't | ||
| 671 | * bother with cleaning up the registered OPP (there's | ||
| 672 | * no function to do so), and simply cancel the | ||
| 673 | * registration of the cpufreq device. | ||
| 674 | */ | ||
| 675 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0); | ||
| 676 | if (ret) { | ||
| 677 | clk_put(clk); | ||
| 678 | return ret; | ||
| 679 | } | ||
| 680 | |||
| 681 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0); | ||
| 682 | if (ret) { | ||
| 683 | clk_put(clk); | ||
| 684 | return ret; | ||
| 685 | } | ||
| 686 | } | ||
| 687 | |||
| 688 | platform_device_register_data(NULL, "cpufreq-dt", -1, | ||
| 689 | &cpufreq_dt_pd, sizeof(cpufreq_dt_pd)); | ||
| 690 | return 0; | ||
| 691 | } | ||
| 692 | |||
| 693 | device_initcall(armada_xp_pmsu_cpufreq_init); | ||
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index 58920bc8807b..2f7b11da7d5d 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c | |||
| @@ -277,13 +277,10 @@ static void __init omap4_init_voltages(void) | |||
| 277 | 277 | ||
| 278 | static inline void omap_init_cpufreq(void) | 278 | static inline void omap_init_cpufreq(void) |
| 279 | { | 279 | { |
| 280 | struct platform_device_info devinfo = { }; | 280 | struct platform_device_info devinfo = { .name = "omap-cpufreq" }; |
| 281 | 281 | ||
| 282 | if (!of_have_populated_dt()) | 282 | if (!of_have_populated_dt()) |
| 283 | devinfo.name = "omap-cpufreq"; | 283 | platform_device_register_full(&devinfo); |
| 284 | else | ||
| 285 | devinfo.name = "cpufreq-dt"; | ||
| 286 | platform_device_register_full(&devinfo); | ||
| 287 | } | 284 | } |
| 288 | 285 | ||
| 289 | static int __init omap2_common_pm_init(void) | 286 | static int __init omap2_common_pm_init(void) |
diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c index 3f07cc5dfe5f..beb71da5d9c8 100644 --- a/arch/arm/mach-rockchip/rockchip.c +++ b/arch/arm/mach-rockchip/rockchip.c | |||
| @@ -74,7 +74,6 @@ static void __init rockchip_dt_init(void) | |||
| 74 | { | 74 | { |
| 75 | rockchip_suspend_init(); | 75 | rockchip_suspend_init(); |
| 76 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 76 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 77 | platform_device_register_simple("cpufreq-dt", 0, NULL, 0); | ||
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | static const char * const rockchip_board_dt_compat[] = { | 79 | static const char * const rockchip_board_dt_compat[] = { |
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index a65c80ac9009..c9ea0e6ff4f9 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile | |||
| @@ -38,7 +38,6 @@ smp-$(CONFIG_ARCH_EMEV2) += smp-emev2.o headsmp-scu.o platsmp-scu.o | |||
| 38 | 38 | ||
| 39 | # PM objects | 39 | # PM objects |
| 40 | obj-$(CONFIG_SUSPEND) += suspend.o | 40 | obj-$(CONFIG_SUSPEND) += suspend.o |
| 41 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | ||
| 42 | obj-$(CONFIG_PM_RCAR) += pm-rcar.o | 41 | obj-$(CONFIG_PM_RCAR) += pm-rcar.o |
| 43 | obj-$(CONFIG_PM_RMOBILE) += pm-rmobile.o | 42 | obj-$(CONFIG_PM_RMOBILE) += pm-rmobile.o |
| 44 | obj-$(CONFIG_ARCH_RCAR_GEN2) += pm-rcar-gen2.o | 43 | obj-$(CONFIG_ARCH_RCAR_GEN2) += pm-rcar-gen2.o |
diff --git a/arch/arm/mach-shmobile/common.h b/arch/arm/mach-shmobile/common.h index 5464b7a75e30..3b562d87826d 100644 --- a/arch/arm/mach-shmobile/common.h +++ b/arch/arm/mach-shmobile/common.h | |||
| @@ -25,16 +25,9 @@ static inline int shmobile_suspend_init(void) { return 0; } | |||
| 25 | static inline void shmobile_smp_apmu_suspend_init(void) { } | 25 | static inline void shmobile_smp_apmu_suspend_init(void) { } |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #ifdef CONFIG_CPU_FREQ | ||
| 29 | int shmobile_cpufreq_init(void); | ||
| 30 | #else | ||
| 31 | static inline int shmobile_cpufreq_init(void) { return 0; } | ||
| 32 | #endif | ||
| 33 | |||
| 34 | static inline void __init shmobile_init_late(void) | 28 | static inline void __init shmobile_init_late(void) |
| 35 | { | 29 | { |
| 36 | shmobile_suspend_init(); | 30 | shmobile_suspend_init(); |
| 37 | shmobile_cpufreq_init(); | ||
| 38 | } | 31 | } |
| 39 | 32 | ||
| 40 | #endif /* __ARCH_MACH_COMMON_H */ | 33 | #endif /* __ARCH_MACH_COMMON_H */ |
diff --git a/arch/arm/mach-shmobile/cpufreq.c b/arch/arm/mach-shmobile/cpufreq.c deleted file mode 100644 index 634d701c56a7..000000000000 --- a/arch/arm/mach-shmobile/cpufreq.c +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * CPUFreq support code for SH-Mobile ARM | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Gaku Inami | ||
| 5 | * | ||
| 6 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 7 | * License. See the file "COPYING" in the main directory of this archive | ||
| 8 | * for more details. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include <linux/platform_device.h> | ||
| 12 | |||
| 13 | #include "common.h" | ||
| 14 | |||
| 15 | int __init shmobile_cpufreq_init(void) | ||
| 16 | { | ||
| 17 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
| 18 | return 0; | ||
| 19 | } | ||
diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c index 3c156190a1d4..95dca8c2c9ed 100644 --- a/arch/arm/mach-sunxi/sunxi.c +++ b/arch/arm/mach-sunxi/sunxi.c | |||
| @@ -17,11 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | #include <asm/mach/arch.h> | 18 | #include <asm/mach/arch.h> |
| 19 | 19 | ||
| 20 | static void __init sunxi_dt_cpufreq_init(void) | ||
| 21 | { | ||
| 22 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
| 23 | } | ||
| 24 | |||
| 25 | static const char * const sunxi_board_dt_compat[] = { | 20 | static const char * const sunxi_board_dt_compat[] = { |
| 26 | "allwinner,sun4i-a10", | 21 | "allwinner,sun4i-a10", |
| 27 | "allwinner,sun5i-a10s", | 22 | "allwinner,sun5i-a10s", |
| @@ -32,7 +27,6 @@ static const char * const sunxi_board_dt_compat[] = { | |||
| 32 | 27 | ||
| 33 | DT_MACHINE_START(SUNXI_DT, "Allwinner sun4i/sun5i Families") | 28 | DT_MACHINE_START(SUNXI_DT, "Allwinner sun4i/sun5i Families") |
| 34 | .dt_compat = sunxi_board_dt_compat, | 29 | .dt_compat = sunxi_board_dt_compat, |
| 35 | .init_late = sunxi_dt_cpufreq_init, | ||
| 36 | MACHINE_END | 30 | MACHINE_END |
| 37 | 31 | ||
| 38 | static const char * const sun6i_board_dt_compat[] = { | 32 | static const char * const sun6i_board_dt_compat[] = { |
| @@ -53,7 +47,6 @@ static void __init sun6i_timer_init(void) | |||
| 53 | DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family") | 47 | DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family") |
| 54 | .init_time = sun6i_timer_init, | 48 | .init_time = sun6i_timer_init, |
| 55 | .dt_compat = sun6i_board_dt_compat, | 49 | .dt_compat = sun6i_board_dt_compat, |
| 56 | .init_late = sunxi_dt_cpufreq_init, | ||
| 57 | MACHINE_END | 50 | MACHINE_END |
| 58 | 51 | ||
| 59 | static const char * const sun7i_board_dt_compat[] = { | 52 | static const char * const sun7i_board_dt_compat[] = { |
| @@ -63,7 +56,6 @@ static const char * const sun7i_board_dt_compat[] = { | |||
| 63 | 56 | ||
| 64 | DT_MACHINE_START(SUN7I_DT, "Allwinner sun7i (A20) Family") | 57 | DT_MACHINE_START(SUN7I_DT, "Allwinner sun7i (A20) Family") |
| 65 | .dt_compat = sun7i_board_dt_compat, | 58 | .dt_compat = sun7i_board_dt_compat, |
| 66 | .init_late = sunxi_dt_cpufreq_init, | ||
| 67 | MACHINE_END | 59 | MACHINE_END |
| 68 | 60 | ||
| 69 | static const char * const sun8i_board_dt_compat[] = { | 61 | static const char * const sun8i_board_dt_compat[] = { |
| @@ -77,7 +69,6 @@ static const char * const sun8i_board_dt_compat[] = { | |||
| 77 | DT_MACHINE_START(SUN8I_DT, "Allwinner sun8i Family") | 69 | DT_MACHINE_START(SUN8I_DT, "Allwinner sun8i Family") |
| 78 | .init_time = sun6i_timer_init, | 70 | .init_time = sun6i_timer_init, |
| 79 | .dt_compat = sun8i_board_dt_compat, | 71 | .dt_compat = sun8i_board_dt_compat, |
| 80 | .init_late = sunxi_dt_cpufreq_init, | ||
| 81 | MACHINE_END | 72 | MACHINE_END |
| 82 | 73 | ||
| 83 | static const char * const sun9i_board_dt_compat[] = { | 74 | static const char * const sun9i_board_dt_compat[] = { |
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c index 860ffb663f02..da876d28ccbc 100644 --- a/arch/arm/mach-zynq/common.c +++ b/arch/arm/mach-zynq/common.c | |||
| @@ -110,7 +110,6 @@ static void __init zynq_init_late(void) | |||
| 110 | */ | 110 | */ |
| 111 | static void __init zynq_init_machine(void) | 111 | static void __init zynq_init_machine(void) |
| 112 | { | 112 | { |
| 113 | struct platform_device_info devinfo = { .name = "cpufreq-dt", }; | ||
| 114 | struct soc_device_attribute *soc_dev_attr; | 113 | struct soc_device_attribute *soc_dev_attr; |
| 115 | struct soc_device *soc_dev; | 114 | struct soc_device *soc_dev; |
| 116 | struct device *parent = NULL; | 115 | struct device *parent = NULL; |
| @@ -145,7 +144,6 @@ out: | |||
| 145 | of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); | 144 | of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); |
| 146 | 145 | ||
| 147 | platform_device_register(&zynq_cpuidle_device); | 146 | platform_device_register(&zynq_cpuidle_device); |
| 148 | platform_device_register_full(&devinfo); | ||
| 149 | } | 147 | } |
| 150 | 148 | ||
| 151 | static void __init zynq_timer_init(void) | 149 | static void __init zynq_timer_init(void) |
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index a7f45853c103..b7445b6ae5a4 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
| @@ -18,7 +18,11 @@ config CPU_FREQ | |||
| 18 | 18 | ||
| 19 | if CPU_FREQ | 19 | if CPU_FREQ |
| 20 | 20 | ||
| 21 | config CPU_FREQ_GOV_ATTR_SET | ||
| 22 | bool | ||
| 23 | |||
| 21 | config CPU_FREQ_GOV_COMMON | 24 | config CPU_FREQ_GOV_COMMON |
| 25 | select CPU_FREQ_GOV_ATTR_SET | ||
| 22 | select IRQ_WORK | 26 | select IRQ_WORK |
| 23 | bool | 27 | bool |
| 24 | 28 | ||
| @@ -103,6 +107,17 @@ config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE | |||
| 103 | Be aware that not all cpufreq drivers support the conservative | 107 | Be aware that not all cpufreq drivers support the conservative |
| 104 | governor. If unsure have a look at the help section of the | 108 | governor. If unsure have a look at the help section of the |
| 105 | driver. Fallback governor will be the performance governor. | 109 | driver. Fallback governor will be the performance governor. |
| 110 | |||
| 111 | config CPU_FREQ_DEFAULT_GOV_SCHEDUTIL | ||
| 112 | bool "schedutil" | ||
| 113 | depends on SMP | ||
| 114 | select CPU_FREQ_GOV_SCHEDUTIL | ||
| 115 | select CPU_FREQ_GOV_PERFORMANCE | ||
| 116 | help | ||
| 117 | Use the 'schedutil' CPUFreq governor by default. If unsure, | ||
| 118 | have a look at the help section of that governor. The fallback | ||
| 119 | governor will be 'performance'. | ||
| 120 | |||
| 106 | endchoice | 121 | endchoice |
| 107 | 122 | ||
| 108 | config CPU_FREQ_GOV_PERFORMANCE | 123 | config CPU_FREQ_GOV_PERFORMANCE |
| @@ -184,6 +199,26 @@ config CPU_FREQ_GOV_CONSERVATIVE | |||
| 184 | 199 | ||
| 185 | If in doubt, say N. | 200 | If in doubt, say N. |
| 186 | 201 | ||
| 202 | config CPU_FREQ_GOV_SCHEDUTIL | ||
| 203 | tristate "'schedutil' cpufreq policy governor" | ||
| 204 | depends on CPU_FREQ && SMP | ||
| 205 | select CPU_FREQ_GOV_ATTR_SET | ||
| 206 | select IRQ_WORK | ||
| 207 | help | ||
| 208 | This governor makes decisions based on the utilization data provided | ||
| 209 | by the scheduler. It sets the CPU frequency to be proportional to | ||
| 210 | the utilization/capacity ratio coming from the scheduler. If the | ||
| 211 | utilization is frequency-invariant, the new frequency is also | ||
| 212 | proportional to the maximum available frequency. If that is not the | ||
| 213 | case, it is proportional to the current frequency of the CPU. The | ||
| 214 | frequency tipping point is at utilization/capacity equal to 80% in | ||
| 215 | both cases. | ||
| 216 | |||
| 217 | To compile this driver as a module, choose M here: the module will | ||
| 218 | be called cpufreq_schedutil. | ||
| 219 | |||
| 220 | If in doubt, say N. | ||
| 221 | |||
| 187 | comment "CPU frequency scaling drivers" | 222 | comment "CPU frequency scaling drivers" |
| 188 | 223 | ||
| 189 | config CPUFREQ_DT | 224 | config CPUFREQ_DT |
| @@ -191,6 +226,7 @@ config CPUFREQ_DT | |||
| 191 | depends on HAVE_CLK && OF | 226 | depends on HAVE_CLK && OF |
| 192 | # if CPU_THERMAL is on and THERMAL=m, CPUFREQ_DT cannot be =y: | 227 | # if CPU_THERMAL is on and THERMAL=m, CPUFREQ_DT cannot be =y: |
| 193 | depends on !CPU_THERMAL || THERMAL | 228 | depends on !CPU_THERMAL || THERMAL |
| 229 | select CPUFREQ_DT_PLATDEV | ||
| 194 | select PM_OPP | 230 | select PM_OPP |
| 195 | help | 231 | help |
| 196 | This adds a generic DT based cpufreq driver for frequency management. | 232 | This adds a generic DT based cpufreq driver for frequency management. |
| @@ -199,6 +235,15 @@ config CPUFREQ_DT | |||
| 199 | 235 | ||
| 200 | If in doubt, say N. | 236 | If in doubt, say N. |
| 201 | 237 | ||
| 238 | config CPUFREQ_DT_PLATDEV | ||
| 239 | bool | ||
| 240 | help | ||
| 241 | This adds a generic DT based cpufreq platdev driver for frequency | ||
| 242 | management. This creates a 'cpufreq-dt' platform device, on the | ||
| 243 | supported platforms. | ||
| 244 | |||
| 245 | If in doubt, say N. | ||
| 246 | |||
| 202 | if X86 | 247 | if X86 |
| 203 | source "drivers/cpufreq/Kconfig.x86" | 248 | source "drivers/cpufreq/Kconfig.x86" |
| 204 | endif | 249 | endif |
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 14b1f9393b05..d89b8afe23b6 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
| @@ -50,15 +50,6 @@ config ARM_HIGHBANK_CPUFREQ | |||
| 50 | 50 | ||
| 51 | If in doubt, say N. | 51 | If in doubt, say N. |
| 52 | 52 | ||
| 53 | config ARM_HISI_ACPU_CPUFREQ | ||
| 54 | tristate "Hisilicon ACPU CPUfreq driver" | ||
| 55 | depends on ARCH_HISI && CPUFREQ_DT | ||
| 56 | select PM_OPP | ||
| 57 | help | ||
| 58 | This enables the hisilicon ACPU CPUfreq driver. | ||
| 59 | |||
| 60 | If in doubt, say N. | ||
| 61 | |||
| 62 | config ARM_IMX6Q_CPUFREQ | 53 | config ARM_IMX6Q_CPUFREQ |
| 63 | tristate "Freescale i.MX6 cpufreq support" | 54 | tristate "Freescale i.MX6 cpufreq support" |
| 64 | depends on ARCH_MXC | 55 | depends on ARCH_MXC |
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index c59bdcb83217..adbd1de1cea5 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | config X86_INTEL_PSTATE | 5 | config X86_INTEL_PSTATE |
| 6 | bool "Intel P state control" | 6 | bool "Intel P state control" |
| 7 | depends on X86 | 7 | depends on X86 |
| 8 | select ACPI_PROCESSOR if ACPI | ||
| 8 | help | 9 | help |
| 9 | This driver provides a P state for Intel core processors. | 10 | This driver provides a P state for Intel core processors. |
| 10 | The driver implements an internal governor and will become | 11 | The driver implements an internal governor and will become |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 9e63fb1b09f8..e1eb11ee3570 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
| @@ -11,8 +11,10 @@ obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE) += cpufreq_userspace.o | |||
| 11 | obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o | 11 | obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o |
| 12 | obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o | 12 | obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o |
| 13 | obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o | 13 | obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o |
| 14 | obj-$(CONFIG_CPU_FREQ_GOV_ATTR_SET) += cpufreq_governor_attr_set.o | ||
| 14 | 15 | ||
| 15 | obj-$(CONFIG_CPUFREQ_DT) += cpufreq-dt.o | 16 | obj-$(CONFIG_CPUFREQ_DT) += cpufreq-dt.o |
| 17 | obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o | ||
| 16 | 18 | ||
| 17 | ################################################################################## | 19 | ################################################################################## |
| 18 | # x86 drivers. | 20 | # x86 drivers. |
| @@ -53,7 +55,6 @@ obj-$(CONFIG_ARCH_DAVINCI) += davinci-cpufreq.o | |||
| 53 | obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o | 55 | obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o |
| 54 | obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o | 56 | obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o |
| 55 | obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o | 57 | obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o |
| 56 | obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ) += hisi-acpu-cpufreq.o | ||
| 57 | obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o | 58 | obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o |
| 58 | obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o | 59 | obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o |
| 59 | obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o | 60 | obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o |
| @@ -78,6 +79,7 @@ obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o | |||
| 78 | obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o | 79 | obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o |
| 79 | obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o | 80 | obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o |
| 80 | obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o | 81 | obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o |
| 82 | obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o | ||
| 81 | 83 | ||
| 82 | 84 | ||
| 83 | ################################################################################## | 85 | ################################################################################## |
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index fb5712141040..32a15052f363 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
| @@ -25,6 +25,8 @@ | |||
| 25 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 25 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 29 | |||
| 28 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
| 29 | #include <linux/module.h> | 31 | #include <linux/module.h> |
| 30 | #include <linux/init.h> | 32 | #include <linux/init.h> |
| @@ -50,8 +52,6 @@ MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski"); | |||
| 50 | MODULE_DESCRIPTION("ACPI Processor P-States Driver"); | 52 | MODULE_DESCRIPTION("ACPI Processor P-States Driver"); |
| 51 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
| 52 | 54 | ||
| 53 | #define PFX "acpi-cpufreq: " | ||
| 54 | |||
| 55 | enum { | 55 | enum { |
| 56 | UNDEFINED_CAPABLE = 0, | 56 | UNDEFINED_CAPABLE = 0, |
| 57 | SYSTEM_INTEL_MSR_CAPABLE, | 57 | SYSTEM_INTEL_MSR_CAPABLE, |
| @@ -65,7 +65,6 @@ enum { | |||
| 65 | #define MSR_K7_HWCR_CPB_DIS (1ULL << 25) | 65 | #define MSR_K7_HWCR_CPB_DIS (1ULL << 25) |
| 66 | 66 | ||
| 67 | struct acpi_cpufreq_data { | 67 | struct acpi_cpufreq_data { |
| 68 | struct cpufreq_frequency_table *freq_table; | ||
| 69 | unsigned int resume; | 68 | unsigned int resume; |
| 70 | unsigned int cpu_feature; | 69 | unsigned int cpu_feature; |
| 71 | unsigned int acpi_perf_cpu; | 70 | unsigned int acpi_perf_cpu; |
| @@ -200,8 +199,9 @@ static int check_amd_hwpstate_cpu(unsigned int cpuid) | |||
| 200 | return cpu_has(cpu, X86_FEATURE_HW_PSTATE); | 199 | return cpu_has(cpu, X86_FEATURE_HW_PSTATE); |
| 201 | } | 200 | } |
| 202 | 201 | ||
| 203 | static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data) | 202 | static unsigned extract_io(struct cpufreq_policy *policy, u32 value) |
| 204 | { | 203 | { |
| 204 | struct acpi_cpufreq_data *data = policy->driver_data; | ||
| 205 | struct acpi_processor_performance *perf; | 205 | struct acpi_processor_performance *perf; |
| 206 | int i; | 206 | int i; |
| 207 | 207 | ||
| @@ -209,13 +209,14 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data) | |||
| 209 | 209 | ||
| 210 | for (i = 0; i < perf->state_count; i++) { | 210 | for (i = 0; i < perf->state_count; i++) { |
| 211 | if (value == perf->states[i].status) | 211 | if (value == perf->states[i].status) |
| 212 | return data->freq_table[i].frequency; | 212 | return policy->freq_table[i].frequency; |
| 213 | } | 213 | } |
| 214 | return 0; | 214 | return 0; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) | 217 | static unsigned extract_msr(struct cpufreq_policy *policy, u32 msr) |
| 218 | { | 218 | { |
| 219 | struct acpi_cpufreq_data *data = policy->driver_data; | ||
| 219 | struct cpufreq_frequency_table *pos; | 220 | struct cpufreq_frequency_table *pos; |
| 220 | struct acpi_processor_performance *perf; | 221 | struct acpi_processor_performance *perf; |
| 221 | 222 | ||
| @@ -226,20 +227,22 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) | |||
| 226 | 227 | ||
| 227 | perf = to_perf_data(data); | 228 | perf = to_perf_data(data); |
| 228 | 229 | ||
| 229 | cpufreq_for_each_entry(pos, data->freq_table) | 230 | cpufreq_for_each_entry(pos, policy->freq_table) |
| 230 | if (msr == perf->states[pos->driver_data].status) | 231 | if (msr == perf->states[pos->driver_data].status) |
| 231 | return pos->frequency; | 232 | return pos->frequency; |
| 232 | return data->freq_table[0].frequency; | 233 | return policy->freq_table[0].frequency; |
| 233 | } | 234 | } |
| 234 | 235 | ||
| 235 | static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data) | 236 | static unsigned extract_freq(struct cpufreq_policy *policy, u32 val) |
| 236 | { | 237 | { |
| 238 | struct acpi_cpufreq_data *data = policy->driver_data; | ||
| 239 | |||
| 237 | switch (data->cpu_feature) { | 240 | switch (data->cpu_feature) { |
| 238 | case SYSTEM_INTEL_MSR_CAPABLE: | 241 | case SYSTEM_INTEL_MSR_CAPABLE: |
| 239 | case SYSTEM_AMD_MSR_CAPABLE: | 242 | case SYSTEM_AMD_MSR_CAPABLE: |
| 240 | return extract_msr(val, data); | 243 | return extract_msr(policy, val); |
| 241 | case SYSTEM_IO_CAPABLE: | 244 | case SYSTEM_IO_CAPABLE: |
| 242 | return extract_io(val, data); | 245 | return extract_io(policy, val); |
| 243 | default: | 246 | default: |
| 244 | return 0; | 247 | return 0; |
| 245 | } | 248 | } |
| @@ -374,11 +377,11 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) | |||
| 374 | return 0; | 377 | return 0; |
| 375 | 378 | ||
| 376 | data = policy->driver_data; | 379 | data = policy->driver_data; |
| 377 | if (unlikely(!data || !data->freq_table)) | 380 | if (unlikely(!data || !policy->freq_table)) |
| 378 | return 0; | 381 | return 0; |
| 379 | 382 | ||
| 380 | cached_freq = data->freq_table[to_perf_data(data)->state].frequency; | 383 | cached_freq = policy->freq_table[to_perf_data(data)->state].frequency; |
| 381 | freq = extract_freq(get_cur_val(cpumask_of(cpu), data), data); | 384 | freq = extract_freq(policy, get_cur_val(cpumask_of(cpu), data)); |
| 382 | if (freq != cached_freq) { | 385 | if (freq != cached_freq) { |
| 383 | /* | 386 | /* |
| 384 | * The dreaded BIOS frequency change behind our back. | 387 | * The dreaded BIOS frequency change behind our back. |
| @@ -392,14 +395,15 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) | |||
| 392 | return freq; | 395 | return freq; |
| 393 | } | 396 | } |
| 394 | 397 | ||
| 395 | static unsigned int check_freqs(const struct cpumask *mask, unsigned int freq, | 398 | static unsigned int check_freqs(struct cpufreq_policy *policy, |
| 396 | struct acpi_cpufreq_data *data) | 399 | const struct cpumask *mask, unsigned int freq) |
| 397 | { | 400 | { |
| 401 | struct acpi_cpufreq_data *data = policy->driver_data; | ||
| 398 | unsigned int cur_freq; | 402 | unsigned int cur_freq; |
| 399 | unsigned int i; | 403 | unsigned int i; |
| 400 | 404 | ||
| 401 | for (i = 0; i < 100; i++) { | 405 | for (i = 0; i < 100; i++) { |
| 402 | cur_freq = extract_freq(get_cur_val(mask, data), data); | 406 | cur_freq = extract_freq(policy, get_cur_val(mask, data)); |
| 403 | if (cur_freq == freq) | 407 | if (cur_freq == freq) |
| 404 | return 1; | 408 | return 1; |
| 405 | udelay(10); | 409 | udelay(10); |
| @@ -416,12 +420,12 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
| 416 | unsigned int next_perf_state = 0; /* Index into perf table */ | 420 | unsigned int next_perf_state = 0; /* Index into perf table */ |
| 417 | int result = 0; | 421 | int result = 0; |
| 418 | 422 | ||
| 419 | if (unlikely(data == NULL || data->freq_table == NULL)) { | 423 | if (unlikely(!data)) { |
| 420 | return -ENODEV; | 424 | return -ENODEV; |
| 421 | } | 425 | } |
| 422 | 426 | ||
| 423 | perf = to_perf_data(data); | 427 | perf = to_perf_data(data); |
| 424 | next_perf_state = data->freq_table[index].driver_data; | 428 | next_perf_state = policy->freq_table[index].driver_data; |
| 425 | if (perf->state == next_perf_state) { | 429 | if (perf->state == next_perf_state) { |
| 426 | if (unlikely(data->resume)) { | 430 | if (unlikely(data->resume)) { |
| 427 | pr_debug("Called after resume, resetting to P%d\n", | 431 | pr_debug("Called after resume, resetting to P%d\n", |
| @@ -444,8 +448,8 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
| 444 | drv_write(data, mask, perf->states[next_perf_state].control); | 448 | drv_write(data, mask, perf->states[next_perf_state].control); |
| 445 | 449 | ||
| 446 | if (acpi_pstate_strict) { | 450 | if (acpi_pstate_strict) { |
| 447 | if (!check_freqs(mask, data->freq_table[index].frequency, | 451 | if (!check_freqs(policy, mask, |
| 448 | data)) { | 452 | policy->freq_table[index].frequency)) { |
| 449 | pr_debug("acpi_cpufreq_target failed (%d)\n", | 453 | pr_debug("acpi_cpufreq_target failed (%d)\n", |
| 450 | policy->cpu); | 454 | policy->cpu); |
| 451 | result = -EAGAIN; | 455 | result = -EAGAIN; |
| @@ -458,6 +462,43 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
| 458 | return result; | 462 | return result; |
| 459 | } | 463 | } |
| 460 | 464 | ||
| 465 | unsigned int acpi_cpufreq_fast_switch(struct cpufreq_policy *policy, | ||
| 466 | unsigned int target_freq) | ||
| 467 | { | ||
| 468 | struct acpi_cpufreq_data *data = policy->driver_data; | ||
| 469 | struct acpi_processor_performance *perf; | ||
| 470 | struct cpufreq_frequency_table *entry; | ||
| 471 | unsigned int next_perf_state, next_freq, freq; | ||
| 472 | |||
| 473 | /* | ||
| 474 | * Find the closest frequency above target_freq. | ||
| 475 | * | ||
| 476 | * The table is sorted in the reverse order with respect to the | ||
| 477 | * frequency and all of the entries are valid (see the initialization). | ||
| 478 | */ | ||
| 479 | entry = policy->freq_table; | ||
| 480 | do { | ||
| 481 | entry++; | ||
| 482 | freq = entry->frequency; | ||
| 483 | } while (freq >= target_freq && freq != CPUFREQ_TABLE_END); | ||
| 484 | entry--; | ||
| 485 | next_freq = entry->frequency; | ||
| 486 | next_perf_state = entry->driver_data; | ||
| 487 | |||
| 488 | perf = to_perf_data(data); | ||
| 489 | if (perf->state == next_perf_state) { | ||
| 490 | if (unlikely(data->resume)) | ||
| 491 | data->resume = 0; | ||
| 492 | else | ||
| 493 | return next_freq; | ||
| 494 | } | ||
| 495 | |||
| 496 | data->cpu_freq_write(&perf->control_register, | ||
| 497 | perf->states[next_perf_state].control); | ||
| 498 | perf->state = next_perf_state; | ||
| 499 | return next_freq; | ||
| 500 | } | ||
| 501 | |||
| 461 | static unsigned long | 502 | static unsigned long |
| 462 | acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu) | 503 | acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu) |
| 463 | { | 504 | { |
| @@ -611,10 +652,7 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c) | |||
| 611 | if ((c->x86 == 15) && | 652 | if ((c->x86 == 15) && |
| 612 | (c->x86_model == 6) && | 653 | (c->x86_model == 6) && |
| 613 | (c->x86_mask == 8)) { | 654 | (c->x86_mask == 8)) { |
| 614 | printk(KERN_INFO "acpi-cpufreq: Intel(R) " | 655 | pr_info("Intel(R) Xeon(R) 7100 Errata AL30, processors may lock up on frequency changes: disabling acpi-cpufreq\n"); |
| 615 | "Xeon(R) 7100 Errata AL30, processors may " | ||
| 616 | "lock up on frequency changes: disabling " | ||
| 617 | "acpi-cpufreq.\n"); | ||
| 618 | return -ENODEV; | 656 | return -ENODEV; |
| 619 | } | 657 | } |
| 620 | } | 658 | } |
| @@ -631,6 +669,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 631 | unsigned int result = 0; | 669 | unsigned int result = 0; |
| 632 | struct cpuinfo_x86 *c = &cpu_data(policy->cpu); | 670 | struct cpuinfo_x86 *c = &cpu_data(policy->cpu); |
| 633 | struct acpi_processor_performance *perf; | 671 | struct acpi_processor_performance *perf; |
| 672 | struct cpufreq_frequency_table *freq_table; | ||
| 634 | #ifdef CONFIG_SMP | 673 | #ifdef CONFIG_SMP |
| 635 | static int blacklisted; | 674 | static int blacklisted; |
| 636 | #endif | 675 | #endif |
| @@ -690,7 +729,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 690 | cpumask_copy(data->freqdomain_cpus, | 729 | cpumask_copy(data->freqdomain_cpus, |
| 691 | topology_sibling_cpumask(cpu)); | 730 | topology_sibling_cpumask(cpu)); |
| 692 | policy->shared_type = CPUFREQ_SHARED_TYPE_HW; | 731 | policy->shared_type = CPUFREQ_SHARED_TYPE_HW; |
| 693 | pr_info_once(PFX "overriding BIOS provided _PSD data\n"); | 732 | pr_info_once("overriding BIOS provided _PSD data\n"); |
| 694 | } | 733 | } |
| 695 | #endif | 734 | #endif |
| 696 | 735 | ||
| @@ -742,9 +781,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 742 | goto err_unreg; | 781 | goto err_unreg; |
| 743 | } | 782 | } |
| 744 | 783 | ||
| 745 | data->freq_table = kzalloc(sizeof(*data->freq_table) * | 784 | freq_table = kzalloc(sizeof(*freq_table) * |
| 746 | (perf->state_count+1), GFP_KERNEL); | 785 | (perf->state_count+1), GFP_KERNEL); |
| 747 | if (!data->freq_table) { | 786 | if (!freq_table) { |
| 748 | result = -ENOMEM; | 787 | result = -ENOMEM; |
| 749 | goto err_unreg; | 788 | goto err_unreg; |
| 750 | } | 789 | } |
| @@ -762,30 +801,29 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 762 | if (perf->control_register.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE && | 801 | if (perf->control_register.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE && |
| 763 | policy->cpuinfo.transition_latency > 20 * 1000) { | 802 | policy->cpuinfo.transition_latency > 20 * 1000) { |
| 764 | policy->cpuinfo.transition_latency = 20 * 1000; | 803 | policy->cpuinfo.transition_latency = 20 * 1000; |
| 765 | printk_once(KERN_INFO | 804 | pr_info_once("P-state transition latency capped at 20 uS\n"); |
| 766 | "P-state transition latency capped at 20 uS\n"); | ||
| 767 | } | 805 | } |
| 768 | 806 | ||
| 769 | /* table init */ | 807 | /* table init */ |
| 770 | for (i = 0; i < perf->state_count; i++) { | 808 | for (i = 0; i < perf->state_count; i++) { |
| 771 | if (i > 0 && perf->states[i].core_frequency >= | 809 | if (i > 0 && perf->states[i].core_frequency >= |
| 772 | data->freq_table[valid_states-1].frequency / 1000) | 810 | freq_table[valid_states-1].frequency / 1000) |
| 773 | continue; | 811 | continue; |
| 774 | 812 | ||
| 775 | data->freq_table[valid_states].driver_data = i; | 813 | freq_table[valid_states].driver_data = i; |
| 776 | data->freq_table[valid_states].frequency = | 814 | freq_table[valid_states].frequency = |
| 777 | perf->states[i].core_frequency * 1000; | 815 | perf->states[i].core_frequency * 1000; |
| 778 | valid_states++; | 816 | valid_states++; |
| 779 | } | 817 | } |
| 780 | data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END; | 818 | freq_table[valid_states].frequency = CPUFREQ_TABLE_END; |
| 781 | perf->state = 0; | 819 | perf->state = 0; |
| 782 | 820 | ||
| 783 | result = cpufreq_table_validate_and_show(policy, data->freq_table); | 821 | result = cpufreq_table_validate_and_show(policy, freq_table); |
| 784 | if (result) | 822 | if (result) |
| 785 | goto err_freqfree; | 823 | goto err_freqfree; |
| 786 | 824 | ||
| 787 | if (perf->states[0].core_frequency * 1000 != policy->cpuinfo.max_freq) | 825 | if (perf->states[0].core_frequency * 1000 != policy->cpuinfo.max_freq) |
| 788 | printk(KERN_WARNING FW_WARN "P-state 0 is not max freq\n"); | 826 | pr_warn(FW_WARN "P-state 0 is not max freq\n"); |
| 789 | 827 | ||
| 790 | switch (perf->control_register.space_id) { | 828 | switch (perf->control_register.space_id) { |
| 791 | case ACPI_ADR_SPACE_SYSTEM_IO: | 829 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| @@ -821,10 +859,13 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 821 | */ | 859 | */ |
| 822 | data->resume = 1; | 860 | data->resume = 1; |
| 823 | 861 | ||
| 862 | policy->fast_switch_possible = !acpi_pstate_strict && | ||
| 863 | !(policy_is_shared(policy) && policy->shared_type != CPUFREQ_SHARED_TYPE_ANY); | ||
| 864 | |||
| 824 | return result; | 865 | return result; |
| 825 | 866 | ||
| 826 | err_freqfree: | 867 | err_freqfree: |
| 827 | kfree(data->freq_table); | 868 | kfree(freq_table); |
| 828 | err_unreg: | 869 | err_unreg: |
| 829 | acpi_processor_unregister_performance(cpu); | 870 | acpi_processor_unregister_performance(cpu); |
| 830 | err_free_mask: | 871 | err_free_mask: |
| @@ -842,13 +883,12 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy) | |||
| 842 | 883 | ||
| 843 | pr_debug("acpi_cpufreq_cpu_exit\n"); | 884 | pr_debug("acpi_cpufreq_cpu_exit\n"); |
| 844 | 885 | ||
| 845 | if (data) { | 886 | policy->fast_switch_possible = false; |
| 846 | policy->driver_data = NULL; | 887 | policy->driver_data = NULL; |
| 847 | acpi_processor_unregister_performance(data->acpi_perf_cpu); | 888 | acpi_processor_unregister_performance(data->acpi_perf_cpu); |
| 848 | free_cpumask_var(data->freqdomain_cpus); | 889 | free_cpumask_var(data->freqdomain_cpus); |
| 849 | kfree(data->freq_table); | 890 | kfree(policy->freq_table); |
| 850 | kfree(data); | 891 | kfree(data); |
| 851 | } | ||
| 852 | 892 | ||
| 853 | return 0; | 893 | return 0; |
| 854 | } | 894 | } |
| @@ -876,6 +916,7 @@ static struct freq_attr *acpi_cpufreq_attr[] = { | |||
| 876 | static struct cpufreq_driver acpi_cpufreq_driver = { | 916 | static struct cpufreq_driver acpi_cpufreq_driver = { |
| 877 | .verify = cpufreq_generic_frequency_table_verify, | 917 | .verify = cpufreq_generic_frequency_table_verify, |
| 878 | .target_index = acpi_cpufreq_target, | 918 | .target_index = acpi_cpufreq_target, |
| 919 | .fast_switch = acpi_cpufreq_fast_switch, | ||
| 879 | .bios_limit = acpi_processor_get_bios_limit, | 920 | .bios_limit = acpi_processor_get_bios_limit, |
| 880 | .init = acpi_cpufreq_cpu_init, | 921 | .init = acpi_cpufreq_cpu_init, |
| 881 | .exit = acpi_cpufreq_cpu_exit, | 922 | .exit = acpi_cpufreq_cpu_exit, |
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index c251247ae661..418042201e6d 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c | |||
| @@ -298,7 +298,8 @@ static int merge_cluster_tables(void) | |||
| 298 | return 0; | 298 | return 0; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | static void _put_cluster_clk_and_freq_table(struct device *cpu_dev) | 301 | static void _put_cluster_clk_and_freq_table(struct device *cpu_dev, |
| 302 | const struct cpumask *cpumask) | ||
| 302 | { | 303 | { |
| 303 | u32 cluster = raw_cpu_to_cluster(cpu_dev->id); | 304 | u32 cluster = raw_cpu_to_cluster(cpu_dev->id); |
| 304 | 305 | ||
| @@ -308,11 +309,12 @@ static void _put_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 308 | clk_put(clk[cluster]); | 309 | clk_put(clk[cluster]); |
| 309 | dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); | 310 | dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); |
| 310 | if (arm_bL_ops->free_opp_table) | 311 | if (arm_bL_ops->free_opp_table) |
| 311 | arm_bL_ops->free_opp_table(cpu_dev); | 312 | arm_bL_ops->free_opp_table(cpumask); |
| 312 | dev_dbg(cpu_dev, "%s: cluster: %d\n", __func__, cluster); | 313 | dev_dbg(cpu_dev, "%s: cluster: %d\n", __func__, cluster); |
| 313 | } | 314 | } |
| 314 | 315 | ||
| 315 | static void put_cluster_clk_and_freq_table(struct device *cpu_dev) | 316 | static void put_cluster_clk_and_freq_table(struct device *cpu_dev, |
| 317 | const struct cpumask *cpumask) | ||
| 316 | { | 318 | { |
| 317 | u32 cluster = cpu_to_cluster(cpu_dev->id); | 319 | u32 cluster = cpu_to_cluster(cpu_dev->id); |
| 318 | int i; | 320 | int i; |
| @@ -321,7 +323,7 @@ static void put_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 321 | return; | 323 | return; |
| 322 | 324 | ||
| 323 | if (cluster < MAX_CLUSTERS) | 325 | if (cluster < MAX_CLUSTERS) |
| 324 | return _put_cluster_clk_and_freq_table(cpu_dev); | 326 | return _put_cluster_clk_and_freq_table(cpu_dev, cpumask); |
| 325 | 327 | ||
| 326 | for_each_present_cpu(i) { | 328 | for_each_present_cpu(i) { |
| 327 | struct device *cdev = get_cpu_device(i); | 329 | struct device *cdev = get_cpu_device(i); |
| @@ -330,14 +332,15 @@ static void put_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 330 | return; | 332 | return; |
| 331 | } | 333 | } |
| 332 | 334 | ||
| 333 | _put_cluster_clk_and_freq_table(cdev); | 335 | _put_cluster_clk_and_freq_table(cdev, cpumask); |
| 334 | } | 336 | } |
| 335 | 337 | ||
| 336 | /* free virtual table */ | 338 | /* free virtual table */ |
| 337 | kfree(freq_table[cluster]); | 339 | kfree(freq_table[cluster]); |
| 338 | } | 340 | } |
| 339 | 341 | ||
| 340 | static int _get_cluster_clk_and_freq_table(struct device *cpu_dev) | 342 | static int _get_cluster_clk_and_freq_table(struct device *cpu_dev, |
| 343 | const struct cpumask *cpumask) | ||
| 341 | { | 344 | { |
| 342 | u32 cluster = raw_cpu_to_cluster(cpu_dev->id); | 345 | u32 cluster = raw_cpu_to_cluster(cpu_dev->id); |
| 343 | int ret; | 346 | int ret; |
| @@ -345,7 +348,7 @@ static int _get_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 345 | if (freq_table[cluster]) | 348 | if (freq_table[cluster]) |
| 346 | return 0; | 349 | return 0; |
| 347 | 350 | ||
| 348 | ret = arm_bL_ops->init_opp_table(cpu_dev); | 351 | ret = arm_bL_ops->init_opp_table(cpumask); |
| 349 | if (ret) { | 352 | if (ret) { |
| 350 | dev_err(cpu_dev, "%s: init_opp_table failed, cpu: %d, err: %d\n", | 353 | dev_err(cpu_dev, "%s: init_opp_table failed, cpu: %d, err: %d\n", |
| 351 | __func__, cpu_dev->id, ret); | 354 | __func__, cpu_dev->id, ret); |
| @@ -374,14 +377,15 @@ static int _get_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 374 | 377 | ||
| 375 | free_opp_table: | 378 | free_opp_table: |
| 376 | if (arm_bL_ops->free_opp_table) | 379 | if (arm_bL_ops->free_opp_table) |
| 377 | arm_bL_ops->free_opp_table(cpu_dev); | 380 | arm_bL_ops->free_opp_table(cpumask); |
| 378 | out: | 381 | out: |
| 379 | dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__, | 382 | dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__, |
| 380 | cluster); | 383 | cluster); |
| 381 | return ret; | 384 | return ret; |
| 382 | } | 385 | } |
| 383 | 386 | ||
| 384 | static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | 387 | static int get_cluster_clk_and_freq_table(struct device *cpu_dev, |
| 388 | const struct cpumask *cpumask) | ||
| 385 | { | 389 | { |
| 386 | u32 cluster = cpu_to_cluster(cpu_dev->id); | 390 | u32 cluster = cpu_to_cluster(cpu_dev->id); |
| 387 | int i, ret; | 391 | int i, ret; |
| @@ -390,7 +394,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 390 | return 0; | 394 | return 0; |
| 391 | 395 | ||
| 392 | if (cluster < MAX_CLUSTERS) { | 396 | if (cluster < MAX_CLUSTERS) { |
| 393 | ret = _get_cluster_clk_and_freq_table(cpu_dev); | 397 | ret = _get_cluster_clk_and_freq_table(cpu_dev, cpumask); |
| 394 | if (ret) | 398 | if (ret) |
| 395 | atomic_dec(&cluster_usage[cluster]); | 399 | atomic_dec(&cluster_usage[cluster]); |
| 396 | return ret; | 400 | return ret; |
| @@ -407,7 +411,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 407 | return -ENODEV; | 411 | return -ENODEV; |
| 408 | } | 412 | } |
| 409 | 413 | ||
| 410 | ret = _get_cluster_clk_and_freq_table(cdev); | 414 | ret = _get_cluster_clk_and_freq_table(cdev, cpumask); |
| 411 | if (ret) | 415 | if (ret) |
| 412 | goto put_clusters; | 416 | goto put_clusters; |
| 413 | } | 417 | } |
| @@ -433,7 +437,7 @@ put_clusters: | |||
| 433 | return -ENODEV; | 437 | return -ENODEV; |
| 434 | } | 438 | } |
| 435 | 439 | ||
| 436 | _put_cluster_clk_and_freq_table(cdev); | 440 | _put_cluster_clk_and_freq_table(cdev, cpumask); |
| 437 | } | 441 | } |
| 438 | 442 | ||
| 439 | atomic_dec(&cluster_usage[cluster]); | 443 | atomic_dec(&cluster_usage[cluster]); |
| @@ -455,18 +459,6 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy) | |||
| 455 | return -ENODEV; | 459 | return -ENODEV; |
| 456 | } | 460 | } |
| 457 | 461 | ||
| 458 | ret = get_cluster_clk_and_freq_table(cpu_dev); | ||
| 459 | if (ret) | ||
| 460 | return ret; | ||
| 461 | |||
| 462 | ret = cpufreq_table_validate_and_show(policy, freq_table[cur_cluster]); | ||
| 463 | if (ret) { | ||
| 464 | dev_err(cpu_dev, "CPU %d, cluster: %d invalid freq table\n", | ||
| 465 | policy->cpu, cur_cluster); | ||
| 466 | put_cluster_clk_and_freq_table(cpu_dev); | ||
| 467 | return ret; | ||
| 468 | } | ||
| 469 | |||
| 470 | if (cur_cluster < MAX_CLUSTERS) { | 462 | if (cur_cluster < MAX_CLUSTERS) { |
| 471 | int cpu; | 463 | int cpu; |
| 472 | 464 | ||
| @@ -479,6 +471,18 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy) | |||
| 479 | per_cpu(physical_cluster, policy->cpu) = A15_CLUSTER; | 471 | per_cpu(physical_cluster, policy->cpu) = A15_CLUSTER; |
| 480 | } | 472 | } |
| 481 | 473 | ||
| 474 | ret = get_cluster_clk_and_freq_table(cpu_dev, policy->cpus); | ||
| 475 | if (ret) | ||
| 476 | return ret; | ||
| 477 | |||
| 478 | ret = cpufreq_table_validate_and_show(policy, freq_table[cur_cluster]); | ||
| 479 | if (ret) { | ||
| 480 | dev_err(cpu_dev, "CPU %d, cluster: %d invalid freq table\n", | ||
| 481 | policy->cpu, cur_cluster); | ||
| 482 | put_cluster_clk_and_freq_table(cpu_dev, policy->cpus); | ||
| 483 | return ret; | ||
| 484 | } | ||
| 485 | |||
| 482 | if (arm_bL_ops->get_transition_latency) | 486 | if (arm_bL_ops->get_transition_latency) |
| 483 | policy->cpuinfo.transition_latency = | 487 | policy->cpuinfo.transition_latency = |
| 484 | arm_bL_ops->get_transition_latency(cpu_dev); | 488 | arm_bL_ops->get_transition_latency(cpu_dev); |
| @@ -509,7 +513,7 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy) | |||
| 509 | return -ENODEV; | 513 | return -ENODEV; |
| 510 | } | 514 | } |
| 511 | 515 | ||
| 512 | put_cluster_clk_and_freq_table(cpu_dev); | 516 | put_cluster_clk_and_freq_table(cpu_dev, policy->related_cpus); |
| 513 | dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); | 517 | dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); |
| 514 | 518 | ||
| 515 | return 0; | 519 | return 0; |
diff --git a/drivers/cpufreq/arm_big_little.h b/drivers/cpufreq/arm_big_little.h index b88889d9387e..184d7c3a112a 100644 --- a/drivers/cpufreq/arm_big_little.h +++ b/drivers/cpufreq/arm_big_little.h | |||
| @@ -30,11 +30,11 @@ struct cpufreq_arm_bL_ops { | |||
| 30 | * This must set opp table for cpu_dev in a similar way as done by | 30 | * This must set opp table for cpu_dev in a similar way as done by |
| 31 | * dev_pm_opp_of_add_table(). | 31 | * dev_pm_opp_of_add_table(). |
| 32 | */ | 32 | */ |
| 33 | int (*init_opp_table)(struct device *cpu_dev); | 33 | int (*init_opp_table)(const struct cpumask *cpumask); |
| 34 | 34 | ||
| 35 | /* Optional */ | 35 | /* Optional */ |
| 36 | int (*get_transition_latency)(struct device *cpu_dev); | 36 | int (*get_transition_latency)(struct device *cpu_dev); |
| 37 | void (*free_opp_table)(struct device *cpu_dev); | 37 | void (*free_opp_table)(const struct cpumask *cpumask); |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); | 40 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); |
diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c index 16ddeefe9443..39b3f51d9a30 100644 --- a/drivers/cpufreq/arm_big_little_dt.c +++ b/drivers/cpufreq/arm_big_little_dt.c | |||
| @@ -43,23 +43,6 @@ static struct device_node *get_cpu_node_with_valid_op(int cpu) | |||
| 43 | return np; | 43 | return np; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | static int dt_init_opp_table(struct device *cpu_dev) | ||
| 47 | { | ||
| 48 | struct device_node *np; | ||
| 49 | int ret; | ||
| 50 | |||
| 51 | np = of_node_get(cpu_dev->of_node); | ||
| 52 | if (!np) { | ||
| 53 | pr_err("failed to find cpu%d node\n", cpu_dev->id); | ||
| 54 | return -ENOENT; | ||
| 55 | } | ||
| 56 | |||
| 57 | ret = dev_pm_opp_of_add_table(cpu_dev); | ||
| 58 | of_node_put(np); | ||
| 59 | |||
| 60 | return ret; | ||
| 61 | } | ||
| 62 | |||
| 63 | static int dt_get_transition_latency(struct device *cpu_dev) | 46 | static int dt_get_transition_latency(struct device *cpu_dev) |
| 64 | { | 47 | { |
| 65 | struct device_node *np; | 48 | struct device_node *np; |
| @@ -81,8 +64,8 @@ static int dt_get_transition_latency(struct device *cpu_dev) | |||
| 81 | static struct cpufreq_arm_bL_ops dt_bL_ops = { | 64 | static struct cpufreq_arm_bL_ops dt_bL_ops = { |
| 82 | .name = "dt-bl", | 65 | .name = "dt-bl", |
| 83 | .get_transition_latency = dt_get_transition_latency, | 66 | .get_transition_latency = dt_get_transition_latency, |
| 84 | .init_opp_table = dt_init_opp_table, | 67 | .init_opp_table = dev_pm_opp_of_cpumask_add_table, |
| 85 | .free_opp_table = dev_pm_opp_of_remove_table, | 68 | .free_opp_table = dev_pm_opp_of_cpumask_remove_table, |
| 86 | }; | 69 | }; |
| 87 | 70 | ||
| 88 | static int generic_bL_probe(struct platform_device *pdev) | 71 | static int generic_bL_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 7c0bdfb1a2ca..8882b8e2ecd0 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c | |||
| @@ -173,4 +173,25 @@ out: | |||
| 173 | return -ENODEV; | 173 | return -ENODEV; |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | static void __exit cppc_cpufreq_exit(void) | ||
| 177 | { | ||
| 178 | struct cpudata *cpu; | ||
| 179 | int i; | ||
| 180 | |||
| 181 | cpufreq_unregister_driver(&cppc_cpufreq_driver); | ||
| 182 | |||
| 183 | for_each_possible_cpu(i) { | ||
| 184 | cpu = all_cpu_data[i]; | ||
| 185 | free_cpumask_var(cpu->shared_cpu_map); | ||
| 186 | kfree(cpu); | ||
| 187 | } | ||
| 188 | |||
| 189 | kfree(all_cpu_data); | ||
| 190 | } | ||
| 191 | |||
| 192 | module_exit(cppc_cpufreq_exit); | ||
| 193 | MODULE_AUTHOR("Ashwin Chaugule"); | ||
| 194 | MODULE_DESCRIPTION("CPUFreq driver based on the ACPI CPPC v5.0+ spec"); | ||
| 195 | MODULE_LICENSE("GPL"); | ||
| 196 | |||
| 176 | late_initcall(cppc_cpufreq_init); | 197 | late_initcall(cppc_cpufreq_init); |
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c new file mode 100644 index 000000000000..3646b143bbf5 --- /dev/null +++ b/drivers/cpufreq/cpufreq-dt-platdev.c | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2016 Linaro. | ||
| 3 | * Viresh Kumar <viresh.kumar@linaro.org> | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include <linux/err.h> | ||
| 11 | #include <linux/of.h> | ||
| 12 | #include <linux/platform_device.h> | ||
| 13 | |||
| 14 | static const struct of_device_id machines[] __initconst = { | ||
| 15 | { .compatible = "allwinner,sun4i-a10", }, | ||
| 16 | { .compatible = "allwinner,sun5i-a10s", }, | ||
| 17 | { .compatible = "allwinner,sun5i-a13", }, | ||
| 18 | { .compatible = "allwinner,sun5i-r8", }, | ||
| 19 | { .compatible = "allwinner,sun6i-a31", }, | ||
| 20 | { .compatible = "allwinner,sun6i-a31s", }, | ||
| 21 | { .compatible = "allwinner,sun7i-a20", }, | ||
| 22 | { .compatible = "allwinner,sun8i-a23", }, | ||
| 23 | { .compatible = "allwinner,sun8i-a33", }, | ||
| 24 | { .compatible = "allwinner,sun8i-a83t", }, | ||
| 25 | { .compatible = "allwinner,sun8i-h3", }, | ||
| 26 | |||
| 27 | { .compatible = "hisilicon,hi6220", }, | ||
| 28 | |||
| 29 | { .compatible = "fsl,imx27", }, | ||
| 30 | { .compatible = "fsl,imx51", }, | ||
| 31 | { .compatible = "fsl,imx53", }, | ||
| 32 | { .compatible = "fsl,imx7d", }, | ||
| 33 | |||
| 34 | { .compatible = "marvell,berlin", }, | ||
| 35 | |||
| 36 | { .compatible = "samsung,exynos3250", }, | ||
| 37 | { .compatible = "samsung,exynos4210", }, | ||
| 38 | { .compatible = "samsung,exynos4212", }, | ||
| 39 | { .compatible = "samsung,exynos4412", }, | ||
| 40 | { .compatible = "samsung,exynos5250", }, | ||
| 41 | #ifndef CONFIG_BL_SWITCHER | ||
| 42 | { .compatible = "samsung,exynos5420", }, | ||
| 43 | { .compatible = "samsung,exynos5800", }, | ||
| 44 | #endif | ||
| 45 | |||
| 46 | { .compatible = "renesas,emev2", }, | ||
| 47 | { .compatible = "renesas,r7s72100", }, | ||
| 48 | { .compatible = "renesas,r8a73a4", }, | ||
| 49 | { .compatible = "renesas,r8a7740", }, | ||
| 50 | { .compatible = "renesas,r8a7778", }, | ||
| 51 | { .compatible = "renesas,r8a7779", }, | ||
| 52 | { .compatible = "renesas,r8a7790", }, | ||
| 53 | { .compatible = "renesas,r8a7791", }, | ||
| 54 | { .compatible = "renesas,r8a7793", }, | ||
| 55 | { .compatible = "renesas,r8a7794", }, | ||
| 56 | { .compatible = "renesas,sh73a0", }, | ||
| 57 | |||
| 58 | { .compatible = "rockchip,rk2928", }, | ||
| 59 | { .compatible = "rockchip,rk3036", }, | ||
| 60 | { .compatible = "rockchip,rk3066a", }, | ||
| 61 | { .compatible = "rockchip,rk3066b", }, | ||
| 62 | { .compatible = "rockchip,rk3188", }, | ||
| 63 | { .compatible = "rockchip,rk3228", }, | ||
| 64 | { .compatible = "rockchip,rk3288", }, | ||
| 65 | { .compatible = "rockchip,rk3366", }, | ||
| 66 | { .compatible = "rockchip,rk3368", }, | ||
| 67 | { .compatible = "rockchip,rk3399", }, | ||
| 68 | |||
| 69 | { .compatible = "sigma,tango4" }, | ||
| 70 | |||
| 71 | { .compatible = "ti,omap2", }, | ||
| 72 | { .compatible = "ti,omap3", }, | ||
| 73 | { .compatible = "ti,omap4", }, | ||
| 74 | { .compatible = "ti,omap5", }, | ||
| 75 | |||
| 76 | { .compatible = "xlnx,zynq-7000", }, | ||
| 77 | }; | ||
| 78 | |||
| 79 | static int __init cpufreq_dt_platdev_init(void) | ||
| 80 | { | ||
| 81 | struct device_node *np = of_find_node_by_path("/"); | ||
| 82 | |||
| 83 | if (!np) | ||
| 84 | return -ENODEV; | ||
| 85 | |||
| 86 | if (!of_match_node(machines, np)) | ||
| 87 | return -ENODEV; | ||
| 88 | |||
| 89 | of_node_put(of_root); | ||
| 90 | |||
| 91 | return PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", -1, | ||
| 92 | NULL, 0)); | ||
| 93 | } | ||
| 94 | device_initcall(cpufreq_dt_platdev_init); | ||
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 5f8dbe640a20..3957de801ae8 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | #include <linux/cpu.h> | 15 | #include <linux/cpu.h> |
| 16 | #include <linux/cpu_cooling.h> | 16 | #include <linux/cpu_cooling.h> |
| 17 | #include <linux/cpufreq.h> | 17 | #include <linux/cpufreq.h> |
| 18 | #include <linux/cpufreq-dt.h> | ||
| 19 | #include <linux/cpumask.h> | 18 | #include <linux/cpumask.h> |
| 20 | #include <linux/err.h> | 19 | #include <linux/err.h> |
| 21 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| @@ -147,7 +146,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
| 147 | struct clk *cpu_clk; | 146 | struct clk *cpu_clk; |
| 148 | struct dev_pm_opp *suspend_opp; | 147 | struct dev_pm_opp *suspend_opp; |
| 149 | unsigned int transition_latency; | 148 | unsigned int transition_latency; |
| 150 | bool opp_v1 = false; | 149 | bool fallback = false; |
| 151 | const char *name; | 150 | const char *name; |
| 152 | int ret; | 151 | int ret; |
| 153 | 152 | ||
| @@ -167,14 +166,16 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
| 167 | /* Get OPP-sharing information from "operating-points-v2" bindings */ | 166 | /* Get OPP-sharing information from "operating-points-v2" bindings */ |
| 168 | ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus); | 167 | ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus); |
| 169 | if (ret) { | 168 | if (ret) { |
| 169 | if (ret != -ENOENT) | ||
| 170 | goto out_put_clk; | ||
| 171 | |||
| 170 | /* | 172 | /* |
| 171 | * operating-points-v2 not supported, fallback to old method of | 173 | * operating-points-v2 not supported, fallback to old method of |
| 172 | * finding shared-OPPs for backward compatibility. | 174 | * finding shared-OPPs for backward compatibility if the |
| 175 | * platform hasn't set sharing CPUs. | ||
| 173 | */ | 176 | */ |
| 174 | if (ret == -ENOENT) | 177 | if (dev_pm_opp_get_sharing_cpus(cpu_dev, policy->cpus)) |
| 175 | opp_v1 = true; | 178 | fallback = true; |
| 176 | else | ||
| 177 | goto out_put_clk; | ||
| 178 | } | 179 | } |
| 179 | 180 | ||
| 180 | /* | 181 | /* |
| @@ -214,11 +215,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
| 214 | goto out_free_opp; | 215 | goto out_free_opp; |
| 215 | } | 216 | } |
| 216 | 217 | ||
| 217 | if (opp_v1) { | 218 | if (fallback) { |
| 218 | struct cpufreq_dt_platform_data *pd = cpufreq_get_driver_data(); | 219 | cpumask_setall(policy->cpus); |
| 219 | |||
| 220 | if (!pd || !pd->independent_clocks) | ||
| 221 | cpumask_setall(policy->cpus); | ||
| 222 | 220 | ||
| 223 | /* | 221 | /* |
| 224 | * OPP tables are initialized only for policy->cpu, do it for | 222 | * OPP tables are initialized only for policy->cpu, do it for |
diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c index db69eeb501a7..5503d491b016 100644 --- a/drivers/cpufreq/cpufreq-nforce2.c +++ b/drivers/cpufreq/cpufreq-nforce2.c | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* | 7 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* |
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 11 | |||
| 10 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 11 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 12 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
| @@ -56,8 +58,6 @@ MODULE_PARM_DESC(fid, "CPU multiplier to use (11.5 = 115)"); | |||
| 56 | MODULE_PARM_DESC(min_fsb, | 58 | MODULE_PARM_DESC(min_fsb, |
| 57 | "Minimum FSB to use, if not defined: current FSB - 50"); | 59 | "Minimum FSB to use, if not defined: current FSB - 50"); |
| 58 | 60 | ||
| 59 | #define PFX "cpufreq-nforce2: " | ||
| 60 | |||
| 61 | /** | 61 | /** |
| 62 | * nforce2_calc_fsb - calculate FSB | 62 | * nforce2_calc_fsb - calculate FSB |
| 63 | * @pll: PLL value | 63 | * @pll: PLL value |
| @@ -174,13 +174,13 @@ static int nforce2_set_fsb(unsigned int fsb) | |||
| 174 | int pll = 0; | 174 | int pll = 0; |
| 175 | 175 | ||
| 176 | if ((fsb > max_fsb) || (fsb < NFORCE2_MIN_FSB)) { | 176 | if ((fsb > max_fsb) || (fsb < NFORCE2_MIN_FSB)) { |
| 177 | printk(KERN_ERR PFX "FSB %d is out of range!\n", fsb); | 177 | pr_err("FSB %d is out of range!\n", fsb); |
| 178 | return -EINVAL; | 178 | return -EINVAL; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | tfsb = nforce2_fsb_read(0); | 181 | tfsb = nforce2_fsb_read(0); |
| 182 | if (!tfsb) { | 182 | if (!tfsb) { |
| 183 | printk(KERN_ERR PFX "Error while reading the FSB\n"); | 183 | pr_err("Error while reading the FSB\n"); |
| 184 | return -EINVAL; | 184 | return -EINVAL; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| @@ -276,8 +276,7 @@ static int nforce2_target(struct cpufreq_policy *policy, | |||
| 276 | /* local_irq_save(flags); */ | 276 | /* local_irq_save(flags); */ |
| 277 | 277 | ||
| 278 | if (nforce2_set_fsb(target_fsb) < 0) | 278 | if (nforce2_set_fsb(target_fsb) < 0) |
| 279 | printk(KERN_ERR PFX "Changing FSB to %d failed\n", | 279 | pr_err("Changing FSB to %d failed\n", target_fsb); |
| 280 | target_fsb); | ||
| 281 | else | 280 | else |
| 282 | pr_debug("Changed FSB successfully to %d\n", | 281 | pr_debug("Changed FSB successfully to %d\n", |
| 283 | target_fsb); | 282 | target_fsb); |
| @@ -325,8 +324,7 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy) | |||
| 325 | /* FIX: Get FID from CPU */ | 324 | /* FIX: Get FID from CPU */ |
| 326 | if (!fid) { | 325 | if (!fid) { |
| 327 | if (!cpu_khz) { | 326 | if (!cpu_khz) { |
| 328 | printk(KERN_WARNING PFX | 327 | pr_warn("cpu_khz not set, can't calculate multiplier!\n"); |
| 329 | "cpu_khz not set, can't calculate multiplier!\n"); | ||
| 330 | return -ENODEV; | 328 | return -ENODEV; |
| 331 | } | 329 | } |
| 332 | 330 | ||
| @@ -341,8 +339,8 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy) | |||
| 341 | } | 339 | } |
| 342 | } | 340 | } |
| 343 | 341 | ||
| 344 | printk(KERN_INFO PFX "FSB currently at %i MHz, FID %d.%d\n", fsb, | 342 | pr_info("FSB currently at %i MHz, FID %d.%d\n", |
| 345 | fid / 10, fid % 10); | 343 | fsb, fid / 10, fid % 10); |
| 346 | 344 | ||
| 347 | /* Set maximum FSB to FSB at boot time */ | 345 | /* Set maximum FSB to FSB at boot time */ |
| 348 | max_fsb = nforce2_fsb_read(1); | 346 | max_fsb = nforce2_fsb_read(1); |
| @@ -401,11 +399,9 @@ static int nforce2_detect_chipset(void) | |||
| 401 | if (nforce2_dev == NULL) | 399 | if (nforce2_dev == NULL) |
| 402 | return -ENODEV; | 400 | return -ENODEV; |
| 403 | 401 | ||
| 404 | printk(KERN_INFO PFX "Detected nForce2 chipset revision %X\n", | 402 | pr_info("Detected nForce2 chipset revision %X\n", |
| 405 | nforce2_dev->revision); | 403 | nforce2_dev->revision); |
| 406 | printk(KERN_INFO PFX | 404 | pr_info("FSB changing is maybe unstable and can lead to crashes and data loss\n"); |
| 407 | "FSB changing is maybe unstable and can lead to " | ||
| 408 | "crashes and data loss.\n"); | ||
| 409 | 405 | ||
| 410 | return 0; | 406 | return 0; |
| 411 | } | 407 | } |
| @@ -423,7 +419,7 @@ static int __init nforce2_init(void) | |||
| 423 | 419 | ||
| 424 | /* detect chipset */ | 420 | /* detect chipset */ |
| 425 | if (nforce2_detect_chipset()) { | 421 | if (nforce2_detect_chipset()) { |
| 426 | printk(KERN_INFO PFX "No nForce2 chipset.\n"); | 422 | pr_info("No nForce2 chipset\n"); |
| 427 | return -ENODEV; | 423 | return -ENODEV; |
| 428 | } | 424 | } |
| 429 | 425 | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index c4acfc5273b3..035513b012ee 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
| @@ -78,6 +78,11 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); | |||
| 78 | static unsigned int __cpufreq_get(struct cpufreq_policy *policy); | 78 | static unsigned int __cpufreq_get(struct cpufreq_policy *policy); |
| 79 | static int cpufreq_start_governor(struct cpufreq_policy *policy); | 79 | static int cpufreq_start_governor(struct cpufreq_policy *policy); |
| 80 | 80 | ||
| 81 | static inline int cpufreq_exit_governor(struct cpufreq_policy *policy) | ||
| 82 | { | ||
| 83 | return cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); | ||
| 84 | } | ||
| 85 | |||
| 81 | /** | 86 | /** |
| 82 | * Two notifier lists: the "policy" list is involved in the | 87 | * Two notifier lists: the "policy" list is involved in the |
| 83 | * validation process for a new CPU frequency policy; the | 88 | * validation process for a new CPU frequency policy; the |
| @@ -429,6 +434,73 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, | |||
| 429 | } | 434 | } |
| 430 | EXPORT_SYMBOL_GPL(cpufreq_freq_transition_end); | 435 | EXPORT_SYMBOL_GPL(cpufreq_freq_transition_end); |
| 431 | 436 | ||
| 437 | /* | ||
| 438 | * Fast frequency switching status count. Positive means "enabled", negative | ||
| 439 | * means "disabled" and 0 means "not decided yet". | ||
| 440 | */ | ||
| 441 | static int cpufreq_fast_switch_count; | ||
| 442 | static DEFINE_MUTEX(cpufreq_fast_switch_lock); | ||
| 443 | |||
| 444 | static void cpufreq_list_transition_notifiers(void) | ||
| 445 | { | ||
| 446 | struct notifier_block *nb; | ||
| 447 | |||
| 448 | pr_info("Registered transition notifiers:\n"); | ||
| 449 | |||
| 450 | mutex_lock(&cpufreq_transition_notifier_list.mutex); | ||
| 451 | |||
| 452 | for (nb = cpufreq_transition_notifier_list.head; nb; nb = nb->next) | ||
| 453 | pr_info("%pF\n", nb->notifier_call); | ||
| 454 | |||
| 455 | mutex_unlock(&cpufreq_transition_notifier_list.mutex); | ||
| 456 | } | ||
| 457 | |||
| 458 | /** | ||
| 459 | * cpufreq_enable_fast_switch - Enable fast frequency switching for policy. | ||
| 460 | * @policy: cpufreq policy to enable fast frequency switching for. | ||
| 461 | * | ||
| 462 | * Try to enable fast frequency switching for @policy. | ||
| 463 | * | ||
| 464 | * The attempt will fail if there is at least one transition notifier registered | ||
| 465 | * at this point, as fast frequency switching is quite fundamentally at odds | ||
| 466 | * with transition notifiers. Thus if successful, it will make registration of | ||
| 467 | * transition notifiers fail going forward. | ||
| 468 | */ | ||
| 469 | void cpufreq_enable_fast_switch(struct cpufreq_policy *policy) | ||
| 470 | { | ||
| 471 | lockdep_assert_held(&policy->rwsem); | ||
| 472 | |||
| 473 | if (!policy->fast_switch_possible) | ||
| 474 | return; | ||
| 475 | |||
| 476 | mutex_lock(&cpufreq_fast_switch_lock); | ||
| 477 | if (cpufreq_fast_switch_count >= 0) { | ||
| 478 | cpufreq_fast_switch_count++; | ||
| 479 | policy->fast_switch_enabled = true; | ||
| 480 | } else { | ||
| 481 | pr_warn("CPU%u: Fast frequency switching not enabled\n", | ||
| 482 | policy->cpu); | ||
| 483 | cpufreq_list_transition_notifiers(); | ||
| 484 | } | ||
| 485 | mutex_unlock(&cpufreq_fast_switch_lock); | ||
| 486 | } | ||
| 487 | EXPORT_SYMBOL_GPL(cpufreq_enable_fast_switch); | ||
| 488 | |||
| 489 | /** | ||
| 490 | * cpufreq_disable_fast_switch - Disable fast frequency switching for policy. | ||
| 491 | * @policy: cpufreq policy to disable fast frequency switching for. | ||
| 492 | */ | ||
| 493 | void cpufreq_disable_fast_switch(struct cpufreq_policy *policy) | ||
| 494 | { | ||
| 495 | mutex_lock(&cpufreq_fast_switch_lock); | ||
| 496 | if (policy->fast_switch_enabled) { | ||
| 497 | policy->fast_switch_enabled = false; | ||
| 498 | if (!WARN_ON(cpufreq_fast_switch_count <= 0)) | ||
| 499 | cpufreq_fast_switch_count--; | ||
| 500 | } | ||
| 501 | mutex_unlock(&cpufreq_fast_switch_lock); | ||
| 502 | } | ||
| 503 | EXPORT_SYMBOL_GPL(cpufreq_disable_fast_switch); | ||
| 432 | 504 | ||
| 433 | /********************************************************************* | 505 | /********************************************************************* |
| 434 | * SYSFS INTERFACE * | 506 | * SYSFS INTERFACE * |
| @@ -1248,26 +1320,24 @@ out_free_policy: | |||
| 1248 | */ | 1320 | */ |
| 1249 | static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | 1321 | static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) |
| 1250 | { | 1322 | { |
| 1323 | struct cpufreq_policy *policy; | ||
| 1251 | unsigned cpu = dev->id; | 1324 | unsigned cpu = dev->id; |
| 1252 | int ret; | ||
| 1253 | 1325 | ||
| 1254 | dev_dbg(dev, "%s: adding CPU%u\n", __func__, cpu); | 1326 | dev_dbg(dev, "%s: adding CPU%u\n", __func__, cpu); |
| 1255 | 1327 | ||
| 1256 | if (cpu_online(cpu)) { | 1328 | if (cpu_online(cpu)) |
| 1257 | ret = cpufreq_online(cpu); | 1329 | return cpufreq_online(cpu); |
| 1258 | } else { | ||
| 1259 | /* | ||
| 1260 | * A hotplug notifier will follow and we will handle it as CPU | ||
| 1261 | * online then. For now, just create the sysfs link, unless | ||
| 1262 | * there is no policy or the link is already present. | ||
| 1263 | */ | ||
| 1264 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); | ||
| 1265 | 1330 | ||
| 1266 | ret = policy && !cpumask_test_and_set_cpu(cpu, policy->real_cpus) | 1331 | /* |
| 1267 | ? add_cpu_dev_symlink(policy, cpu) : 0; | 1332 | * A hotplug notifier will follow and we will handle it as CPU online |
| 1268 | } | 1333 | * then. For now, just create the sysfs link, unless there is no policy |
| 1334 | * or the link is already present. | ||
| 1335 | */ | ||
| 1336 | policy = per_cpu(cpufreq_cpu_data, cpu); | ||
| 1337 | if (!policy || cpumask_test_and_set_cpu(cpu, policy->real_cpus)) | ||
| 1338 | return 0; | ||
| 1269 | 1339 | ||
| 1270 | return ret; | 1340 | return add_cpu_dev_symlink(policy, cpu); |
| 1271 | } | 1341 | } |
| 1272 | 1342 | ||
| 1273 | static void cpufreq_offline(unsigned int cpu) | 1343 | static void cpufreq_offline(unsigned int cpu) |
| @@ -1319,7 +1389,7 @@ static void cpufreq_offline(unsigned int cpu) | |||
| 1319 | 1389 | ||
| 1320 | /* If cpu is last user of policy, free policy */ | 1390 | /* If cpu is last user of policy, free policy */ |
| 1321 | if (has_target()) { | 1391 | if (has_target()) { |
| 1322 | ret = cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); | 1392 | ret = cpufreq_exit_governor(policy); |
| 1323 | if (ret) | 1393 | if (ret) |
| 1324 | pr_err("%s: Failed to exit governor\n", __func__); | 1394 | pr_err("%s: Failed to exit governor\n", __func__); |
| 1325 | } | 1395 | } |
| @@ -1447,8 +1517,12 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy) | |||
| 1447 | 1517 | ||
| 1448 | ret_freq = cpufreq_driver->get(policy->cpu); | 1518 | ret_freq = cpufreq_driver->get(policy->cpu); |
| 1449 | 1519 | ||
| 1450 | /* Updating inactive policies is invalid, so avoid doing that. */ | 1520 | /* |
| 1451 | if (unlikely(policy_is_inactive(policy))) | 1521 | * Updating inactive policies is invalid, so avoid doing that. Also |
| 1522 | * if fast frequency switching is used with the given policy, the check | ||
| 1523 | * against policy->cur is pointless, so skip it in that case too. | ||
| 1524 | */ | ||
| 1525 | if (unlikely(policy_is_inactive(policy)) || policy->fast_switch_enabled) | ||
| 1452 | return ret_freq; | 1526 | return ret_freq; |
| 1453 | 1527 | ||
| 1454 | if (ret_freq && policy->cur && | 1528 | if (ret_freq && policy->cur && |
| @@ -1679,8 +1753,18 @@ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list) | |||
| 1679 | 1753 | ||
| 1680 | switch (list) { | 1754 | switch (list) { |
| 1681 | case CPUFREQ_TRANSITION_NOTIFIER: | 1755 | case CPUFREQ_TRANSITION_NOTIFIER: |
| 1756 | mutex_lock(&cpufreq_fast_switch_lock); | ||
| 1757 | |||
| 1758 | if (cpufreq_fast_switch_count > 0) { | ||
| 1759 | mutex_unlock(&cpufreq_fast_switch_lock); | ||
| 1760 | return -EBUSY; | ||
| 1761 | } | ||
| 1682 | ret = srcu_notifier_chain_register( | 1762 | ret = srcu_notifier_chain_register( |
| 1683 | &cpufreq_transition_notifier_list, nb); | 1763 | &cpufreq_transition_notifier_list, nb); |
| 1764 | if (!ret) | ||
| 1765 | cpufreq_fast_switch_count--; | ||
| 1766 | |||
| 1767 | mutex_unlock(&cpufreq_fast_switch_lock); | ||
| 1684 | break; | 1768 | break; |
| 1685 | case CPUFREQ_POLICY_NOTIFIER: | 1769 | case CPUFREQ_POLICY_NOTIFIER: |
| 1686 | ret = blocking_notifier_chain_register( | 1770 | ret = blocking_notifier_chain_register( |
| @@ -1713,8 +1797,14 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list) | |||
| 1713 | 1797 | ||
| 1714 | switch (list) { | 1798 | switch (list) { |
| 1715 | case CPUFREQ_TRANSITION_NOTIFIER: | 1799 | case CPUFREQ_TRANSITION_NOTIFIER: |
| 1800 | mutex_lock(&cpufreq_fast_switch_lock); | ||
| 1801 | |||
| 1716 | ret = srcu_notifier_chain_unregister( | 1802 | ret = srcu_notifier_chain_unregister( |
| 1717 | &cpufreq_transition_notifier_list, nb); | 1803 | &cpufreq_transition_notifier_list, nb); |
| 1804 | if (!ret && !WARN_ON(cpufreq_fast_switch_count >= 0)) | ||
| 1805 | cpufreq_fast_switch_count++; | ||
| 1806 | |||
| 1807 | mutex_unlock(&cpufreq_fast_switch_lock); | ||
| 1718 | break; | 1808 | break; |
| 1719 | case CPUFREQ_POLICY_NOTIFIER: | 1809 | case CPUFREQ_POLICY_NOTIFIER: |
| 1720 | ret = blocking_notifier_chain_unregister( | 1810 | ret = blocking_notifier_chain_unregister( |
| @@ -1733,6 +1823,37 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); | |||
| 1733 | * GOVERNORS * | 1823 | * GOVERNORS * |
| 1734 | *********************************************************************/ | 1824 | *********************************************************************/ |
| 1735 | 1825 | ||
| 1826 | /** | ||
| 1827 | * cpufreq_driver_fast_switch - Carry out a fast CPU frequency switch. | ||
| 1828 | * @policy: cpufreq policy to switch the frequency for. | ||
| 1829 | * @target_freq: New frequency to set (may be approximate). | ||
| 1830 | * | ||
| 1831 | * Carry out a fast frequency switch without sleeping. | ||
| 1832 | * | ||
| 1833 | * The driver's ->fast_switch() callback invoked by this function must be | ||
| 1834 | * suitable for being called from within RCU-sched read-side critical sections | ||
| 1835 | * and it is expected to select the minimum available frequency greater than or | ||
| 1836 | * equal to @target_freq (CPUFREQ_RELATION_L). | ||
| 1837 | * | ||
| 1838 | * This function must not be called if policy->fast_switch_enabled is unset. | ||
| 1839 | * | ||
| 1840 | * Governors calling this function must guarantee that it will never be invoked | ||
| 1841 | * twice in parallel for the same policy and that it will never be called in | ||
| 1842 | * parallel with either ->target() or ->target_index() for the same policy. | ||
| 1843 | * | ||
| 1844 | * If CPUFREQ_ENTRY_INVALID is returned by the driver's ->fast_switch() | ||
| 1845 | * callback to indicate an error condition, the hardware configuration must be | ||
| 1846 | * preserved. | ||
| 1847 | */ | ||
| 1848 | unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, | ||
| 1849 | unsigned int target_freq) | ||
| 1850 | { | ||
| 1851 | clamp_val(target_freq, policy->min, policy->max); | ||
| 1852 | |||
| 1853 | return cpufreq_driver->fast_switch(policy, target_freq); | ||
| 1854 | } | ||
| 1855 | EXPORT_SYMBOL_GPL(cpufreq_driver_fast_switch); | ||
| 1856 | |||
| 1736 | /* Must set freqs->new to intermediate frequency */ | 1857 | /* Must set freqs->new to intermediate frequency */ |
| 1737 | static int __target_intermediate(struct cpufreq_policy *policy, | 1858 | static int __target_intermediate(struct cpufreq_policy *policy, |
| 1738 | struct cpufreq_freqs *freqs, int index) | 1859 | struct cpufreq_freqs *freqs, int index) |
| @@ -2108,7 +2229,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
| 2108 | return ret; | 2229 | return ret; |
| 2109 | } | 2230 | } |
| 2110 | 2231 | ||
| 2111 | ret = cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); | 2232 | ret = cpufreq_exit_governor(policy); |
| 2112 | if (ret) { | 2233 | if (ret) { |
| 2113 | pr_err("%s: Failed to Exit Governor: %s (%d)\n", | 2234 | pr_err("%s: Failed to Exit Governor: %s (%d)\n", |
| 2114 | __func__, old_gov->name, ret); | 2235 | __func__, old_gov->name, ret); |
| @@ -2125,7 +2246,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, | |||
| 2125 | pr_debug("cpufreq: governor change\n"); | 2246 | pr_debug("cpufreq: governor change\n"); |
| 2126 | return 0; | 2247 | return 0; |
| 2127 | } | 2248 | } |
| 2128 | cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); | 2249 | cpufreq_exit_governor(policy); |
| 2129 | } | 2250 | } |
| 2130 | 2251 | ||
| 2131 | /* new governor failed, so re-start old one */ | 2252 | /* new governor failed, so re-start old one */ |
| @@ -2193,16 +2314,13 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, | |||
| 2193 | 2314 | ||
| 2194 | switch (action & ~CPU_TASKS_FROZEN) { | 2315 | switch (action & ~CPU_TASKS_FROZEN) { |
| 2195 | case CPU_ONLINE: | 2316 | case CPU_ONLINE: |
| 2317 | case CPU_DOWN_FAILED: | ||
| 2196 | cpufreq_online(cpu); | 2318 | cpufreq_online(cpu); |
| 2197 | break; | 2319 | break; |
| 2198 | 2320 | ||
| 2199 | case CPU_DOWN_PREPARE: | 2321 | case CPU_DOWN_PREPARE: |
| 2200 | cpufreq_offline(cpu); | 2322 | cpufreq_offline(cpu); |
| 2201 | break; | 2323 | break; |
| 2202 | |||
| 2203 | case CPU_DOWN_FAILED: | ||
| 2204 | cpufreq_online(cpu); | ||
| 2205 | break; | ||
| 2206 | } | 2324 | } |
| 2207 | return NOTIFY_OK; | 2325 | return NOTIFY_OK; |
| 2208 | } | 2326 | } |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index bf4913f6453b..316df247e00d 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
| @@ -129,9 +129,10 @@ static struct notifier_block cs_cpufreq_notifier_block = { | |||
| 129 | /************************** sysfs interface ************************/ | 129 | /************************** sysfs interface ************************/ |
| 130 | static struct dbs_governor cs_dbs_gov; | 130 | static struct dbs_governor cs_dbs_gov; |
| 131 | 131 | ||
| 132 | static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data, | 132 | static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, |
| 133 | const char *buf, size_t count) | 133 | const char *buf, size_t count) |
| 134 | { | 134 | { |
| 135 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 135 | unsigned int input; | 136 | unsigned int input; |
| 136 | int ret; | 137 | int ret; |
| 137 | ret = sscanf(buf, "%u", &input); | 138 | ret = sscanf(buf, "%u", &input); |
| @@ -143,9 +144,10 @@ static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data, | |||
| 143 | return count; | 144 | return count; |
| 144 | } | 145 | } |
| 145 | 146 | ||
| 146 | static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, | 147 | static ssize_t store_up_threshold(struct gov_attr_set *attr_set, |
| 147 | size_t count) | 148 | const char *buf, size_t count) |
| 148 | { | 149 | { |
| 150 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 149 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | 151 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; |
| 150 | unsigned int input; | 152 | unsigned int input; |
| 151 | int ret; | 153 | int ret; |
| @@ -158,9 +160,10 @@ static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, | |||
| 158 | return count; | 160 | return count; |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf, | 163 | static ssize_t store_down_threshold(struct gov_attr_set *attr_set, |
| 162 | size_t count) | 164 | const char *buf, size_t count) |
| 163 | { | 165 | { |
| 166 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 164 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | 167 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; |
| 165 | unsigned int input; | 168 | unsigned int input; |
| 166 | int ret; | 169 | int ret; |
| @@ -175,9 +178,10 @@ static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf, | |||
| 175 | return count; | 178 | return count; |
| 176 | } | 179 | } |
| 177 | 180 | ||
| 178 | static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data, | 181 | static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set, |
| 179 | const char *buf, size_t count) | 182 | const char *buf, size_t count) |
| 180 | { | 183 | { |
| 184 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 181 | unsigned int input; | 185 | unsigned int input; |
| 182 | int ret; | 186 | int ret; |
| 183 | 187 | ||
| @@ -199,9 +203,10 @@ static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data, | |||
| 199 | return count; | 203 | return count; |
| 200 | } | 204 | } |
| 201 | 205 | ||
| 202 | static ssize_t store_freq_step(struct dbs_data *dbs_data, const char *buf, | 206 | static ssize_t store_freq_step(struct gov_attr_set *attr_set, const char *buf, |
| 203 | size_t count) | 207 | size_t count) |
| 204 | { | 208 | { |
| 209 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 205 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | 210 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; |
| 206 | unsigned int input; | 211 | unsigned int input; |
| 207 | int ret; | 212 | int ret; |
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 5f1147fa9239..be498d56dd69 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
| @@ -43,9 +43,10 @@ static DEFINE_MUTEX(gov_dbs_data_mutex); | |||
| 43 | * This must be called with dbs_data->mutex held, otherwise traversing | 43 | * This must be called with dbs_data->mutex held, otherwise traversing |
| 44 | * policy_dbs_list isn't safe. | 44 | * policy_dbs_list isn't safe. |
| 45 | */ | 45 | */ |
| 46 | ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf, | 46 | ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf, |
| 47 | size_t count) | 47 | size_t count) |
| 48 | { | 48 | { |
| 49 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 49 | struct policy_dbs_info *policy_dbs; | 50 | struct policy_dbs_info *policy_dbs; |
| 50 | unsigned int rate; | 51 | unsigned int rate; |
| 51 | int ret; | 52 | int ret; |
| @@ -59,7 +60,7 @@ ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf, | |||
| 59 | * We are operating under dbs_data->mutex and so the list and its | 60 | * We are operating under dbs_data->mutex and so the list and its |
| 60 | * entries can't be freed concurrently. | 61 | * entries can't be freed concurrently. |
| 61 | */ | 62 | */ |
| 62 | list_for_each_entry(policy_dbs, &dbs_data->policy_dbs_list, list) { | 63 | list_for_each_entry(policy_dbs, &attr_set->policy_list, list) { |
| 63 | mutex_lock(&policy_dbs->timer_mutex); | 64 | mutex_lock(&policy_dbs->timer_mutex); |
| 64 | /* | 65 | /* |
| 65 | * On 32-bit architectures this may race with the | 66 | * On 32-bit architectures this may race with the |
| @@ -96,13 +97,13 @@ void gov_update_cpu_data(struct dbs_data *dbs_data) | |||
| 96 | { | 97 | { |
| 97 | struct policy_dbs_info *policy_dbs; | 98 | struct policy_dbs_info *policy_dbs; |
| 98 | 99 | ||
| 99 | list_for_each_entry(policy_dbs, &dbs_data->policy_dbs_list, list) { | 100 | list_for_each_entry(policy_dbs, &dbs_data->attr_set.policy_list, list) { |
| 100 | unsigned int j; | 101 | unsigned int j; |
| 101 | 102 | ||
| 102 | for_each_cpu(j, policy_dbs->policy->cpus) { | 103 | for_each_cpu(j, policy_dbs->policy->cpus) { |
| 103 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); | 104 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); |
| 104 | 105 | ||
| 105 | j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, &j_cdbs->prev_cpu_wall, | 106 | j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, &j_cdbs->prev_update_time, |
| 106 | dbs_data->io_is_busy); | 107 | dbs_data->io_is_busy); |
| 107 | if (dbs_data->ignore_nice_load) | 108 | if (dbs_data->ignore_nice_load) |
| 108 | j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; | 109 | j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
| @@ -111,54 +112,6 @@ void gov_update_cpu_data(struct dbs_data *dbs_data) | |||
| 111 | } | 112 | } |
| 112 | EXPORT_SYMBOL_GPL(gov_update_cpu_data); | 113 | EXPORT_SYMBOL_GPL(gov_update_cpu_data); |
| 113 | 114 | ||
| 114 | static inline struct dbs_data *to_dbs_data(struct kobject *kobj) | ||
| 115 | { | ||
| 116 | return container_of(kobj, struct dbs_data, kobj); | ||
| 117 | } | ||
| 118 | |||
| 119 | static inline struct governor_attr *to_gov_attr(struct attribute *attr) | ||
| 120 | { | ||
| 121 | return container_of(attr, struct governor_attr, attr); | ||
| 122 | } | ||
| 123 | |||
| 124 | static ssize_t governor_show(struct kobject *kobj, struct attribute *attr, | ||
| 125 | char *buf) | ||
| 126 | { | ||
| 127 | struct dbs_data *dbs_data = to_dbs_data(kobj); | ||
| 128 | struct governor_attr *gattr = to_gov_attr(attr); | ||
| 129 | |||
| 130 | return gattr->show(dbs_data, buf); | ||
| 131 | } | ||
| 132 | |||
| 133 | static ssize_t governor_store(struct kobject *kobj, struct attribute *attr, | ||
| 134 | const char *buf, size_t count) | ||
| 135 | { | ||
| 136 | struct dbs_data *dbs_data = to_dbs_data(kobj); | ||
| 137 | struct governor_attr *gattr = to_gov_attr(attr); | ||
| 138 | int ret = -EBUSY; | ||
| 139 | |||
| 140 | mutex_lock(&dbs_data->mutex); | ||
| 141 | |||
| 142 | if (dbs_data->usage_count) | ||
| 143 | ret = gattr->store(dbs_data, buf, count); | ||
| 144 | |||
| 145 | mutex_unlock(&dbs_data->mutex); | ||
| 146 | |||
| 147 | return ret; | ||
| 148 | } | ||
| 149 | |||
| 150 | /* | ||
| 151 | * Sysfs Ops for accessing governor attributes. | ||
| 152 | * | ||
| 153 | * All show/store invocations for governor specific sysfs attributes, will first | ||
| 154 | * call the below show/store callbacks and the attribute specific callback will | ||
| 155 | * be called from within it. | ||
| 156 | */ | ||
| 157 | static const struct sysfs_ops governor_sysfs_ops = { | ||
| 158 | .show = governor_show, | ||
| 159 | .store = governor_store, | ||
| 160 | }; | ||
| 161 | |||
| 162 | unsigned int dbs_update(struct cpufreq_policy *policy) | 115 | unsigned int dbs_update(struct cpufreq_policy *policy) |
| 163 | { | 116 | { |
| 164 | struct policy_dbs_info *policy_dbs = policy->governor_data; | 117 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
| @@ -184,14 +137,14 @@ unsigned int dbs_update(struct cpufreq_policy *policy) | |||
| 184 | /* Get Absolute Load */ | 137 | /* Get Absolute Load */ |
| 185 | for_each_cpu(j, policy->cpus) { | 138 | for_each_cpu(j, policy->cpus) { |
| 186 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); | 139 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); |
| 187 | u64 cur_wall_time, cur_idle_time; | 140 | u64 update_time, cur_idle_time; |
| 188 | unsigned int idle_time, wall_time; | 141 | unsigned int idle_time, time_elapsed; |
| 189 | unsigned int load; | 142 | unsigned int load; |
| 190 | 143 | ||
| 191 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time, io_busy); | 144 | cur_idle_time = get_cpu_idle_time(j, &update_time, io_busy); |
| 192 | 145 | ||
| 193 | wall_time = cur_wall_time - j_cdbs->prev_cpu_wall; | 146 | time_elapsed = update_time - j_cdbs->prev_update_time; |
| 194 | j_cdbs->prev_cpu_wall = cur_wall_time; | 147 | j_cdbs->prev_update_time = update_time; |
| 195 | 148 | ||
| 196 | idle_time = cur_idle_time - j_cdbs->prev_cpu_idle; | 149 | idle_time = cur_idle_time - j_cdbs->prev_cpu_idle; |
| 197 | j_cdbs->prev_cpu_idle = cur_idle_time; | 150 | j_cdbs->prev_cpu_idle = cur_idle_time; |
| @@ -203,47 +156,62 @@ unsigned int dbs_update(struct cpufreq_policy *policy) | |||
| 203 | j_cdbs->prev_cpu_nice = cur_nice; | 156 | j_cdbs->prev_cpu_nice = cur_nice; |
| 204 | } | 157 | } |
| 205 | 158 | ||
| 206 | if (unlikely(!wall_time || wall_time < idle_time)) | 159 | if (unlikely(!time_elapsed)) { |
| 207 | continue; | 160 | /* |
| 208 | 161 | * That can only happen when this function is called | |
| 209 | /* | 162 | * twice in a row with a very short interval between the |
| 210 | * If the CPU had gone completely idle, and a task just woke up | 163 | * calls, so the previous load value can be used then. |
| 211 | * on this CPU now, it would be unfair to calculate 'load' the | 164 | */ |
| 212 | * usual way for this elapsed time-window, because it will show | ||
| 213 | * near-zero load, irrespective of how CPU intensive that task | ||
| 214 | * actually is. This is undesirable for latency-sensitive bursty | ||
| 215 | * workloads. | ||
| 216 | * | ||
| 217 | * To avoid this, we reuse the 'load' from the previous | ||
| 218 | * time-window and give this task a chance to start with a | ||
| 219 | * reasonably high CPU frequency. (However, we shouldn't over-do | ||
| 220 | * this copy, lest we get stuck at a high load (high frequency) | ||
| 221 | * for too long, even when the current system load has actually | ||
| 222 | * dropped down. So we perform the copy only once, upon the | ||
| 223 | * first wake-up from idle.) | ||
| 224 | * | ||
| 225 | * Detecting this situation is easy: the governor's utilization | ||
| 226 | * update handler would not have run during CPU-idle periods. | ||
| 227 | * Hence, an unusually large 'wall_time' (as compared to the | ||
| 228 | * sampling rate) indicates this scenario. | ||
| 229 | * | ||
| 230 | * prev_load can be zero in two cases and we must recalculate it | ||
| 231 | * for both cases: | ||
| 232 | * - during long idle intervals | ||
| 233 | * - explicitly set to zero | ||
| 234 | */ | ||
| 235 | if (unlikely(wall_time > (2 * sampling_rate) && | ||
| 236 | j_cdbs->prev_load)) { | ||
| 237 | load = j_cdbs->prev_load; | 165 | load = j_cdbs->prev_load; |
| 238 | 166 | } else if (unlikely(time_elapsed > 2 * sampling_rate && | |
| 167 | j_cdbs->prev_load)) { | ||
| 239 | /* | 168 | /* |
| 240 | * Perform a destructive copy, to ensure that we copy | 169 | * If the CPU had gone completely idle and a task has |
| 241 | * the previous load only once, upon the first wake-up | 170 | * just woken up on this CPU now, it would be unfair to |
| 242 | * from idle. | 171 | * calculate 'load' the usual way for this elapsed |
| 172 | * time-window, because it would show near-zero load, | ||
| 173 | * irrespective of how CPU intensive that task actually | ||
| 174 | * was. This is undesirable for latency-sensitive bursty | ||
| 175 | * workloads. | ||
| 176 | * | ||
| 177 | * To avoid this, reuse the 'load' from the previous | ||
| 178 | * time-window and give this task a chance to start with | ||
| 179 | * a reasonably high CPU frequency. However, that | ||
| 180 | * shouldn't be over-done, lest we get stuck at a high | ||
| 181 | * load (high frequency) for too long, even when the | ||
| 182 | * current system load has actually dropped down, so | ||
| 183 | * clear prev_load to guarantee that the load will be | ||
| 184 | * computed again next time. | ||
| 185 | * | ||
| 186 | * Detecting this situation is easy: the governor's | ||
| 187 | * utilization update handler would not have run during | ||
| 188 | * CPU-idle periods. Hence, an unusually large | ||
| 189 | * 'time_elapsed' (as compared to the sampling rate) | ||
| 190 | * indicates this scenario. | ||
| 243 | */ | 191 | */ |
| 192 | load = j_cdbs->prev_load; | ||
| 244 | j_cdbs->prev_load = 0; | 193 | j_cdbs->prev_load = 0; |
| 245 | } else { | 194 | } else { |
| 246 | load = 100 * (wall_time - idle_time) / wall_time; | 195 | if (time_elapsed >= idle_time) { |
| 196 | load = 100 * (time_elapsed - idle_time) / time_elapsed; | ||
| 197 | } else { | ||
| 198 | /* | ||
| 199 | * That can happen if idle_time is returned by | ||
| 200 | * get_cpu_idle_time_jiffy(). In that case | ||
| 201 | * idle_time is roughly equal to the difference | ||
| 202 | * between time_elapsed and "busy time" obtained | ||
| 203 | * from CPU statistics. Then, the "busy time" | ||
| 204 | * can end up being greater than time_elapsed | ||
| 205 | * (for example, if jiffies_64 and the CPU | ||
| 206 | * statistics are updated by different CPUs), | ||
| 207 | * so idle_time may in fact be negative. That | ||
| 208 | * means, though, that the CPU was busy all | ||
| 209 | * the time (on the rough average) during the | ||
| 210 | * last sampling interval and 100 can be | ||
| 211 | * returned as the load. | ||
| 212 | */ | ||
| 213 | load = (int)idle_time < 0 ? 100 : 0; | ||
| 214 | } | ||
| 247 | j_cdbs->prev_load = load; | 215 | j_cdbs->prev_load = load; |
| 248 | } | 216 | } |
| 249 | 217 | ||
| @@ -254,43 +222,6 @@ unsigned int dbs_update(struct cpufreq_policy *policy) | |||
| 254 | } | 222 | } |
| 255 | EXPORT_SYMBOL_GPL(dbs_update); | 223 | EXPORT_SYMBOL_GPL(dbs_update); |
| 256 | 224 | ||
| 257 | static void gov_set_update_util(struct policy_dbs_info *policy_dbs, | ||
| 258 | unsigned int delay_us) | ||
| 259 | { | ||
| 260 | struct cpufreq_policy *policy = policy_dbs->policy; | ||
| 261 | int cpu; | ||
| 262 | |||
| 263 | gov_update_sample_delay(policy_dbs, delay_us); | ||
| 264 | policy_dbs->last_sample_time = 0; | ||
| 265 | |||
| 266 | for_each_cpu(cpu, policy->cpus) { | ||
| 267 | struct cpu_dbs_info *cdbs = &per_cpu(cpu_dbs, cpu); | ||
| 268 | |||
| 269 | cpufreq_set_update_util_data(cpu, &cdbs->update_util); | ||
| 270 | } | ||
| 271 | } | ||
| 272 | |||
| 273 | static inline void gov_clear_update_util(struct cpufreq_policy *policy) | ||
| 274 | { | ||
| 275 | int i; | ||
| 276 | |||
| 277 | for_each_cpu(i, policy->cpus) | ||
| 278 | cpufreq_set_update_util_data(i, NULL); | ||
| 279 | |||
| 280 | synchronize_sched(); | ||
| 281 | } | ||
| 282 | |||
| 283 | static void gov_cancel_work(struct cpufreq_policy *policy) | ||
| 284 | { | ||
| 285 | struct policy_dbs_info *policy_dbs = policy->governor_data; | ||
| 286 | |||
| 287 | gov_clear_update_util(policy_dbs->policy); | ||
| 288 | irq_work_sync(&policy_dbs->irq_work); | ||
| 289 | cancel_work_sync(&policy_dbs->work); | ||
| 290 | atomic_set(&policy_dbs->work_count, 0); | ||
| 291 | policy_dbs->work_in_progress = false; | ||
| 292 | } | ||
| 293 | |||
| 294 | static void dbs_work_handler(struct work_struct *work) | 225 | static void dbs_work_handler(struct work_struct *work) |
| 295 | { | 226 | { |
| 296 | struct policy_dbs_info *policy_dbs; | 227 | struct policy_dbs_info *policy_dbs; |
| @@ -378,6 +309,44 @@ static void dbs_update_util_handler(struct update_util_data *data, u64 time, | |||
| 378 | irq_work_queue(&policy_dbs->irq_work); | 309 | irq_work_queue(&policy_dbs->irq_work); |
| 379 | } | 310 | } |
| 380 | 311 | ||
| 312 | static void gov_set_update_util(struct policy_dbs_info *policy_dbs, | ||
| 313 | unsigned int delay_us) | ||
| 314 | { | ||
| 315 | struct cpufreq_policy *policy = policy_dbs->policy; | ||
| 316 | int cpu; | ||
| 317 | |||
| 318 | gov_update_sample_delay(policy_dbs, delay_us); | ||
| 319 | policy_dbs->last_sample_time = 0; | ||
| 320 | |||
| 321 | for_each_cpu(cpu, policy->cpus) { | ||
| 322 | struct cpu_dbs_info *cdbs = &per_cpu(cpu_dbs, cpu); | ||
| 323 | |||
| 324 | cpufreq_add_update_util_hook(cpu, &cdbs->update_util, | ||
| 325 | dbs_update_util_handler); | ||
| 326 | } | ||
| 327 | } | ||
| 328 | |||
| 329 | static inline void gov_clear_update_util(struct cpufreq_policy *policy) | ||
| 330 | { | ||
| 331 | int i; | ||
| 332 | |||
| 333 | for_each_cpu(i, policy->cpus) | ||
| 334 | cpufreq_remove_update_util_hook(i); | ||
| 335 | |||
| 336 | synchronize_sched(); | ||
| 337 | } | ||
| 338 | |||
| 339 | static void gov_cancel_work(struct cpufreq_policy *policy) | ||
| 340 | { | ||
| 341 | struct policy_dbs_info *policy_dbs = policy->governor_data; | ||
| 342 | |||
| 343 | gov_clear_update_util(policy_dbs->policy); | ||
| 344 | irq_work_sync(&policy_dbs->irq_work); | ||
| 345 | cancel_work_sync(&policy_dbs->work); | ||
| 346 | atomic_set(&policy_dbs->work_count, 0); | ||
| 347 | policy_dbs->work_in_progress = false; | ||
| 348 | } | ||
| 349 | |||
| 381 | static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *policy, | 350 | static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *policy, |
| 382 | struct dbs_governor *gov) | 351 | struct dbs_governor *gov) |
| 383 | { | 352 | { |
| @@ -400,7 +369,6 @@ static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *poli | |||
| 400 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); | 369 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); |
| 401 | 370 | ||
| 402 | j_cdbs->policy_dbs = policy_dbs; | 371 | j_cdbs->policy_dbs = policy_dbs; |
| 403 | j_cdbs->update_util.func = dbs_update_util_handler; | ||
| 404 | } | 372 | } |
| 405 | return policy_dbs; | 373 | return policy_dbs; |
| 406 | } | 374 | } |
| @@ -449,10 +417,7 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy) | |||
| 449 | policy_dbs->dbs_data = dbs_data; | 417 | policy_dbs->dbs_data = dbs_data; |
| 450 | policy->governor_data = policy_dbs; | 418 | policy->governor_data = policy_dbs; |
| 451 | 419 | ||
| 452 | mutex_lock(&dbs_data->mutex); | 420 | gov_attr_set_get(&dbs_data->attr_set, &policy_dbs->list); |
| 453 | dbs_data->usage_count++; | ||
| 454 | list_add(&policy_dbs->list, &dbs_data->policy_dbs_list); | ||
| 455 | mutex_unlock(&dbs_data->mutex); | ||
| 456 | goto out; | 421 | goto out; |
| 457 | } | 422 | } |
| 458 | 423 | ||
| @@ -462,8 +427,7 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy) | |||
| 462 | goto free_policy_dbs_info; | 427 | goto free_policy_dbs_info; |
| 463 | } | 428 | } |
| 464 | 429 | ||
| 465 | INIT_LIST_HEAD(&dbs_data->policy_dbs_list); | 430 | gov_attr_set_init(&dbs_data->attr_set, &policy_dbs->list); |
| 466 | mutex_init(&dbs_data->mutex); | ||
| 467 | 431 | ||
| 468 | ret = gov->init(dbs_data, !policy->governor->initialized); | 432 | ret = gov->init(dbs_data, !policy->governor->initialized); |
| 469 | if (ret) | 433 | if (ret) |
| @@ -483,14 +447,11 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy) | |||
| 483 | if (!have_governor_per_policy()) | 447 | if (!have_governor_per_policy()) |
| 484 | gov->gdbs_data = dbs_data; | 448 | gov->gdbs_data = dbs_data; |
| 485 | 449 | ||
| 486 | policy->governor_data = policy_dbs; | ||
| 487 | |||
| 488 | policy_dbs->dbs_data = dbs_data; | 450 | policy_dbs->dbs_data = dbs_data; |
| 489 | dbs_data->usage_count = 1; | 451 | policy->governor_data = policy_dbs; |
| 490 | list_add(&policy_dbs->list, &dbs_data->policy_dbs_list); | ||
| 491 | 452 | ||
| 492 | gov->kobj_type.sysfs_ops = &governor_sysfs_ops; | 453 | gov->kobj_type.sysfs_ops = &governor_sysfs_ops; |
| 493 | ret = kobject_init_and_add(&dbs_data->kobj, &gov->kobj_type, | 454 | ret = kobject_init_and_add(&dbs_data->attr_set.kobj, &gov->kobj_type, |
| 494 | get_governor_parent_kobj(policy), | 455 | get_governor_parent_kobj(policy), |
| 495 | "%s", gov->gov.name); | 456 | "%s", gov->gov.name); |
| 496 | if (!ret) | 457 | if (!ret) |
| @@ -519,29 +480,21 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy) | |||
| 519 | struct dbs_governor *gov = dbs_governor_of(policy); | 480 | struct dbs_governor *gov = dbs_governor_of(policy); |
| 520 | struct policy_dbs_info *policy_dbs = policy->governor_data; | 481 | struct policy_dbs_info *policy_dbs = policy->governor_data; |
| 521 | struct dbs_data *dbs_data = policy_dbs->dbs_data; | 482 | struct dbs_data *dbs_data = policy_dbs->dbs_data; |
| 522 | int count; | 483 | unsigned int count; |
| 523 | 484 | ||
| 524 | /* Protect gov->gdbs_data against concurrent updates. */ | 485 | /* Protect gov->gdbs_data against concurrent updates. */ |
| 525 | mutex_lock(&gov_dbs_data_mutex); | 486 | mutex_lock(&gov_dbs_data_mutex); |
| 526 | 487 | ||
| 527 | mutex_lock(&dbs_data->mutex); | 488 | count = gov_attr_set_put(&dbs_data->attr_set, &policy_dbs->list); |
| 528 | list_del(&policy_dbs->list); | ||
| 529 | count = --dbs_data->usage_count; | ||
| 530 | mutex_unlock(&dbs_data->mutex); | ||
| 531 | 489 | ||
| 532 | if (!count) { | 490 | policy->governor_data = NULL; |
| 533 | kobject_put(&dbs_data->kobj); | ||
| 534 | |||
| 535 | policy->governor_data = NULL; | ||
| 536 | 491 | ||
| 492 | if (!count) { | ||
| 537 | if (!have_governor_per_policy()) | 493 | if (!have_governor_per_policy()) |
| 538 | gov->gdbs_data = NULL; | 494 | gov->gdbs_data = NULL; |
| 539 | 495 | ||
| 540 | gov->exit(dbs_data, policy->governor->initialized == 1); | 496 | gov->exit(dbs_data, policy->governor->initialized == 1); |
| 541 | mutex_destroy(&dbs_data->mutex); | ||
| 542 | kfree(dbs_data); | 497 | kfree(dbs_data); |
| 543 | } else { | ||
| 544 | policy->governor_data = NULL; | ||
| 545 | } | 498 | } |
| 546 | 499 | ||
| 547 | free_policy_dbs_info(policy_dbs, gov); | 500 | free_policy_dbs_info(policy_dbs, gov); |
| @@ -570,12 +523,12 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy) | |||
| 570 | 523 | ||
| 571 | for_each_cpu(j, policy->cpus) { | 524 | for_each_cpu(j, policy->cpus) { |
| 572 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); | 525 | struct cpu_dbs_info *j_cdbs = &per_cpu(cpu_dbs, j); |
| 573 | unsigned int prev_load; | ||
| 574 | 526 | ||
| 575 | j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, &j_cdbs->prev_cpu_wall, io_busy); | 527 | j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, &j_cdbs->prev_update_time, io_busy); |
| 576 | 528 | /* | |
| 577 | prev_load = j_cdbs->prev_cpu_wall - j_cdbs->prev_cpu_idle; | 529 | * Make the first invocation of dbs_update() compute the load. |
| 578 | j_cdbs->prev_load = 100 * prev_load / (unsigned int)j_cdbs->prev_cpu_wall; | 530 | */ |
| 531 | j_cdbs->prev_load = 0; | ||
| 579 | 532 | ||
| 580 | if (ignore_nice) | 533 | if (ignore_nice) |
| 581 | j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; | 534 | j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index 61ff82fe0613..34eb214b6d57 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
| @@ -24,20 +24,6 @@ | |||
| 24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
| 26 | 26 | ||
| 27 | /* | ||
| 28 | * The polling frequency depends on the capability of the processor. Default | ||
| 29 | * polling frequency is 1000 times the transition latency of the processor. The | ||
| 30 | * governor will work on any processor with transition latency <= 10ms, using | ||
| 31 | * appropriate sampling rate. | ||
| 32 | * | ||
| 33 | * For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL) | ||
| 34 | * this governor will not work. All times here are in us (micro seconds). | ||
| 35 | */ | ||
| 36 | #define MIN_SAMPLING_RATE_RATIO (2) | ||
| 37 | #define LATENCY_MULTIPLIER (1000) | ||
| 38 | #define MIN_LATENCY_MULTIPLIER (20) | ||
| 39 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) | ||
| 40 | |||
| 41 | /* Ondemand Sampling types */ | 27 | /* Ondemand Sampling types */ |
| 42 | enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE}; | 28 | enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE}; |
| 43 | 29 | ||
| @@ -52,7 +38,7 @@ enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE}; | |||
| 52 | 38 | ||
| 53 | /* Governor demand based switching data (per-policy or global). */ | 39 | /* Governor demand based switching data (per-policy or global). */ |
| 54 | struct dbs_data { | 40 | struct dbs_data { |
| 55 | int usage_count; | 41 | struct gov_attr_set attr_set; |
| 56 | void *tuners; | 42 | void *tuners; |
| 57 | unsigned int min_sampling_rate; | 43 | unsigned int min_sampling_rate; |
| 58 | unsigned int ignore_nice_load; | 44 | unsigned int ignore_nice_load; |
| @@ -60,37 +46,27 @@ struct dbs_data { | |||
| 60 | unsigned int sampling_down_factor; | 46 | unsigned int sampling_down_factor; |
| 61 | unsigned int up_threshold; | 47 | unsigned int up_threshold; |
| 62 | unsigned int io_is_busy; | 48 | unsigned int io_is_busy; |
| 63 | |||
| 64 | struct kobject kobj; | ||
| 65 | struct list_head policy_dbs_list; | ||
| 66 | /* | ||
| 67 | * Protect concurrent updates to governor tunables from sysfs, | ||
| 68 | * policy_dbs_list and usage_count. | ||
| 69 | */ | ||
| 70 | struct mutex mutex; | ||
| 71 | }; | 49 | }; |
| 72 | 50 | ||
| 73 | /* Governor's specific attributes */ | 51 | static inline struct dbs_data *to_dbs_data(struct gov_attr_set *attr_set) |
| 74 | struct dbs_data; | 52 | { |
| 75 | struct governor_attr { | 53 | return container_of(attr_set, struct dbs_data, attr_set); |
| 76 | struct attribute attr; | 54 | } |
| 77 | ssize_t (*show)(struct dbs_data *dbs_data, char *buf); | ||
| 78 | ssize_t (*store)(struct dbs_data *dbs_data, const char *buf, | ||
| 79 | size_t count); | ||
| 80 | }; | ||
| 81 | 55 | ||
| 82 | #define gov_show_one(_gov, file_name) \ | 56 | #define gov_show_one(_gov, file_name) \ |
| 83 | static ssize_t show_##file_name \ | 57 | static ssize_t show_##file_name \ |
| 84 | (struct dbs_data *dbs_data, char *buf) \ | 58 | (struct gov_attr_set *attr_set, char *buf) \ |
| 85 | { \ | 59 | { \ |
| 60 | struct dbs_data *dbs_data = to_dbs_data(attr_set); \ | ||
| 86 | struct _gov##_dbs_tuners *tuners = dbs_data->tuners; \ | 61 | struct _gov##_dbs_tuners *tuners = dbs_data->tuners; \ |
| 87 | return sprintf(buf, "%u\n", tuners->file_name); \ | 62 | return sprintf(buf, "%u\n", tuners->file_name); \ |
| 88 | } | 63 | } |
| 89 | 64 | ||
| 90 | #define gov_show_one_common(file_name) \ | 65 | #define gov_show_one_common(file_name) \ |
| 91 | static ssize_t show_##file_name \ | 66 | static ssize_t show_##file_name \ |
| 92 | (struct dbs_data *dbs_data, char *buf) \ | 67 | (struct gov_attr_set *attr_set, char *buf) \ |
| 93 | { \ | 68 | { \ |
| 69 | struct dbs_data *dbs_data = to_dbs_data(attr_set); \ | ||
| 94 | return sprintf(buf, "%u\n", dbs_data->file_name); \ | 70 | return sprintf(buf, "%u\n", dbs_data->file_name); \ |
| 95 | } | 71 | } |
| 96 | 72 | ||
| @@ -135,7 +111,7 @@ static inline void gov_update_sample_delay(struct policy_dbs_info *policy_dbs, | |||
| 135 | /* Per cpu structures */ | 111 | /* Per cpu structures */ |
| 136 | struct cpu_dbs_info { | 112 | struct cpu_dbs_info { |
| 137 | u64 prev_cpu_idle; | 113 | u64 prev_cpu_idle; |
| 138 | u64 prev_cpu_wall; | 114 | u64 prev_update_time; |
| 139 | u64 prev_cpu_nice; | 115 | u64 prev_cpu_nice; |
| 140 | /* | 116 | /* |
| 141 | * Used to keep track of load in the previous interval. However, when | 117 | * Used to keep track of load in the previous interval. However, when |
| @@ -184,7 +160,7 @@ void od_register_powersave_bias_handler(unsigned int (*f) | |||
| 184 | (struct cpufreq_policy *, unsigned int, unsigned int), | 160 | (struct cpufreq_policy *, unsigned int, unsigned int), |
| 185 | unsigned int powersave_bias); | 161 | unsigned int powersave_bias); |
| 186 | void od_unregister_powersave_bias_handler(void); | 162 | void od_unregister_powersave_bias_handler(void); |
| 187 | ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf, | 163 | ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf, |
| 188 | size_t count); | 164 | size_t count); |
| 189 | void gov_update_cpu_data(struct dbs_data *dbs_data); | 165 | void gov_update_cpu_data(struct dbs_data *dbs_data); |
| 190 | #endif /* _CPUFREQ_GOVERNOR_H */ | 166 | #endif /* _CPUFREQ_GOVERNOR_H */ |
diff --git a/drivers/cpufreq/cpufreq_governor_attr_set.c b/drivers/cpufreq/cpufreq_governor_attr_set.c new file mode 100644 index 000000000000..52841f807a7e --- /dev/null +++ b/drivers/cpufreq/cpufreq_governor_attr_set.c | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | /* | ||
| 2 | * Abstract code for CPUFreq governor tunable sysfs attributes. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016, Intel Corporation | ||
| 5 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include "cpufreq_governor.h" | ||
| 13 | |||
| 14 | static inline struct gov_attr_set *to_gov_attr_set(struct kobject *kobj) | ||
| 15 | { | ||
| 16 | return container_of(kobj, struct gov_attr_set, kobj); | ||
| 17 | } | ||
| 18 | |||
| 19 | static inline struct governor_attr *to_gov_attr(struct attribute *attr) | ||
| 20 | { | ||
| 21 | return container_of(attr, struct governor_attr, attr); | ||
| 22 | } | ||
| 23 | |||
| 24 | static ssize_t governor_show(struct kobject *kobj, struct attribute *attr, | ||
| 25 | char *buf) | ||
| 26 | { | ||
| 27 | struct governor_attr *gattr = to_gov_attr(attr); | ||
| 28 | |||
| 29 | return gattr->show(to_gov_attr_set(kobj), buf); | ||
| 30 | } | ||
| 31 | |||
| 32 | static ssize_t governor_store(struct kobject *kobj, struct attribute *attr, | ||
| 33 | const char *buf, size_t count) | ||
| 34 | { | ||
| 35 | struct gov_attr_set *attr_set = to_gov_attr_set(kobj); | ||
| 36 | struct governor_attr *gattr = to_gov_attr(attr); | ||
| 37 | int ret; | ||
| 38 | |||
| 39 | mutex_lock(&attr_set->update_lock); | ||
| 40 | ret = attr_set->usage_count ? gattr->store(attr_set, buf, count) : -EBUSY; | ||
| 41 | mutex_unlock(&attr_set->update_lock); | ||
| 42 | return ret; | ||
| 43 | } | ||
| 44 | |||
| 45 | const struct sysfs_ops governor_sysfs_ops = { | ||
| 46 | .show = governor_show, | ||
| 47 | .store = governor_store, | ||
| 48 | }; | ||
| 49 | EXPORT_SYMBOL_GPL(governor_sysfs_ops); | ||
| 50 | |||
| 51 | void gov_attr_set_init(struct gov_attr_set *attr_set, struct list_head *list_node) | ||
| 52 | { | ||
| 53 | INIT_LIST_HEAD(&attr_set->policy_list); | ||
| 54 | mutex_init(&attr_set->update_lock); | ||
| 55 | attr_set->usage_count = 1; | ||
| 56 | list_add(list_node, &attr_set->policy_list); | ||
| 57 | } | ||
| 58 | EXPORT_SYMBOL_GPL(gov_attr_set_init); | ||
| 59 | |||
| 60 | void gov_attr_set_get(struct gov_attr_set *attr_set, struct list_head *list_node) | ||
| 61 | { | ||
| 62 | mutex_lock(&attr_set->update_lock); | ||
| 63 | attr_set->usage_count++; | ||
| 64 | list_add(list_node, &attr_set->policy_list); | ||
| 65 | mutex_unlock(&attr_set->update_lock); | ||
| 66 | } | ||
| 67 | EXPORT_SYMBOL_GPL(gov_attr_set_get); | ||
| 68 | |||
| 69 | unsigned int gov_attr_set_put(struct gov_attr_set *attr_set, struct list_head *list_node) | ||
| 70 | { | ||
| 71 | unsigned int count; | ||
| 72 | |||
| 73 | mutex_lock(&attr_set->update_lock); | ||
| 74 | list_del(list_node); | ||
| 75 | count = --attr_set->usage_count; | ||
| 76 | mutex_unlock(&attr_set->update_lock); | ||
| 77 | if (count) | ||
| 78 | return count; | ||
| 79 | |||
| 80 | kobject_put(&attr_set->kobj); | ||
| 81 | mutex_destroy(&attr_set->update_lock); | ||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | EXPORT_SYMBOL_GPL(gov_attr_set_put); | ||
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index acd80272ded6..300163430516 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
| @@ -207,9 +207,10 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy) | |||
| 207 | /************************** sysfs interface ************************/ | 207 | /************************** sysfs interface ************************/ |
| 208 | static struct dbs_governor od_dbs_gov; | 208 | static struct dbs_governor od_dbs_gov; |
| 209 | 209 | ||
| 210 | static ssize_t store_io_is_busy(struct dbs_data *dbs_data, const char *buf, | 210 | static ssize_t store_io_is_busy(struct gov_attr_set *attr_set, const char *buf, |
| 211 | size_t count) | 211 | size_t count) |
| 212 | { | 212 | { |
| 213 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 213 | unsigned int input; | 214 | unsigned int input; |
| 214 | int ret; | 215 | int ret; |
| 215 | 216 | ||
| @@ -224,9 +225,10 @@ static ssize_t store_io_is_busy(struct dbs_data *dbs_data, const char *buf, | |||
| 224 | return count; | 225 | return count; |
| 225 | } | 226 | } |
| 226 | 227 | ||
| 227 | static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, | 228 | static ssize_t store_up_threshold(struct gov_attr_set *attr_set, |
| 228 | size_t count) | 229 | const char *buf, size_t count) |
| 229 | { | 230 | { |
| 231 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 230 | unsigned int input; | 232 | unsigned int input; |
| 231 | int ret; | 233 | int ret; |
| 232 | ret = sscanf(buf, "%u", &input); | 234 | ret = sscanf(buf, "%u", &input); |
| @@ -240,9 +242,10 @@ static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, | |||
| 240 | return count; | 242 | return count; |
| 241 | } | 243 | } |
| 242 | 244 | ||
| 243 | static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data, | 245 | static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, |
| 244 | const char *buf, size_t count) | 246 | const char *buf, size_t count) |
| 245 | { | 247 | { |
| 248 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 246 | struct policy_dbs_info *policy_dbs; | 249 | struct policy_dbs_info *policy_dbs; |
| 247 | unsigned int input; | 250 | unsigned int input; |
| 248 | int ret; | 251 | int ret; |
| @@ -254,7 +257,7 @@ static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data, | |||
| 254 | dbs_data->sampling_down_factor = input; | 257 | dbs_data->sampling_down_factor = input; |
| 255 | 258 | ||
| 256 | /* Reset down sampling multiplier in case it was active */ | 259 | /* Reset down sampling multiplier in case it was active */ |
| 257 | list_for_each_entry(policy_dbs, &dbs_data->policy_dbs_list, list) { | 260 | list_for_each_entry(policy_dbs, &attr_set->policy_list, list) { |
| 258 | /* | 261 | /* |
| 259 | * Doing this without locking might lead to using different | 262 | * Doing this without locking might lead to using different |
| 260 | * rate_mult values in od_update() and od_dbs_timer(). | 263 | * rate_mult values in od_update() and od_dbs_timer(). |
| @@ -267,9 +270,10 @@ static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data, | |||
| 267 | return count; | 270 | return count; |
| 268 | } | 271 | } |
| 269 | 272 | ||
| 270 | static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data, | 273 | static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set, |
| 271 | const char *buf, size_t count) | 274 | const char *buf, size_t count) |
| 272 | { | 275 | { |
| 276 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 273 | unsigned int input; | 277 | unsigned int input; |
| 274 | int ret; | 278 | int ret; |
| 275 | 279 | ||
| @@ -291,9 +295,10 @@ static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data, | |||
| 291 | return count; | 295 | return count; |
| 292 | } | 296 | } |
| 293 | 297 | ||
| 294 | static ssize_t store_powersave_bias(struct dbs_data *dbs_data, const char *buf, | 298 | static ssize_t store_powersave_bias(struct gov_attr_set *attr_set, |
| 295 | size_t count) | 299 | const char *buf, size_t count) |
| 296 | { | 300 | { |
| 301 | struct dbs_data *dbs_data = to_dbs_data(attr_set); | ||
| 297 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | 302 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; |
| 298 | struct policy_dbs_info *policy_dbs; | 303 | struct policy_dbs_info *policy_dbs; |
| 299 | unsigned int input; | 304 | unsigned int input; |
| @@ -308,7 +313,7 @@ static ssize_t store_powersave_bias(struct dbs_data *dbs_data, const char *buf, | |||
| 308 | 313 | ||
| 309 | od_tuners->powersave_bias = input; | 314 | od_tuners->powersave_bias = input; |
| 310 | 315 | ||
| 311 | list_for_each_entry(policy_dbs, &dbs_data->policy_dbs_list, list) | 316 | list_for_each_entry(policy_dbs, &attr_set->policy_list, list) |
| 312 | ondemand_powersave_bias_init(policy_dbs->policy); | 317 | ondemand_powersave_bias_init(policy_dbs->policy); |
| 313 | 318 | ||
| 314 | return count; | 319 | return count; |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 4d16f45ee1da..9f3dec9a3f36 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/mutex.h> | 19 | #include <linux/mutex.h> |
| 20 | #include <linux/slab.h> | ||
| 20 | 21 | ||
| 21 | static DEFINE_PER_CPU(unsigned int, cpu_is_managed); | 22 | static DEFINE_PER_CPU(unsigned int, cpu_is_managed); |
| 22 | static DEFINE_MUTEX(userspace_mutex); | 23 | static DEFINE_MUTEX(userspace_mutex); |
| @@ -31,6 +32,7 @@ static DEFINE_MUTEX(userspace_mutex); | |||
| 31 | static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) | 32 | static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) |
| 32 | { | 33 | { |
| 33 | int ret = -EINVAL; | 34 | int ret = -EINVAL; |
| 35 | unsigned int *setspeed = policy->governor_data; | ||
| 34 | 36 | ||
| 35 | pr_debug("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); | 37 | pr_debug("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); |
| 36 | 38 | ||
| @@ -38,6 +40,8 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) | |||
| 38 | if (!per_cpu(cpu_is_managed, policy->cpu)) | 40 | if (!per_cpu(cpu_is_managed, policy->cpu)) |
| 39 | goto err; | 41 | goto err; |
| 40 | 42 | ||
| 43 | *setspeed = freq; | ||
| 44 | |||
| 41 | ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L); | 45 | ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L); |
| 42 | err: | 46 | err: |
| 43 | mutex_unlock(&userspace_mutex); | 47 | mutex_unlock(&userspace_mutex); |
| @@ -49,19 +53,45 @@ static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) | |||
| 49 | return sprintf(buf, "%u\n", policy->cur); | 53 | return sprintf(buf, "%u\n", policy->cur); |
| 50 | } | 54 | } |
| 51 | 55 | ||
| 56 | static int cpufreq_userspace_policy_init(struct cpufreq_policy *policy) | ||
| 57 | { | ||
| 58 | unsigned int *setspeed; | ||
| 59 | |||
| 60 | setspeed = kzalloc(sizeof(*setspeed), GFP_KERNEL); | ||
| 61 | if (!setspeed) | ||
| 62 | return -ENOMEM; | ||
| 63 | |||
| 64 | policy->governor_data = setspeed; | ||
| 65 | return 0; | ||
| 66 | } | ||
| 67 | |||
| 52 | static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | 68 | static int cpufreq_governor_userspace(struct cpufreq_policy *policy, |
| 53 | unsigned int event) | 69 | unsigned int event) |
| 54 | { | 70 | { |
| 71 | unsigned int *setspeed = policy->governor_data; | ||
| 55 | unsigned int cpu = policy->cpu; | 72 | unsigned int cpu = policy->cpu; |
| 56 | int rc = 0; | 73 | int rc = 0; |
| 57 | 74 | ||
| 75 | if (event == CPUFREQ_GOV_POLICY_INIT) | ||
| 76 | return cpufreq_userspace_policy_init(policy); | ||
| 77 | |||
| 78 | if (!setspeed) | ||
| 79 | return -EINVAL; | ||
| 80 | |||
| 58 | switch (event) { | 81 | switch (event) { |
| 82 | case CPUFREQ_GOV_POLICY_EXIT: | ||
| 83 | mutex_lock(&userspace_mutex); | ||
| 84 | policy->governor_data = NULL; | ||
| 85 | kfree(setspeed); | ||
| 86 | mutex_unlock(&userspace_mutex); | ||
| 87 | break; | ||
| 59 | case CPUFREQ_GOV_START: | 88 | case CPUFREQ_GOV_START: |
| 60 | BUG_ON(!policy->cur); | 89 | BUG_ON(!policy->cur); |
| 61 | pr_debug("started managing cpu %u\n", cpu); | 90 | pr_debug("started managing cpu %u\n", cpu); |
| 62 | 91 | ||
| 63 | mutex_lock(&userspace_mutex); | 92 | mutex_lock(&userspace_mutex); |
| 64 | per_cpu(cpu_is_managed, cpu) = 1; | 93 | per_cpu(cpu_is_managed, cpu) = 1; |
| 94 | *setspeed = policy->cur; | ||
| 65 | mutex_unlock(&userspace_mutex); | 95 | mutex_unlock(&userspace_mutex); |
| 66 | break; | 96 | break; |
| 67 | case CPUFREQ_GOV_STOP: | 97 | case CPUFREQ_GOV_STOP: |
| @@ -69,20 +99,23 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | |||
| 69 | 99 | ||
| 70 | mutex_lock(&userspace_mutex); | 100 | mutex_lock(&userspace_mutex); |
| 71 | per_cpu(cpu_is_managed, cpu) = 0; | 101 | per_cpu(cpu_is_managed, cpu) = 0; |
| 102 | *setspeed = 0; | ||
| 72 | mutex_unlock(&userspace_mutex); | 103 | mutex_unlock(&userspace_mutex); |
| 73 | break; | 104 | break; |
| 74 | case CPUFREQ_GOV_LIMITS: | 105 | case CPUFREQ_GOV_LIMITS: |
| 75 | mutex_lock(&userspace_mutex); | 106 | mutex_lock(&userspace_mutex); |
| 76 | pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz\n", | 107 | pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", |
| 77 | cpu, policy->min, policy->max, | 108 | cpu, policy->min, policy->max, policy->cur, *setspeed); |
| 78 | policy->cur); | ||
| 79 | 109 | ||
| 80 | if (policy->max < policy->cur) | 110 | if (policy->max < *setspeed) |
| 81 | __cpufreq_driver_target(policy, policy->max, | 111 | __cpufreq_driver_target(policy, policy->max, |
| 82 | CPUFREQ_RELATION_H); | 112 | CPUFREQ_RELATION_H); |
| 83 | else if (policy->min > policy->cur) | 113 | else if (policy->min > *setspeed) |
| 84 | __cpufreq_driver_target(policy, policy->min, | 114 | __cpufreq_driver_target(policy, policy->min, |
| 85 | CPUFREQ_RELATION_L); | 115 | CPUFREQ_RELATION_L); |
| 116 | else | ||
| 117 | __cpufreq_driver_target(policy, *setspeed, | ||
| 118 | CPUFREQ_RELATION_L); | ||
| 86 | mutex_unlock(&userspace_mutex); | 119 | mutex_unlock(&userspace_mutex); |
| 87 | break; | 120 | break; |
| 88 | } | 121 | } |
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 4085244c8a67..cdf097b29862 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* | 6 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 10 | |||
| 9 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
| 10 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 11 | #include <linux/init.h> | 13 | #include <linux/init.h> |
| @@ -20,7 +22,7 @@ | |||
| 20 | #include <asm/msr.h> | 22 | #include <asm/msr.h> |
| 21 | #include <asm/tsc.h> | 23 | #include <asm/tsc.h> |
| 22 | 24 | ||
| 23 | #if defined CONFIG_ACPI_PROCESSOR || defined CONFIG_ACPI_PROCESSOR_MODULE | 25 | #if IS_ENABLED(CONFIG_ACPI_PROCESSOR) |
| 24 | #include <linux/acpi.h> | 26 | #include <linux/acpi.h> |
| 25 | #include <acpi/processor.h> | 27 | #include <acpi/processor.h> |
| 26 | #endif | 28 | #endif |
| @@ -33,7 +35,7 @@ | |||
| 33 | 35 | ||
| 34 | struct eps_cpu_data { | 36 | struct eps_cpu_data { |
| 35 | u32 fsb; | 37 | u32 fsb; |
| 36 | #if defined CONFIG_ACPI_PROCESSOR || defined CONFIG_ACPI_PROCESSOR_MODULE | 38 | #if IS_ENABLED(CONFIG_ACPI_PROCESSOR) |
| 37 | u32 bios_limit; | 39 | u32 bios_limit; |
| 38 | #endif | 40 | #endif |
| 39 | struct cpufreq_frequency_table freq_table[]; | 41 | struct cpufreq_frequency_table freq_table[]; |
| @@ -46,7 +48,7 @@ static int freq_failsafe_off; | |||
| 46 | static int voltage_failsafe_off; | 48 | static int voltage_failsafe_off; |
| 47 | static int set_max_voltage; | 49 | static int set_max_voltage; |
| 48 | 50 | ||
| 49 | #if defined CONFIG_ACPI_PROCESSOR || defined CONFIG_ACPI_PROCESSOR_MODULE | 51 | #if IS_ENABLED(CONFIG_ACPI_PROCESSOR) |
| 50 | static int ignore_acpi_limit; | 52 | static int ignore_acpi_limit; |
| 51 | 53 | ||
| 52 | static struct acpi_processor_performance *eps_acpi_cpu_perf; | 54 | static struct acpi_processor_performance *eps_acpi_cpu_perf; |
| @@ -141,11 +143,9 @@ static int eps_set_state(struct eps_cpu_data *centaur, | |||
| 141 | /* Print voltage and multiplier */ | 143 | /* Print voltage and multiplier */ |
| 142 | rdmsr(MSR_IA32_PERF_STATUS, lo, hi); | 144 | rdmsr(MSR_IA32_PERF_STATUS, lo, hi); |
| 143 | current_voltage = lo & 0xff; | 145 | current_voltage = lo & 0xff; |
| 144 | printk(KERN_INFO "eps: Current voltage = %dmV\n", | 146 | pr_info("Current voltage = %dmV\n", current_voltage * 16 + 700); |
| 145 | current_voltage * 16 + 700); | ||
| 146 | current_multiplier = (lo >> 8) & 0xff; | 147 | current_multiplier = (lo >> 8) & 0xff; |
| 147 | printk(KERN_INFO "eps: Current multiplier = %d\n", | 148 | pr_info("Current multiplier = %d\n", current_multiplier); |
| 148 | current_multiplier); | ||
| 149 | } | 149 | } |
| 150 | #endif | 150 | #endif |
| 151 | return 0; | 151 | return 0; |
| @@ -166,7 +166,7 @@ static int eps_target(struct cpufreq_policy *policy, unsigned int index) | |||
| 166 | dest_state = centaur->freq_table[index].driver_data & 0xffff; | 166 | dest_state = centaur->freq_table[index].driver_data & 0xffff; |
| 167 | ret = eps_set_state(centaur, policy, dest_state); | 167 | ret = eps_set_state(centaur, policy, dest_state); |
| 168 | if (ret) | 168 | if (ret) |
| 169 | printk(KERN_ERR "eps: Timeout!\n"); | 169 | pr_err("Timeout!\n"); |
| 170 | return ret; | 170 | return ret; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| @@ -186,7 +186,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 186 | int k, step, voltage; | 186 | int k, step, voltage; |
| 187 | int ret; | 187 | int ret; |
| 188 | int states; | 188 | int states; |
| 189 | #if defined CONFIG_ACPI_PROCESSOR || defined CONFIG_ACPI_PROCESSOR_MODULE | 189 | #if IS_ENABLED(CONFIG_ACPI_PROCESSOR) |
| 190 | unsigned int limit; | 190 | unsigned int limit; |
| 191 | #endif | 191 | #endif |
| 192 | 192 | ||
| @@ -194,36 +194,36 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 194 | return -ENODEV; | 194 | return -ENODEV; |
| 195 | 195 | ||
| 196 | /* Check brand */ | 196 | /* Check brand */ |
| 197 | printk(KERN_INFO "eps: Detected VIA "); | 197 | pr_info("Detected VIA "); |
| 198 | 198 | ||
| 199 | switch (c->x86_model) { | 199 | switch (c->x86_model) { |
| 200 | case 10: | 200 | case 10: |
| 201 | rdmsr(0x1153, lo, hi); | 201 | rdmsr(0x1153, lo, hi); |
| 202 | brand = (((lo >> 2) ^ lo) >> 18) & 3; | 202 | brand = (((lo >> 2) ^ lo) >> 18) & 3; |
| 203 | printk(KERN_CONT "Model A "); | 203 | pr_cont("Model A "); |
| 204 | break; | 204 | break; |
| 205 | case 13: | 205 | case 13: |
| 206 | rdmsr(0x1154, lo, hi); | 206 | rdmsr(0x1154, lo, hi); |
| 207 | brand = (((lo >> 4) ^ (lo >> 2))) & 0x000000ff; | 207 | brand = (((lo >> 4) ^ (lo >> 2))) & 0x000000ff; |
| 208 | printk(KERN_CONT "Model D "); | 208 | pr_cont("Model D "); |
| 209 | break; | 209 | break; |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | switch (brand) { | 212 | switch (brand) { |
| 213 | case EPS_BRAND_C7M: | 213 | case EPS_BRAND_C7M: |
| 214 | printk(KERN_CONT "C7-M\n"); | 214 | pr_cont("C7-M\n"); |
| 215 | break; | 215 | break; |
| 216 | case EPS_BRAND_C7: | 216 | case EPS_BRAND_C7: |
| 217 | printk(KERN_CONT "C7\n"); | 217 | pr_cont("C7\n"); |
| 218 | break; | 218 | break; |
| 219 | case EPS_BRAND_EDEN: | 219 | case EPS_BRAND_EDEN: |
| 220 | printk(KERN_CONT "Eden\n"); | 220 | pr_cont("Eden\n"); |
| 221 | break; | 221 | break; |
| 222 | case EPS_BRAND_C7D: | 222 | case EPS_BRAND_C7D: |
| 223 | printk(KERN_CONT "C7-D\n"); | 223 | pr_cont("C7-D\n"); |
| 224 | break; | 224 | break; |
| 225 | case EPS_BRAND_C3: | 225 | case EPS_BRAND_C3: |
| 226 | printk(KERN_CONT "C3\n"); | 226 | pr_cont("C3\n"); |
| 227 | return -ENODEV; | 227 | return -ENODEV; |
| 228 | break; | 228 | break; |
| 229 | } | 229 | } |
| @@ -235,7 +235,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 235 | /* Can be locked at 0 */ | 235 | /* Can be locked at 0 */ |
| 236 | rdmsrl(MSR_IA32_MISC_ENABLE, val); | 236 | rdmsrl(MSR_IA32_MISC_ENABLE, val); |
| 237 | if (!(val & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP)) { | 237 | if (!(val & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP)) { |
| 238 | printk(KERN_INFO "eps: Can't enable Enhanced PowerSaver\n"); | 238 | pr_info("Can't enable Enhanced PowerSaver\n"); |
| 239 | return -ENODEV; | 239 | return -ENODEV; |
| 240 | } | 240 | } |
| 241 | } | 241 | } |
| @@ -243,22 +243,19 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 243 | /* Print voltage and multiplier */ | 243 | /* Print voltage and multiplier */ |
| 244 | rdmsr(MSR_IA32_PERF_STATUS, lo, hi); | 244 | rdmsr(MSR_IA32_PERF_STATUS, lo, hi); |
| 245 | current_voltage = lo & 0xff; | 245 | current_voltage = lo & 0xff; |
| 246 | printk(KERN_INFO "eps: Current voltage = %dmV\n", | 246 | pr_info("Current voltage = %dmV\n", current_voltage * 16 + 700); |
| 247 | current_voltage * 16 + 700); | ||
| 248 | current_multiplier = (lo >> 8) & 0xff; | 247 | current_multiplier = (lo >> 8) & 0xff; |
| 249 | printk(KERN_INFO "eps: Current multiplier = %d\n", current_multiplier); | 248 | pr_info("Current multiplier = %d\n", current_multiplier); |
| 250 | 249 | ||
| 251 | /* Print limits */ | 250 | /* Print limits */ |
| 252 | max_voltage = hi & 0xff; | 251 | max_voltage = hi & 0xff; |
| 253 | printk(KERN_INFO "eps: Highest voltage = %dmV\n", | 252 | pr_info("Highest voltage = %dmV\n", max_voltage * 16 + 700); |
| 254 | max_voltage * 16 + 700); | ||
| 255 | max_multiplier = (hi >> 8) & 0xff; | 253 | max_multiplier = (hi >> 8) & 0xff; |
| 256 | printk(KERN_INFO "eps: Highest multiplier = %d\n", max_multiplier); | 254 | pr_info("Highest multiplier = %d\n", max_multiplier); |
| 257 | min_voltage = (hi >> 16) & 0xff; | 255 | min_voltage = (hi >> 16) & 0xff; |
| 258 | printk(KERN_INFO "eps: Lowest voltage = %dmV\n", | 256 | pr_info("Lowest voltage = %dmV\n", min_voltage * 16 + 700); |
| 259 | min_voltage * 16 + 700); | ||
| 260 | min_multiplier = (hi >> 24) & 0xff; | 257 | min_multiplier = (hi >> 24) & 0xff; |
| 261 | printk(KERN_INFO "eps: Lowest multiplier = %d\n", min_multiplier); | 258 | pr_info("Lowest multiplier = %d\n", min_multiplier); |
| 262 | 259 | ||
| 263 | /* Sanity checks */ | 260 | /* Sanity checks */ |
| 264 | if (current_multiplier == 0 || max_multiplier == 0 | 261 | if (current_multiplier == 0 || max_multiplier == 0 |
| @@ -276,34 +273,30 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 276 | 273 | ||
| 277 | /* Check for systems using underclocked CPU */ | 274 | /* Check for systems using underclocked CPU */ |
| 278 | if (!freq_failsafe_off && max_multiplier != current_multiplier) { | 275 | if (!freq_failsafe_off && max_multiplier != current_multiplier) { |
| 279 | printk(KERN_INFO "eps: Your processor is running at different " | 276 | pr_info("Your processor is running at different frequency then its maximum. Aborting.\n"); |
| 280 | "frequency then its maximum. Aborting.\n"); | 277 | pr_info("You can use freq_failsafe_off option to disable this check.\n"); |
| 281 | printk(KERN_INFO "eps: You can use freq_failsafe_off option " | ||
| 282 | "to disable this check.\n"); | ||
| 283 | return -EINVAL; | 278 | return -EINVAL; |
| 284 | } | 279 | } |
| 285 | if (!voltage_failsafe_off && max_voltage != current_voltage) { | 280 | if (!voltage_failsafe_off && max_voltage != current_voltage) { |
| 286 | printk(KERN_INFO "eps: Your processor is running at different " | 281 | pr_info("Your processor is running at different voltage then its maximum. Aborting.\n"); |
| 287 | "voltage then its maximum. Aborting.\n"); | 282 | pr_info("You can use voltage_failsafe_off option to disable this check.\n"); |
| 288 | printk(KERN_INFO "eps: You can use voltage_failsafe_off " | ||
| 289 | "option to disable this check.\n"); | ||
| 290 | return -EINVAL; | 283 | return -EINVAL; |
| 291 | } | 284 | } |
| 292 | 285 | ||
| 293 | /* Calc FSB speed */ | 286 | /* Calc FSB speed */ |
| 294 | fsb = cpu_khz / current_multiplier; | 287 | fsb = cpu_khz / current_multiplier; |
| 295 | 288 | ||
| 296 | #if defined CONFIG_ACPI_PROCESSOR || defined CONFIG_ACPI_PROCESSOR_MODULE | 289 | #if IS_ENABLED(CONFIG_ACPI_PROCESSOR) |
| 297 | /* Check for ACPI processor speed limit */ | 290 | /* Check for ACPI processor speed limit */ |
| 298 | if (!ignore_acpi_limit && !eps_acpi_init()) { | 291 | if (!ignore_acpi_limit && !eps_acpi_init()) { |
| 299 | if (!acpi_processor_get_bios_limit(policy->cpu, &limit)) { | 292 | if (!acpi_processor_get_bios_limit(policy->cpu, &limit)) { |
| 300 | printk(KERN_INFO "eps: ACPI limit %u.%uGHz\n", | 293 | pr_info("ACPI limit %u.%uGHz\n", |
| 301 | limit/1000000, | 294 | limit/1000000, |
| 302 | (limit%1000000)/10000); | 295 | (limit%1000000)/10000); |
| 303 | eps_acpi_exit(policy); | 296 | eps_acpi_exit(policy); |
| 304 | /* Check if max_multiplier is in BIOS limits */ | 297 | /* Check if max_multiplier is in BIOS limits */ |
| 305 | if (limit && max_multiplier * fsb > limit) { | 298 | if (limit && max_multiplier * fsb > limit) { |
| 306 | printk(KERN_INFO "eps: Aborting.\n"); | 299 | pr_info("Aborting\n"); |
| 307 | return -EINVAL; | 300 | return -EINVAL; |
| 308 | } | 301 | } |
| 309 | } | 302 | } |
| @@ -319,8 +312,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 319 | v = (set_max_voltage - 700) / 16; | 312 | v = (set_max_voltage - 700) / 16; |
| 320 | /* Check if voltage is within limits */ | 313 | /* Check if voltage is within limits */ |
| 321 | if (v >= min_voltage && v <= max_voltage) { | 314 | if (v >= min_voltage && v <= max_voltage) { |
| 322 | printk(KERN_INFO "eps: Setting %dmV as maximum.\n", | 315 | pr_info("Setting %dmV as maximum\n", v * 16 + 700); |
| 323 | v * 16 + 700); | ||
| 324 | max_voltage = v; | 316 | max_voltage = v; |
| 325 | } | 317 | } |
| 326 | } | 318 | } |
| @@ -341,7 +333,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 341 | 333 | ||
| 342 | /* Copy basic values */ | 334 | /* Copy basic values */ |
| 343 | centaur->fsb = fsb; | 335 | centaur->fsb = fsb; |
| 344 | #if defined CONFIG_ACPI_PROCESSOR || defined CONFIG_ACPI_PROCESSOR_MODULE | 336 | #if IS_ENABLED(CONFIG_ACPI_PROCESSOR) |
| 345 | centaur->bios_limit = limit; | 337 | centaur->bios_limit = limit; |
| 346 | #endif | 338 | #endif |
| 347 | 339 | ||
| @@ -426,7 +418,7 @@ module_param(freq_failsafe_off, int, 0644); | |||
| 426 | MODULE_PARM_DESC(freq_failsafe_off, "Disable current vs max frequency check"); | 418 | MODULE_PARM_DESC(freq_failsafe_off, "Disable current vs max frequency check"); |
| 427 | module_param(voltage_failsafe_off, int, 0644); | 419 | module_param(voltage_failsafe_off, int, 0644); |
| 428 | MODULE_PARM_DESC(voltage_failsafe_off, "Disable current vs max voltage check"); | 420 | MODULE_PARM_DESC(voltage_failsafe_off, "Disable current vs max voltage check"); |
| 429 | #if defined CONFIG_ACPI_PROCESSOR || defined CONFIG_ACPI_PROCESSOR_MODULE | 421 | #if IS_ENABLED(CONFIG_ACPI_PROCESSOR) |
| 430 | module_param(ignore_acpi_limit, int, 0644); | 422 | module_param(ignore_acpi_limit, int, 0644); |
| 431 | MODULE_PARM_DESC(ignore_acpi_limit, "Don't check ACPI's processor speed limit"); | 423 | MODULE_PARM_DESC(ignore_acpi_limit, "Don't check ACPI's processor speed limit"); |
| 432 | #endif | 424 | #endif |
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c index 1c06e786c9ba..bfce11cba1df 100644 --- a/drivers/cpufreq/elanfreq.c +++ b/drivers/cpufreq/elanfreq.c | |||
| @@ -16,6 +16,8 @@ | |||
| 16 | * | 16 | * |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 20 | |||
| 19 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
| 20 | #include <linux/module.h> | 22 | #include <linux/module.h> |
| 21 | #include <linux/init.h> | 23 | #include <linux/init.h> |
| @@ -185,7 +187,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy) | |||
| 185 | static int __init elanfreq_setup(char *str) | 187 | static int __init elanfreq_setup(char *str) |
| 186 | { | 188 | { |
| 187 | max_freq = simple_strtoul(str, &str, 0); | 189 | max_freq = simple_strtoul(str, &str, 0); |
| 188 | printk(KERN_WARNING "You're using the deprecated elanfreq command line option. Use elanfreq.max_freq instead, please!\n"); | 190 | pr_warn("You're using the deprecated elanfreq command line option. Use elanfreq.max_freq instead, please!\n"); |
| 189 | return 1; | 191 | return 1; |
| 190 | } | 192 | } |
| 191 | __setup("elanfreq=", elanfreq_setup); | 193 | __setup("elanfreq=", elanfreq_setup); |
diff --git a/drivers/cpufreq/hisi-acpu-cpufreq.c b/drivers/cpufreq/hisi-acpu-cpufreq.c deleted file mode 100644 index 026d5b2224de..000000000000 --- a/drivers/cpufreq/hisi-acpu-cpufreq.c +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Hisilicon Platforms Using ACPU CPUFreq Support | ||
| 3 | * | ||
| 4 | * Copyright (c) 2015 Hisilicon Limited. | ||
| 5 | * Copyright (c) 2015 Linaro Limited. | ||
| 6 | * | ||
| 7 | * Leo Yan <leo.yan@linaro.org> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License version 2 as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | * | ||
| 13 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 14 | * kind, whether express or implied; without even the implied warranty | ||
| 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 20 | |||
| 21 | #include <linux/err.h> | ||
| 22 | #include <linux/init.h> | ||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/of.h> | ||
| 26 | #include <linux/platform_device.h> | ||
| 27 | |||
| 28 | static int __init hisi_acpu_cpufreq_driver_init(void) | ||
| 29 | { | ||
| 30 | struct platform_device *pdev; | ||
| 31 | |||
| 32 | if (!of_machine_is_compatible("hisilicon,hi6220")) | ||
| 33 | return -ENODEV; | ||
| 34 | |||
| 35 | pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
| 36 | return PTR_ERR_OR_ZERO(pdev); | ||
| 37 | } | ||
| 38 | module_init(hisi_acpu_cpufreq_driver_init); | ||
| 39 | |||
| 40 | MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>"); | ||
| 41 | MODULE_DESCRIPTION("Hisilicon acpu cpufreq driver"); | ||
| 42 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c index 0202429f1c5b..759612da4fdc 100644 --- a/drivers/cpufreq/ia64-acpi-cpufreq.c +++ b/drivers/cpufreq/ia64-acpi-cpufreq.c | |||
| @@ -8,6 +8,8 @@ | |||
| 8 | * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | 8 | * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 12 | |||
| 11 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 12 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
| 13 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| @@ -118,8 +120,7 @@ processor_get_freq ( | |||
| 118 | 120 | ||
| 119 | if (ret) { | 121 | if (ret) { |
| 120 | set_cpus_allowed_ptr(current, &saved_mask); | 122 | set_cpus_allowed_ptr(current, &saved_mask); |
| 121 | printk(KERN_WARNING "get performance failed with error %d\n", | 123 | pr_warn("get performance failed with error %d\n", ret); |
| 122 | ret); | ||
| 123 | ret = 0; | 124 | ret = 0; |
| 124 | goto migrate_end; | 125 | goto migrate_end; |
| 125 | } | 126 | } |
| @@ -177,7 +178,7 @@ processor_set_freq ( | |||
| 177 | 178 | ||
| 178 | ret = processor_set_pstate(value); | 179 | ret = processor_set_pstate(value); |
| 179 | if (ret) { | 180 | if (ret) { |
| 180 | printk(KERN_WARNING "Transition failed with error %d\n", ret); | 181 | pr_warn("Transition failed with error %d\n", ret); |
| 181 | retval = -ENODEV; | 182 | retval = -ENODEV; |
| 182 | goto migrate_end; | 183 | goto migrate_end; |
| 183 | } | 184 | } |
| @@ -291,8 +292,7 @@ acpi_cpufreq_cpu_init ( | |||
| 291 | /* notify BIOS that we exist */ | 292 | /* notify BIOS that we exist */ |
| 292 | acpi_processor_notify_smm(THIS_MODULE); | 293 | acpi_processor_notify_smm(THIS_MODULE); |
| 293 | 294 | ||
| 294 | printk(KERN_INFO "acpi-cpufreq: CPU%u - ACPI performance management " | 295 | pr_info("CPU%u - ACPI performance management activated\n", cpu); |
| 295 | "activated.\n", cpu); | ||
| 296 | 296 | ||
| 297 | for (i = 0; i < data->acpi_data.state_count; i++) | 297 | for (i = 0; i < data->acpi_data.state_count; i++) |
| 298 | pr_debug(" %cP%d: %d MHz, %d mW, %d uS, %d uS, 0x%x 0x%x\n", | 298 | pr_debug(" %cP%d: %d MHz, %d mW, %d uS, %d uS, 0x%x 0x%x\n", |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index b230ebaae66c..b76a98dd9988 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | * of the License. | 10 | * of the License. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 14 | |||
| 13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
| 14 | #include <linux/kernel_stat.h> | 16 | #include <linux/kernel_stat.h> |
| 15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| @@ -39,10 +41,17 @@ | |||
| 39 | #define ATOM_TURBO_RATIOS 0x66c | 41 | #define ATOM_TURBO_RATIOS 0x66c |
| 40 | #define ATOM_TURBO_VIDS 0x66d | 42 | #define ATOM_TURBO_VIDS 0x66d |
| 41 | 43 | ||
| 44 | #ifdef CONFIG_ACPI | ||
| 45 | #include <acpi/processor.h> | ||
| 46 | #endif | ||
| 47 | |||
| 42 | #define FRAC_BITS 8 | 48 | #define FRAC_BITS 8 |
| 43 | #define int_tofp(X) ((int64_t)(X) << FRAC_BITS) | 49 | #define int_tofp(X) ((int64_t)(X) << FRAC_BITS) |
| 44 | #define fp_toint(X) ((X) >> FRAC_BITS) | 50 | #define fp_toint(X) ((X) >> FRAC_BITS) |
| 45 | 51 | ||
| 52 | #define EXT_BITS 6 | ||
| 53 | #define EXT_FRAC_BITS (EXT_BITS + FRAC_BITS) | ||
| 54 | |||
| 46 | static inline int32_t mul_fp(int32_t x, int32_t y) | 55 | static inline int32_t mul_fp(int32_t x, int32_t y) |
| 47 | { | 56 | { |
| 48 | return ((int64_t)x * (int64_t)y) >> FRAC_BITS; | 57 | return ((int64_t)x * (int64_t)y) >> FRAC_BITS; |
| @@ -64,12 +73,22 @@ static inline int ceiling_fp(int32_t x) | |||
| 64 | return ret; | 73 | return ret; |
| 65 | } | 74 | } |
| 66 | 75 | ||
| 76 | static inline u64 mul_ext_fp(u64 x, u64 y) | ||
| 77 | { | ||
| 78 | return (x * y) >> EXT_FRAC_BITS; | ||
| 79 | } | ||
| 80 | |||
| 81 | static inline u64 div_ext_fp(u64 x, u64 y) | ||
| 82 | { | ||
| 83 | return div64_u64(x << EXT_FRAC_BITS, y); | ||
| 84 | } | ||
| 85 | |||
| 67 | /** | 86 | /** |
| 68 | * struct sample - Store performance sample | 87 | * struct sample - Store performance sample |
| 69 | * @core_pct_busy: Ratio of APERF/MPERF in percent, which is actual | 88 | * @core_avg_perf: Ratio of APERF/MPERF which is the actual average |
| 70 | * performance during last sample period | 89 | * performance during last sample period |
| 71 | * @busy_scaled: Scaled busy value which is used to calculate next | 90 | * @busy_scaled: Scaled busy value which is used to calculate next |
| 72 | * P state. This can be different than core_pct_busy | 91 | * P state. This can be different than core_avg_perf |
| 73 | * to account for cpu idle period | 92 | * to account for cpu idle period |
| 74 | * @aperf: Difference of actual performance frequency clock count | 93 | * @aperf: Difference of actual performance frequency clock count |
| 75 | * read from APERF MSR between last and current sample | 94 | * read from APERF MSR between last and current sample |
| @@ -84,7 +103,7 @@ static inline int ceiling_fp(int32_t x) | |||
| 84 | * data for choosing next P State. | 103 | * data for choosing next P State. |
| 85 | */ | 104 | */ |
| 86 | struct sample { | 105 | struct sample { |
| 87 | int32_t core_pct_busy; | 106 | int32_t core_avg_perf; |
| 88 | int32_t busy_scaled; | 107 | int32_t busy_scaled; |
| 89 | u64 aperf; | 108 | u64 aperf; |
| 90 | u64 mperf; | 109 | u64 mperf; |
| @@ -162,6 +181,7 @@ struct _pid { | |||
| 162 | * struct cpudata - Per CPU instance data storage | 181 | * struct cpudata - Per CPU instance data storage |
| 163 | * @cpu: CPU number for this instance data | 182 | * @cpu: CPU number for this instance data |
| 164 | * @update_util: CPUFreq utility callback information | 183 | * @update_util: CPUFreq utility callback information |
| 184 | * @update_util_set: CPUFreq utility callback is set | ||
| 165 | * @pstate: Stores P state limits for this CPU | 185 | * @pstate: Stores P state limits for this CPU |
| 166 | * @vid: Stores VID limits for this CPU | 186 | * @vid: Stores VID limits for this CPU |
| 167 | * @pid: Stores PID parameters for this CPU | 187 | * @pid: Stores PID parameters for this CPU |
| @@ -172,6 +192,8 @@ struct _pid { | |||
| 172 | * @prev_cummulative_iowait: IO Wait time difference from last and | 192 | * @prev_cummulative_iowait: IO Wait time difference from last and |
| 173 | * current sample | 193 | * current sample |
| 174 | * @sample: Storage for storing last Sample data | 194 | * @sample: Storage for storing last Sample data |
| 195 | * @acpi_perf_data: Stores ACPI perf information read from _PSS | ||
| 196 | * @valid_pss_table: Set to true for valid ACPI _PSS entries found | ||
| 175 | * | 197 | * |
| 176 | * This structure stores per CPU instance data for all CPUs. | 198 | * This structure stores per CPU instance data for all CPUs. |
| 177 | */ | 199 | */ |
| @@ -179,6 +201,7 @@ struct cpudata { | |||
| 179 | int cpu; | 201 | int cpu; |
| 180 | 202 | ||
| 181 | struct update_util_data update_util; | 203 | struct update_util_data update_util; |
| 204 | bool update_util_set; | ||
| 182 | 205 | ||
| 183 | struct pstate_data pstate; | 206 | struct pstate_data pstate; |
| 184 | struct vid_data vid; | 207 | struct vid_data vid; |
| @@ -190,6 +213,10 @@ struct cpudata { | |||
| 190 | u64 prev_tsc; | 213 | u64 prev_tsc; |
| 191 | u64 prev_cummulative_iowait; | 214 | u64 prev_cummulative_iowait; |
| 192 | struct sample sample; | 215 | struct sample sample; |
| 216 | #ifdef CONFIG_ACPI | ||
| 217 | struct acpi_processor_performance acpi_perf_data; | ||
| 218 | bool valid_pss_table; | ||
| 219 | #endif | ||
| 193 | }; | 220 | }; |
| 194 | 221 | ||
| 195 | static struct cpudata **all_cpu_data; | 222 | static struct cpudata **all_cpu_data; |
| @@ -258,6 +285,9 @@ static struct pstate_adjust_policy pid_params; | |||
| 258 | static struct pstate_funcs pstate_funcs; | 285 | static struct pstate_funcs pstate_funcs; |
| 259 | static int hwp_active; | 286 | static int hwp_active; |
| 260 | 287 | ||
| 288 | #ifdef CONFIG_ACPI | ||
| 289 | static bool acpi_ppc; | ||
| 290 | #endif | ||
| 261 | 291 | ||
| 262 | /** | 292 | /** |
| 263 | * struct perf_limits - Store user and policy limits | 293 | * struct perf_limits - Store user and policy limits |
| @@ -331,6 +361,124 @@ static struct perf_limits *limits = &performance_limits; | |||
| 331 | static struct perf_limits *limits = &powersave_limits; | 361 | static struct perf_limits *limits = &powersave_limits; |
| 332 | #endif | 362 | #endif |
| 333 | 363 | ||
| 364 | #ifdef CONFIG_ACPI | ||
| 365 | |||
| 366 | static bool intel_pstate_get_ppc_enable_status(void) | ||
| 367 | { | ||
| 368 | if (acpi_gbl_FADT.preferred_profile == PM_ENTERPRISE_SERVER || | ||
| 369 | acpi_gbl_FADT.preferred_profile == PM_PERFORMANCE_SERVER) | ||
| 370 | return true; | ||
| 371 | |||
| 372 | return acpi_ppc; | ||
| 373 | } | ||
| 374 | |||
| 375 | /* | ||
| 376 | * The max target pstate ratio is a 8 bit value in both PLATFORM_INFO MSR and | ||
| 377 | * in TURBO_RATIO_LIMIT MSR, which pstate driver stores in max_pstate and | ||
| 378 | * max_turbo_pstate fields. The PERF_CTL MSR contains 16 bit value for P state | ||
| 379 | * ratio, out of it only high 8 bits are used. For example 0x1700 is setting | ||
| 380 | * target ratio 0x17. The _PSS control value stores in a format which can be | ||
| 381 | * directly written to PERF_CTL MSR. But in intel_pstate driver this shift | ||
| 382 | * occurs during write to PERF_CTL (E.g. for cores core_set_pstate()). | ||
| 383 | * This function converts the _PSS control value to intel pstate driver format | ||
| 384 | * for comparison and assignment. | ||
| 385 | */ | ||
| 386 | static int convert_to_native_pstate_format(struct cpudata *cpu, int index) | ||
| 387 | { | ||
| 388 | return cpu->acpi_perf_data.states[index].control >> 8; | ||
| 389 | } | ||
| 390 | |||
| 391 | static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy) | ||
| 392 | { | ||
| 393 | struct cpudata *cpu; | ||
| 394 | int turbo_pss_ctl; | ||
| 395 | int ret; | ||
| 396 | int i; | ||
| 397 | |||
| 398 | if (hwp_active) | ||
| 399 | return; | ||
| 400 | |||
| 401 | if (!intel_pstate_get_ppc_enable_status()) | ||
| 402 | return; | ||
| 403 | |||
| 404 | cpu = all_cpu_data[policy->cpu]; | ||
| 405 | |||
| 406 | ret = acpi_processor_register_performance(&cpu->acpi_perf_data, | ||
| 407 | policy->cpu); | ||
| 408 | if (ret) | ||
| 409 | return; | ||
| 410 | |||
| 411 | /* | ||
| 412 | * Check if the control value in _PSS is for PERF_CTL MSR, which should | ||
| 413 | * guarantee that the states returned by it map to the states in our | ||
| 414 | * list directly. | ||
| 415 | */ | ||
| 416 | if (cpu->acpi_perf_data.control_register.space_id != | ||
| 417 | ACPI_ADR_SPACE_FIXED_HARDWARE) | ||
| 418 | goto err; | ||
| 419 | |||
| 420 | /* | ||
| 421 | * If there is only one entry _PSS, simply ignore _PSS and continue as | ||
| 422 | * usual without taking _PSS into account | ||
| 423 | */ | ||
| 424 | if (cpu->acpi_perf_data.state_count < 2) | ||
| 425 | goto err; | ||
| 426 | |||
| 427 | pr_debug("CPU%u - ACPI _PSS perf data\n", policy->cpu); | ||
| 428 | for (i = 0; i < cpu->acpi_perf_data.state_count; i++) { | ||
| 429 | pr_debug(" %cP%d: %u MHz, %u mW, 0x%x\n", | ||
| 430 | (i == cpu->acpi_perf_data.state ? '*' : ' '), i, | ||
| 431 | (u32) cpu->acpi_perf_data.states[i].core_frequency, | ||
| 432 | (u32) cpu->acpi_perf_data.states[i].power, | ||
| 433 | (u32) cpu->acpi_perf_data.states[i].control); | ||
| 434 | } | ||
| 435 | |||
| 436 | /* | ||
| 437 | * The _PSS table doesn't contain whole turbo frequency range. | ||
| 438 | * This just contains +1 MHZ above the max non turbo frequency, | ||
| 439 | * with control value corresponding to max turbo ratio. But | ||
| 440 | * when cpufreq set policy is called, it will call with this | ||
| 441 | * max frequency, which will cause a reduced performance as | ||
| 442 | * this driver uses real max turbo frequency as the max | ||
| 443 | * frequency. So correct this frequency in _PSS table to | ||
| 444 | * correct max turbo frequency based on the turbo ratio. | ||
| 445 | * Also need to convert to MHz as _PSS freq is in MHz. | ||
| 446 | */ | ||
| 447 | turbo_pss_ctl = convert_to_native_pstate_format(cpu, 0); | ||
| 448 | if (turbo_pss_ctl > cpu->pstate.max_pstate) | ||
| 449 | cpu->acpi_perf_data.states[0].core_frequency = | ||
| 450 | policy->cpuinfo.max_freq / 1000; | ||
| 451 | cpu->valid_pss_table = true; | ||
| 452 | pr_info("_PPC limits will be enforced\n"); | ||
| 453 | |||
| 454 | return; | ||
| 455 | |||
| 456 | err: | ||
| 457 | cpu->valid_pss_table = false; | ||
| 458 | acpi_processor_unregister_performance(policy->cpu); | ||
| 459 | } | ||
| 460 | |||
| 461 | static void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy) | ||
| 462 | { | ||
| 463 | struct cpudata *cpu; | ||
| 464 | |||
| 465 | cpu = all_cpu_data[policy->cpu]; | ||
| 466 | if (!cpu->valid_pss_table) | ||
| 467 | return; | ||
| 468 | |||
| 469 | acpi_processor_unregister_performance(policy->cpu); | ||
| 470 | } | ||
| 471 | |||
| 472 | #else | ||
| 473 | static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy) | ||
| 474 | { | ||
| 475 | } | ||
| 476 | |||
| 477 | static void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy) | ||
| 478 | { | ||
| 479 | } | ||
| 480 | #endif | ||
| 481 | |||
| 334 | static inline void pid_reset(struct _pid *pid, int setpoint, int busy, | 482 | static inline void pid_reset(struct _pid *pid, int setpoint, int busy, |
| 335 | int deadband, int integral) { | 483 | int deadband, int integral) { |
| 336 | pid->setpoint = int_tofp(setpoint); | 484 | pid->setpoint = int_tofp(setpoint); |
| @@ -341,17 +489,17 @@ static inline void pid_reset(struct _pid *pid, int setpoint, int busy, | |||
| 341 | 489 | ||
| 342 | static inline void pid_p_gain_set(struct _pid *pid, int percent) | 490 | static inline void pid_p_gain_set(struct _pid *pid, int percent) |
| 343 | { | 491 | { |
| 344 | pid->p_gain = div_fp(int_tofp(percent), int_tofp(100)); | 492 | pid->p_gain = div_fp(percent, 100); |
| 345 | } | 493 | } |
| 346 | 494 | ||
| 347 | static inline void pid_i_gain_set(struct _pid *pid, int percent) | 495 | static inline void pid_i_gain_set(struct _pid *pid, int percent) |
| 348 | { | 496 | { |
| 349 | pid->i_gain = div_fp(int_tofp(percent), int_tofp(100)); | 497 | pid->i_gain = div_fp(percent, 100); |
| 350 | } | 498 | } |
| 351 | 499 | ||
| 352 | static inline void pid_d_gain_set(struct _pid *pid, int percent) | 500 | static inline void pid_d_gain_set(struct _pid *pid, int percent) |
| 353 | { | 501 | { |
| 354 | pid->d_gain = div_fp(int_tofp(percent), int_tofp(100)); | 502 | pid->d_gain = div_fp(percent, 100); |
| 355 | } | 503 | } |
| 356 | 504 | ||
| 357 | static signed int pid_calc(struct _pid *pid, int32_t busy) | 505 | static signed int pid_calc(struct _pid *pid, int32_t busy) |
| @@ -537,7 +685,7 @@ static ssize_t show_turbo_pct(struct kobject *kobj, | |||
| 537 | 685 | ||
| 538 | total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; | 686 | total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; |
| 539 | no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; | 687 | no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; |
| 540 | turbo_fp = div_fp(int_tofp(no_turbo), int_tofp(total)); | 688 | turbo_fp = div_fp(no_turbo, total); |
| 541 | turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100))); | 689 | turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100))); |
| 542 | return sprintf(buf, "%u\n", turbo_pct); | 690 | return sprintf(buf, "%u\n", turbo_pct); |
| 543 | } | 691 | } |
| @@ -579,7 +727,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, | |||
| 579 | 727 | ||
| 580 | update_turbo_state(); | 728 | update_turbo_state(); |
| 581 | if (limits->turbo_disabled) { | 729 | if (limits->turbo_disabled) { |
| 582 | pr_warn("intel_pstate: Turbo disabled by BIOS or unavailable on processor\n"); | 730 | pr_warn("Turbo disabled by BIOS or unavailable on processor\n"); |
| 583 | return -EPERM; | 731 | return -EPERM; |
| 584 | } | 732 | } |
| 585 | 733 | ||
| @@ -608,8 +756,7 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, | |||
| 608 | limits->max_perf_pct); | 756 | limits->max_perf_pct); |
| 609 | limits->max_perf_pct = max(limits->min_perf_pct, | 757 | limits->max_perf_pct = max(limits->min_perf_pct, |
| 610 | limits->max_perf_pct); | 758 | limits->max_perf_pct); |
| 611 | limits->max_perf = div_fp(int_tofp(limits->max_perf_pct), | 759 | limits->max_perf = div_fp(limits->max_perf_pct, 100); |
| 612 | int_tofp(100)); | ||
| 613 | 760 | ||
| 614 | if (hwp_active) | 761 | if (hwp_active) |
| 615 | intel_pstate_hwp_set_online_cpus(); | 762 | intel_pstate_hwp_set_online_cpus(); |
| @@ -633,8 +780,7 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, | |||
| 633 | limits->min_perf_pct); | 780 | limits->min_perf_pct); |
| 634 | limits->min_perf_pct = min(limits->max_perf_pct, | 781 | limits->min_perf_pct = min(limits->max_perf_pct, |
| 635 | limits->min_perf_pct); | 782 | limits->min_perf_pct); |
| 636 | limits->min_perf = div_fp(int_tofp(limits->min_perf_pct), | 783 | limits->min_perf = div_fp(limits->min_perf_pct, 100); |
| 637 | int_tofp(100)); | ||
| 638 | 784 | ||
| 639 | if (hwp_active) | 785 | if (hwp_active) |
| 640 | intel_pstate_hwp_set_online_cpus(); | 786 | intel_pstate_hwp_set_online_cpus(); |
| @@ -1019,15 +1165,11 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) | |||
| 1019 | intel_pstate_set_min_pstate(cpu); | 1165 | intel_pstate_set_min_pstate(cpu); |
| 1020 | } | 1166 | } |
| 1021 | 1167 | ||
| 1022 | static inline void intel_pstate_calc_busy(struct cpudata *cpu) | 1168 | static inline void intel_pstate_calc_avg_perf(struct cpudata *cpu) |
| 1023 | { | 1169 | { |
| 1024 | struct sample *sample = &cpu->sample; | 1170 | struct sample *sample = &cpu->sample; |
| 1025 | int64_t core_pct; | ||
| 1026 | 1171 | ||
| 1027 | core_pct = int_tofp(sample->aperf) * int_tofp(100); | 1172 | sample->core_avg_perf = div_ext_fp(sample->aperf, sample->mperf); |
| 1028 | core_pct = div64_u64(core_pct, int_tofp(sample->mperf)); | ||
| 1029 | |||
| 1030 | sample->core_pct_busy = (int32_t)core_pct; | ||
| 1031 | } | 1173 | } |
| 1032 | 1174 | ||
| 1033 | static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) | 1175 | static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) |
| @@ -1070,9 +1212,14 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) | |||
| 1070 | 1212 | ||
| 1071 | static inline int32_t get_avg_frequency(struct cpudata *cpu) | 1213 | static inline int32_t get_avg_frequency(struct cpudata *cpu) |
| 1072 | { | 1214 | { |
| 1073 | return fp_toint(mul_fp(cpu->sample.core_pct_busy, | 1215 | return mul_ext_fp(cpu->sample.core_avg_perf, |
| 1074 | int_tofp(cpu->pstate.max_pstate_physical * | 1216 | cpu->pstate.max_pstate_physical * cpu->pstate.scaling); |
| 1075 | cpu->pstate.scaling / 100))); | 1217 | } |
| 1218 | |||
| 1219 | static inline int32_t get_avg_pstate(struct cpudata *cpu) | ||
| 1220 | { | ||
| 1221 | return mul_ext_fp(cpu->pstate.max_pstate_physical, | ||
| 1222 | cpu->sample.core_avg_perf); | ||
| 1076 | } | 1223 | } |
| 1077 | 1224 | ||
| 1078 | static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) | 1225 | static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) |
| @@ -1107,49 +1254,43 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) | |||
| 1107 | cpu_load = div64_u64(int_tofp(100) * mperf, sample->tsc); | 1254 | cpu_load = div64_u64(int_tofp(100) * mperf, sample->tsc); |
| 1108 | cpu->sample.busy_scaled = cpu_load; | 1255 | cpu->sample.busy_scaled = cpu_load; |
| 1109 | 1256 | ||
| 1110 | return cpu->pstate.current_pstate - pid_calc(&cpu->pid, cpu_load); | 1257 | return get_avg_pstate(cpu) - pid_calc(&cpu->pid, cpu_load); |
| 1111 | } | 1258 | } |
| 1112 | 1259 | ||
| 1113 | static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu) | 1260 | static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu) |
| 1114 | { | 1261 | { |
| 1115 | int32_t core_busy, max_pstate, current_pstate, sample_ratio; | 1262 | int32_t perf_scaled, max_pstate, current_pstate, sample_ratio; |
| 1116 | u64 duration_ns; | 1263 | u64 duration_ns; |
| 1117 | 1264 | ||
| 1118 | /* | 1265 | /* |
| 1119 | * core_busy is the ratio of actual performance to max | 1266 | * perf_scaled is the average performance during the last sampling |
| 1120 | * max_pstate is the max non turbo pstate available | 1267 | * period scaled by the ratio of the maximum P-state to the P-state |
| 1121 | * current_pstate was the pstate that was requested during | 1268 | * requested last time (in percent). That measures the system's |
| 1122 | * the last sample period. | 1269 | * response to the previous P-state selection. |
| 1123 | * | ||
| 1124 | * We normalize core_busy, which was our actual percent | ||
| 1125 | * performance to what we requested during the last sample | ||
| 1126 | * period. The result will be a percentage of busy at a | ||
| 1127 | * specified pstate. | ||
| 1128 | */ | 1270 | */ |
| 1129 | core_busy = cpu->sample.core_pct_busy; | 1271 | max_pstate = cpu->pstate.max_pstate_physical; |
| 1130 | max_pstate = int_tofp(cpu->pstate.max_pstate_physical); | 1272 | current_pstate = cpu->pstate.current_pstate; |
| 1131 | current_pstate = int_tofp(cpu->pstate.current_pstate); | 1273 | perf_scaled = mul_ext_fp(cpu->sample.core_avg_perf, |
| 1132 | core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); | 1274 | div_fp(100 * max_pstate, current_pstate)); |
| 1133 | 1275 | ||
| 1134 | /* | 1276 | /* |
| 1135 | * Since our utilization update callback will not run unless we are | 1277 | * Since our utilization update callback will not run unless we are |
| 1136 | * in C0, check if the actual elapsed time is significantly greater (3x) | 1278 | * in C0, check if the actual elapsed time is significantly greater (3x) |
| 1137 | * than our sample interval. If it is, then we were idle for a long | 1279 | * than our sample interval. If it is, then we were idle for a long |
| 1138 | * enough period of time to adjust our busyness. | 1280 | * enough period of time to adjust our performance metric. |
| 1139 | */ | 1281 | */ |
| 1140 | duration_ns = cpu->sample.time - cpu->last_sample_time; | 1282 | duration_ns = cpu->sample.time - cpu->last_sample_time; |
| 1141 | if ((s64)duration_ns > pid_params.sample_rate_ns * 3) { | 1283 | if ((s64)duration_ns > pid_params.sample_rate_ns * 3) { |
| 1142 | sample_ratio = div_fp(int_tofp(pid_params.sample_rate_ns), | 1284 | sample_ratio = div_fp(pid_params.sample_rate_ns, duration_ns); |
| 1143 | int_tofp(duration_ns)); | 1285 | perf_scaled = mul_fp(perf_scaled, sample_ratio); |
| 1144 | core_busy = mul_fp(core_busy, sample_ratio); | ||
| 1145 | } else { | 1286 | } else { |
| 1146 | sample_ratio = div_fp(100 * cpu->sample.mperf, cpu->sample.tsc); | 1287 | sample_ratio = div_fp(100 * cpu->sample.mperf, cpu->sample.tsc); |
| 1147 | if (sample_ratio < int_tofp(1)) | 1288 | if (sample_ratio < int_tofp(1)) |
| 1148 | core_busy = 0; | 1289 | perf_scaled = 0; |
| 1149 | } | 1290 | } |
| 1150 | 1291 | ||
| 1151 | cpu->sample.busy_scaled = core_busy; | 1292 | cpu->sample.busy_scaled = perf_scaled; |
| 1152 | return cpu->pstate.current_pstate - pid_calc(&cpu->pid, core_busy); | 1293 | return cpu->pstate.current_pstate - pid_calc(&cpu->pid, perf_scaled); |
| 1153 | } | 1294 | } |
| 1154 | 1295 | ||
| 1155 | static inline void intel_pstate_update_pstate(struct cpudata *cpu, int pstate) | 1296 | static inline void intel_pstate_update_pstate(struct cpudata *cpu, int pstate) |
| @@ -1179,7 +1320,7 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu) | |||
| 1179 | intel_pstate_update_pstate(cpu, target_pstate); | 1320 | intel_pstate_update_pstate(cpu, target_pstate); |
| 1180 | 1321 | ||
| 1181 | sample = &cpu->sample; | 1322 | sample = &cpu->sample; |
| 1182 | trace_pstate_sample(fp_toint(sample->core_pct_busy), | 1323 | trace_pstate_sample(mul_ext_fp(100, sample->core_avg_perf), |
| 1183 | fp_toint(sample->busy_scaled), | 1324 | fp_toint(sample->busy_scaled), |
| 1184 | from, | 1325 | from, |
| 1185 | cpu->pstate.current_pstate, | 1326 | cpu->pstate.current_pstate, |
| @@ -1199,7 +1340,7 @@ static void intel_pstate_update_util(struct update_util_data *data, u64 time, | |||
| 1199 | bool sample_taken = intel_pstate_sample(cpu, time); | 1340 | bool sample_taken = intel_pstate_sample(cpu, time); |
| 1200 | 1341 | ||
| 1201 | if (sample_taken) { | 1342 | if (sample_taken) { |
| 1202 | intel_pstate_calc_busy(cpu); | 1343 | intel_pstate_calc_avg_perf(cpu); |
| 1203 | if (!hwp_active) | 1344 | if (!hwp_active) |
| 1204 | intel_pstate_adjust_busy_pstate(cpu); | 1345 | intel_pstate_adjust_busy_pstate(cpu); |
| 1205 | } | 1346 | } |
| @@ -1261,23 +1402,16 @@ static int intel_pstate_init_cpu(unsigned int cpunum) | |||
| 1261 | 1402 | ||
| 1262 | intel_pstate_busy_pid_reset(cpu); | 1403 | intel_pstate_busy_pid_reset(cpu); |
| 1263 | 1404 | ||
| 1264 | cpu->update_util.func = intel_pstate_update_util; | 1405 | pr_debug("controlling: cpu %d\n", cpunum); |
| 1265 | |||
| 1266 | pr_debug("intel_pstate: controlling: cpu %d\n", cpunum); | ||
| 1267 | 1406 | ||
| 1268 | return 0; | 1407 | return 0; |
| 1269 | } | 1408 | } |
| 1270 | 1409 | ||
| 1271 | static unsigned int intel_pstate_get(unsigned int cpu_num) | 1410 | static unsigned int intel_pstate_get(unsigned int cpu_num) |
| 1272 | { | 1411 | { |
| 1273 | struct sample *sample; | 1412 | struct cpudata *cpu = all_cpu_data[cpu_num]; |
| 1274 | struct cpudata *cpu; | ||
| 1275 | 1413 | ||
| 1276 | cpu = all_cpu_data[cpu_num]; | 1414 | return cpu ? get_avg_frequency(cpu) : 0; |
| 1277 | if (!cpu) | ||
| 1278 | return 0; | ||
| 1279 | sample = &cpu->sample; | ||
| 1280 | return get_avg_frequency(cpu); | ||
| 1281 | } | 1415 | } |
| 1282 | 1416 | ||
| 1283 | static void intel_pstate_set_update_util_hook(unsigned int cpu_num) | 1417 | static void intel_pstate_set_update_util_hook(unsigned int cpu_num) |
| @@ -1286,12 +1420,20 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num) | |||
| 1286 | 1420 | ||
| 1287 | /* Prevent intel_pstate_update_util() from using stale data. */ | 1421 | /* Prevent intel_pstate_update_util() from using stale data. */ |
| 1288 | cpu->sample.time = 0; | 1422 | cpu->sample.time = 0; |
| 1289 | cpufreq_set_update_util_data(cpu_num, &cpu->update_util); | 1423 | cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, |
| 1424 | intel_pstate_update_util); | ||
| 1425 | cpu->update_util_set = true; | ||
| 1290 | } | 1426 | } |
| 1291 | 1427 | ||
| 1292 | static void intel_pstate_clear_update_util_hook(unsigned int cpu) | 1428 | static void intel_pstate_clear_update_util_hook(unsigned int cpu) |
| 1293 | { | 1429 | { |
| 1294 | cpufreq_set_update_util_data(cpu, NULL); | 1430 | struct cpudata *cpu_data = all_cpu_data[cpu]; |
| 1431 | |||
| 1432 | if (!cpu_data->update_util_set) | ||
| 1433 | return; | ||
| 1434 | |||
| 1435 | cpufreq_remove_update_util_hook(cpu); | ||
| 1436 | cpu_data->update_util_set = false; | ||
| 1295 | synchronize_sched(); | 1437 | synchronize_sched(); |
| 1296 | } | 1438 | } |
| 1297 | 1439 | ||
| @@ -1311,20 +1453,31 @@ static void intel_pstate_set_performance_limits(struct perf_limits *limits) | |||
| 1311 | 1453 | ||
| 1312 | static int intel_pstate_set_policy(struct cpufreq_policy *policy) | 1454 | static int intel_pstate_set_policy(struct cpufreq_policy *policy) |
| 1313 | { | 1455 | { |
| 1456 | struct cpudata *cpu; | ||
| 1457 | |||
| 1314 | if (!policy->cpuinfo.max_freq) | 1458 | if (!policy->cpuinfo.max_freq) |
| 1315 | return -ENODEV; | 1459 | return -ENODEV; |
| 1316 | 1460 | ||
| 1317 | intel_pstate_clear_update_util_hook(policy->cpu); | 1461 | intel_pstate_clear_update_util_hook(policy->cpu); |
| 1318 | 1462 | ||
| 1463 | cpu = all_cpu_data[0]; | ||
| 1464 | if (cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate) { | ||
| 1465 | if (policy->max < policy->cpuinfo.max_freq && | ||
| 1466 | policy->max > cpu->pstate.max_pstate * cpu->pstate.scaling) { | ||
| 1467 | pr_debug("policy->max > max non turbo frequency\n"); | ||
| 1468 | policy->max = policy->cpuinfo.max_freq; | ||
| 1469 | } | ||
| 1470 | } | ||
| 1471 | |||
| 1319 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { | 1472 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { |
| 1320 | limits = &performance_limits; | 1473 | limits = &performance_limits; |
| 1321 | if (policy->max >= policy->cpuinfo.max_freq) { | 1474 | if (policy->max >= policy->cpuinfo.max_freq) { |
| 1322 | pr_debug("intel_pstate: set performance\n"); | 1475 | pr_debug("set performance\n"); |
| 1323 | intel_pstate_set_performance_limits(limits); | 1476 | intel_pstate_set_performance_limits(limits); |
| 1324 | goto out; | 1477 | goto out; |
| 1325 | } | 1478 | } |
| 1326 | } else { | 1479 | } else { |
| 1327 | pr_debug("intel_pstate: set powersave\n"); | 1480 | pr_debug("set powersave\n"); |
| 1328 | limits = &powersave_limits; | 1481 | limits = &powersave_limits; |
| 1329 | } | 1482 | } |
| 1330 | 1483 | ||
| @@ -1348,10 +1501,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) | |||
| 1348 | /* Make sure min_perf_pct <= max_perf_pct */ | 1501 | /* Make sure min_perf_pct <= max_perf_pct */ |
| 1349 | limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct); | 1502 | limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct); |
| 1350 | 1503 | ||
| 1351 | limits->min_perf = div_fp(int_tofp(limits->min_perf_pct), | 1504 | limits->min_perf = div_fp(limits->min_perf_pct, 100); |
| 1352 | int_tofp(100)); | 1505 | limits->max_perf = div_fp(limits->max_perf_pct, 100); |
| 1353 | limits->max_perf = div_fp(int_tofp(limits->max_perf_pct), | ||
| 1354 | int_tofp(100)); | ||
| 1355 | 1506 | ||
| 1356 | out: | 1507 | out: |
| 1357 | intel_pstate_set_update_util_hook(policy->cpu); | 1508 | intel_pstate_set_update_util_hook(policy->cpu); |
| @@ -1377,7 +1528,7 @@ static void intel_pstate_stop_cpu(struct cpufreq_policy *policy) | |||
| 1377 | int cpu_num = policy->cpu; | 1528 | int cpu_num = policy->cpu; |
| 1378 | struct cpudata *cpu = all_cpu_data[cpu_num]; | 1529 | struct cpudata *cpu = all_cpu_data[cpu_num]; |
| 1379 | 1530 | ||
| 1380 | pr_debug("intel_pstate: CPU %d exiting\n", cpu_num); | 1531 | pr_debug("CPU %d exiting\n", cpu_num); |
| 1381 | 1532 | ||
| 1382 | intel_pstate_clear_update_util_hook(cpu_num); | 1533 | intel_pstate_clear_update_util_hook(cpu_num); |
| 1383 | 1534 | ||
| @@ -1410,12 +1561,20 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | |||
| 1410 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; | 1561 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; |
| 1411 | policy->cpuinfo.max_freq = | 1562 | policy->cpuinfo.max_freq = |
| 1412 | cpu->pstate.turbo_pstate * cpu->pstate.scaling; | 1563 | cpu->pstate.turbo_pstate * cpu->pstate.scaling; |
| 1564 | intel_pstate_init_acpi_perf_limits(policy); | ||
| 1413 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 1565 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 1414 | cpumask_set_cpu(policy->cpu, policy->cpus); | 1566 | cpumask_set_cpu(policy->cpu, policy->cpus); |
| 1415 | 1567 | ||
| 1416 | return 0; | 1568 | return 0; |
| 1417 | } | 1569 | } |
| 1418 | 1570 | ||
| 1571 | static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) | ||
| 1572 | { | ||
| 1573 | intel_pstate_exit_perf_limits(policy); | ||
| 1574 | |||
| 1575 | return 0; | ||
| 1576 | } | ||
| 1577 | |||
| 1419 | static struct cpufreq_driver intel_pstate_driver = { | 1578 | static struct cpufreq_driver intel_pstate_driver = { |
| 1420 | .flags = CPUFREQ_CONST_LOOPS, | 1579 | .flags = CPUFREQ_CONST_LOOPS, |
| 1421 | .verify = intel_pstate_verify_policy, | 1580 | .verify = intel_pstate_verify_policy, |
| @@ -1423,6 +1582,7 @@ static struct cpufreq_driver intel_pstate_driver = { | |||
| 1423 | .resume = intel_pstate_hwp_set_policy, | 1582 | .resume = intel_pstate_hwp_set_policy, |
| 1424 | .get = intel_pstate_get, | 1583 | .get = intel_pstate_get, |
| 1425 | .init = intel_pstate_cpu_init, | 1584 | .init = intel_pstate_cpu_init, |
| 1585 | .exit = intel_pstate_cpu_exit, | ||
| 1426 | .stop_cpu = intel_pstate_stop_cpu, | 1586 | .stop_cpu = intel_pstate_stop_cpu, |
| 1427 | .name = "intel_pstate", | 1587 | .name = "intel_pstate", |
| 1428 | }; | 1588 | }; |
| @@ -1466,8 +1626,7 @@ static void copy_cpu_funcs(struct pstate_funcs *funcs) | |||
| 1466 | 1626 | ||
| 1467 | } | 1627 | } |
| 1468 | 1628 | ||
| 1469 | #if IS_ENABLED(CONFIG_ACPI) | 1629 | #ifdef CONFIG_ACPI |
| 1470 | #include <acpi/processor.h> | ||
| 1471 | 1630 | ||
| 1472 | static bool intel_pstate_no_acpi_pss(void) | 1631 | static bool intel_pstate_no_acpi_pss(void) |
| 1473 | { | 1632 | { |
| @@ -1623,7 +1782,7 @@ hwp_cpu_matched: | |||
| 1623 | if (intel_pstate_platform_pwr_mgmt_exists()) | 1782 | if (intel_pstate_platform_pwr_mgmt_exists()) |
| 1624 | return -ENODEV; | 1783 | return -ENODEV; |
| 1625 | 1784 | ||
| 1626 | pr_info("Intel P-state driver initializing.\n"); | 1785 | pr_info("Intel P-state driver initializing\n"); |
| 1627 | 1786 | ||
| 1628 | all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus()); | 1787 | all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus()); |
| 1629 | if (!all_cpu_data) | 1788 | if (!all_cpu_data) |
| @@ -1640,7 +1799,7 @@ hwp_cpu_matched: | |||
| 1640 | intel_pstate_sysfs_expose_params(); | 1799 | intel_pstate_sysfs_expose_params(); |
| 1641 | 1800 | ||
| 1642 | if (hwp_active) | 1801 | if (hwp_active) |
| 1643 | pr_info("intel_pstate: HWP enabled\n"); | 1802 | pr_info("HWP enabled\n"); |
| 1644 | 1803 | ||
| 1645 | return rc; | 1804 | return rc; |
| 1646 | out: | 1805 | out: |
| @@ -1666,13 +1825,19 @@ static int __init intel_pstate_setup(char *str) | |||
| 1666 | if (!strcmp(str, "disable")) | 1825 | if (!strcmp(str, "disable")) |
| 1667 | no_load = 1; | 1826 | no_load = 1; |
| 1668 | if (!strcmp(str, "no_hwp")) { | 1827 | if (!strcmp(str, "no_hwp")) { |
| 1669 | pr_info("intel_pstate: HWP disabled\n"); | 1828 | pr_info("HWP disabled\n"); |
| 1670 | no_hwp = 1; | 1829 | no_hwp = 1; |
| 1671 | } | 1830 | } |
| 1672 | if (!strcmp(str, "force")) | 1831 | if (!strcmp(str, "force")) |
| 1673 | force_load = 1; | 1832 | force_load = 1; |
| 1674 | if (!strcmp(str, "hwp_only")) | 1833 | if (!strcmp(str, "hwp_only")) |
| 1675 | hwp_only = 1; | 1834 | hwp_only = 1; |
| 1835 | |||
| 1836 | #ifdef CONFIG_ACPI | ||
| 1837 | if (!strcmp(str, "support_acpi_ppc")) | ||
| 1838 | acpi_ppc = true; | ||
| 1839 | #endif | ||
| 1840 | |||
| 1676 | return 0; | 1841 | return 0; |
| 1677 | } | 1842 | } |
| 1678 | early_param("intel_pstate", intel_pstate_setup); | 1843 | early_param("intel_pstate", intel_pstate_setup); |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 0f6b229afcb9..beae5cf5c62c 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* | 21 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 25 | |||
| 24 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
| 25 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 26 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
| @@ -40,8 +42,6 @@ | |||
| 40 | 42 | ||
| 41 | #include "longhaul.h" | 43 | #include "longhaul.h" |
| 42 | 44 | ||
| 43 | #define PFX "longhaul: " | ||
| 44 | |||
| 45 | #define TYPE_LONGHAUL_V1 1 | 45 | #define TYPE_LONGHAUL_V1 1 |
| 46 | #define TYPE_LONGHAUL_V2 2 | 46 | #define TYPE_LONGHAUL_V2 2 |
| 47 | #define TYPE_POWERSAVER 3 | 47 | #define TYPE_POWERSAVER 3 |
| @@ -347,14 +347,13 @@ retry_loop: | |||
| 347 | freqs.new = calc_speed(longhaul_get_cpu_mult()); | 347 | freqs.new = calc_speed(longhaul_get_cpu_mult()); |
| 348 | /* Check if requested frequency is set. */ | 348 | /* Check if requested frequency is set. */ |
| 349 | if (unlikely(freqs.new != speed)) { | 349 | if (unlikely(freqs.new != speed)) { |
| 350 | printk(KERN_INFO PFX "Failed to set requested frequency!\n"); | 350 | pr_info("Failed to set requested frequency!\n"); |
| 351 | /* Revision ID = 1 but processor is expecting revision key | 351 | /* Revision ID = 1 but processor is expecting revision key |
| 352 | * equal to 0. Jumpers at the bottom of processor will change | 352 | * equal to 0. Jumpers at the bottom of processor will change |
| 353 | * multiplier and FSB, but will not change bits in Longhaul | 353 | * multiplier and FSB, but will not change bits in Longhaul |
| 354 | * MSR nor enable voltage scaling. */ | 354 | * MSR nor enable voltage scaling. */ |
| 355 | if (!revid_errata) { | 355 | if (!revid_errata) { |
| 356 | printk(KERN_INFO PFX "Enabling \"Ignore Revision ID\" " | 356 | pr_info("Enabling \"Ignore Revision ID\" option\n"); |
| 357 | "option.\n"); | ||
| 358 | revid_errata = 1; | 357 | revid_errata = 1; |
| 359 | msleep(200); | 358 | msleep(200); |
| 360 | goto retry_loop; | 359 | goto retry_loop; |
| @@ -364,11 +363,10 @@ retry_loop: | |||
| 364 | * but it doesn't change frequency. I tried poking various | 363 | * but it doesn't change frequency. I tried poking various |
| 365 | * bits in northbridge registers, but without success. */ | 364 | * bits in northbridge registers, but without success. */ |
| 366 | if (longhaul_flags & USE_ACPI_C3) { | 365 | if (longhaul_flags & USE_ACPI_C3) { |
| 367 | printk(KERN_INFO PFX "Disabling ACPI C3 support.\n"); | 366 | pr_info("Disabling ACPI C3 support\n"); |
| 368 | longhaul_flags &= ~USE_ACPI_C3; | 367 | longhaul_flags &= ~USE_ACPI_C3; |
| 369 | if (revid_errata) { | 368 | if (revid_errata) { |
| 370 | printk(KERN_INFO PFX "Disabling \"Ignore " | 369 | pr_info("Disabling \"Ignore Revision ID\" option\n"); |
| 371 | "Revision ID\" option.\n"); | ||
| 372 | revid_errata = 0; | 370 | revid_errata = 0; |
| 373 | } | 371 | } |
| 374 | msleep(200); | 372 | msleep(200); |
| @@ -379,7 +377,7 @@ retry_loop: | |||
| 379 | * RevID = 1. RevID errata will make things right. Just | 377 | * RevID = 1. RevID errata will make things right. Just |
| 380 | * to be 100% sure. */ | 378 | * to be 100% sure. */ |
| 381 | if (longhaul_version == TYPE_LONGHAUL_V2) { | 379 | if (longhaul_version == TYPE_LONGHAUL_V2) { |
| 382 | printk(KERN_INFO PFX "Switching to Longhaul ver. 1\n"); | 380 | pr_info("Switching to Longhaul ver. 1\n"); |
| 383 | longhaul_version = TYPE_LONGHAUL_V1; | 381 | longhaul_version = TYPE_LONGHAUL_V1; |
| 384 | msleep(200); | 382 | msleep(200); |
| 385 | goto retry_loop; | 383 | goto retry_loop; |
| @@ -387,8 +385,7 @@ retry_loop: | |||
| 387 | } | 385 | } |
| 388 | 386 | ||
| 389 | if (!bm_timeout) { | 387 | if (!bm_timeout) { |
| 390 | printk(KERN_INFO PFX "Warning: Timeout while waiting for " | 388 | pr_info("Warning: Timeout while waiting for idle PCI bus\n"); |
| 391 | "idle PCI bus.\n"); | ||
| 392 | return -EBUSY; | 389 | return -EBUSY; |
| 393 | } | 390 | } |
| 394 | 391 | ||
| @@ -433,12 +430,12 @@ static int longhaul_get_ranges(void) | |||
| 433 | /* Get current frequency */ | 430 | /* Get current frequency */ |
| 434 | mult = longhaul_get_cpu_mult(); | 431 | mult = longhaul_get_cpu_mult(); |
| 435 | if (mult == -1) { | 432 | if (mult == -1) { |
| 436 | printk(KERN_INFO PFX "Invalid (reserved) multiplier!\n"); | 433 | pr_info("Invalid (reserved) multiplier!\n"); |
| 437 | return -EINVAL; | 434 | return -EINVAL; |
| 438 | } | 435 | } |
| 439 | fsb = guess_fsb(mult); | 436 | fsb = guess_fsb(mult); |
| 440 | if (fsb == 0) { | 437 | if (fsb == 0) { |
| 441 | printk(KERN_INFO PFX "Invalid (reserved) FSB!\n"); | 438 | pr_info("Invalid (reserved) FSB!\n"); |
| 442 | return -EINVAL; | 439 | return -EINVAL; |
| 443 | } | 440 | } |
| 444 | /* Get max multiplier - as we always did. | 441 | /* Get max multiplier - as we always did. |
| @@ -468,11 +465,11 @@ static int longhaul_get_ranges(void) | |||
| 468 | print_speed(highest_speed/1000)); | 465 | print_speed(highest_speed/1000)); |
| 469 | 466 | ||
| 470 | if (lowest_speed == highest_speed) { | 467 | if (lowest_speed == highest_speed) { |
| 471 | printk(KERN_INFO PFX "highestspeed == lowest, aborting.\n"); | 468 | pr_info("highestspeed == lowest, aborting\n"); |
| 472 | return -EINVAL; | 469 | return -EINVAL; |
| 473 | } | 470 | } |
| 474 | if (lowest_speed > highest_speed) { | 471 | if (lowest_speed > highest_speed) { |
| 475 | printk(KERN_INFO PFX "nonsense! lowest (%d > %d) !\n", | 472 | pr_info("nonsense! lowest (%d > %d) !\n", |
| 476 | lowest_speed, highest_speed); | 473 | lowest_speed, highest_speed); |
| 477 | return -EINVAL; | 474 | return -EINVAL; |
| 478 | } | 475 | } |
| @@ -538,16 +535,16 @@ static void longhaul_setup_voltagescaling(void) | |||
| 538 | 535 | ||
| 539 | rdmsrl(MSR_VIA_LONGHAUL, longhaul.val); | 536 | rdmsrl(MSR_VIA_LONGHAUL, longhaul.val); |
| 540 | if (!(longhaul.bits.RevisionID & 1)) { | 537 | if (!(longhaul.bits.RevisionID & 1)) { |
| 541 | printk(KERN_INFO PFX "Voltage scaling not supported by CPU.\n"); | 538 | pr_info("Voltage scaling not supported by CPU\n"); |
| 542 | return; | 539 | return; |
| 543 | } | 540 | } |
| 544 | 541 | ||
| 545 | if (!longhaul.bits.VRMRev) { | 542 | if (!longhaul.bits.VRMRev) { |
| 546 | printk(KERN_INFO PFX "VRM 8.5\n"); | 543 | pr_info("VRM 8.5\n"); |
| 547 | vrm_mV_table = &vrm85_mV[0]; | 544 | vrm_mV_table = &vrm85_mV[0]; |
| 548 | mV_vrm_table = &mV_vrm85[0]; | 545 | mV_vrm_table = &mV_vrm85[0]; |
| 549 | } else { | 546 | } else { |
| 550 | printk(KERN_INFO PFX "Mobile VRM\n"); | 547 | pr_info("Mobile VRM\n"); |
| 551 | if (cpu_model < CPU_NEHEMIAH) | 548 | if (cpu_model < CPU_NEHEMIAH) |
| 552 | return; | 549 | return; |
| 553 | vrm_mV_table = &mobilevrm_mV[0]; | 550 | vrm_mV_table = &mobilevrm_mV[0]; |
| @@ -558,27 +555,21 @@ static void longhaul_setup_voltagescaling(void) | |||
| 558 | maxvid = vrm_mV_table[longhaul.bits.MaximumVID]; | 555 | maxvid = vrm_mV_table[longhaul.bits.MaximumVID]; |
| 559 | 556 | ||
| 560 | if (minvid.mV == 0 || maxvid.mV == 0 || minvid.mV > maxvid.mV) { | 557 | if (minvid.mV == 0 || maxvid.mV == 0 || minvid.mV > maxvid.mV) { |
| 561 | printk(KERN_INFO PFX "Bogus values Min:%d.%03d Max:%d.%03d. " | 558 | pr_info("Bogus values Min:%d.%03d Max:%d.%03d - Voltage scaling disabled\n", |
| 562 | "Voltage scaling disabled.\n", | 559 | minvid.mV/1000, minvid.mV%1000, |
| 563 | minvid.mV/1000, minvid.mV%1000, | 560 | maxvid.mV/1000, maxvid.mV%1000); |
| 564 | maxvid.mV/1000, maxvid.mV%1000); | ||
| 565 | return; | 561 | return; |
| 566 | } | 562 | } |
| 567 | 563 | ||
| 568 | if (minvid.mV == maxvid.mV) { | 564 | if (minvid.mV == maxvid.mV) { |
| 569 | printk(KERN_INFO PFX "Claims to support voltage scaling but " | 565 | pr_info("Claims to support voltage scaling but min & max are both %d.%03d - Voltage scaling disabled\n", |
| 570 | "min & max are both %d.%03d. " | 566 | maxvid.mV/1000, maxvid.mV%1000); |
| 571 | "Voltage scaling disabled\n", | ||
| 572 | maxvid.mV/1000, maxvid.mV%1000); | ||
| 573 | return; | 567 | return; |
| 574 | } | 568 | } |
| 575 | 569 | ||
| 576 | /* How many voltage steps*/ | 570 | /* How many voltage steps*/ |
| 577 | numvscales = maxvid.pos - minvid.pos + 1; | 571 | numvscales = maxvid.pos - minvid.pos + 1; |
| 578 | printk(KERN_INFO PFX | 572 | pr_info("Max VID=%d.%03d Min VID=%d.%03d, %d possible voltage scales\n", |
| 579 | "Max VID=%d.%03d " | ||
| 580 | "Min VID=%d.%03d, " | ||
| 581 | "%d possible voltage scales\n", | ||
| 582 | maxvid.mV/1000, maxvid.mV%1000, | 573 | maxvid.mV/1000, maxvid.mV%1000, |
| 583 | minvid.mV/1000, minvid.mV%1000, | 574 | minvid.mV/1000, minvid.mV%1000, |
| 584 | numvscales); | 575 | numvscales); |
| @@ -617,12 +608,12 @@ static void longhaul_setup_voltagescaling(void) | |||
| 617 | pos = minvid.pos; | 608 | pos = minvid.pos; |
| 618 | freq_pos->driver_data |= mV_vrm_table[pos] << 8; | 609 | freq_pos->driver_data |= mV_vrm_table[pos] << 8; |
| 619 | vid = vrm_mV_table[mV_vrm_table[pos]]; | 610 | vid = vrm_mV_table[mV_vrm_table[pos]]; |
| 620 | printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", | 611 | pr_info("f: %d kHz, index: %d, vid: %d mV\n", |
| 621 | speed, (int)(freq_pos - longhaul_table), vid.mV); | 612 | speed, (int)(freq_pos - longhaul_table), vid.mV); |
| 622 | } | 613 | } |
| 623 | 614 | ||
| 624 | can_scale_voltage = 1; | 615 | can_scale_voltage = 1; |
| 625 | printk(KERN_INFO PFX "Voltage scaling enabled.\n"); | 616 | pr_info("Voltage scaling enabled\n"); |
| 626 | } | 617 | } |
| 627 | 618 | ||
| 628 | 619 | ||
| @@ -720,8 +711,7 @@ static int enable_arbiter_disable(void) | |||
| 720 | pci_write_config_byte(dev, reg, pci_cmd); | 711 | pci_write_config_byte(dev, reg, pci_cmd); |
| 721 | pci_read_config_byte(dev, reg, &pci_cmd); | 712 | pci_read_config_byte(dev, reg, &pci_cmd); |
| 722 | if (!(pci_cmd & 1<<7)) { | 713 | if (!(pci_cmd & 1<<7)) { |
| 723 | printk(KERN_ERR PFX | 714 | pr_err("Can't enable access to port 0x22\n"); |
| 724 | "Can't enable access to port 0x22.\n"); | ||
| 725 | status = 0; | 715 | status = 0; |
| 726 | } | 716 | } |
| 727 | } | 717 | } |
| @@ -758,8 +748,7 @@ static int longhaul_setup_southbridge(void) | |||
| 758 | if (pci_cmd & 1 << 7) { | 748 | if (pci_cmd & 1 << 7) { |
| 759 | pci_read_config_dword(dev, 0x88, &acpi_regs_addr); | 749 | pci_read_config_dword(dev, 0x88, &acpi_regs_addr); |
| 760 | acpi_regs_addr &= 0xff00; | 750 | acpi_regs_addr &= 0xff00; |
| 761 | printk(KERN_INFO PFX "ACPI I/O at 0x%x\n", | 751 | pr_info("ACPI I/O at 0x%x\n", acpi_regs_addr); |
| 762 | acpi_regs_addr); | ||
| 763 | } | 752 | } |
| 764 | 753 | ||
| 765 | pci_dev_put(dev); | 754 | pci_dev_put(dev); |
| @@ -853,14 +842,14 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy) | |||
| 853 | longhaul_version = TYPE_LONGHAUL_V1; | 842 | longhaul_version = TYPE_LONGHAUL_V1; |
| 854 | } | 843 | } |
| 855 | 844 | ||
| 856 | printk(KERN_INFO PFX "VIA %s CPU detected. ", cpuname); | 845 | pr_info("VIA %s CPU detected. ", cpuname); |
| 857 | switch (longhaul_version) { | 846 | switch (longhaul_version) { |
| 858 | case TYPE_LONGHAUL_V1: | 847 | case TYPE_LONGHAUL_V1: |
| 859 | case TYPE_LONGHAUL_V2: | 848 | case TYPE_LONGHAUL_V2: |
| 860 | printk(KERN_CONT "Longhaul v%d supported.\n", longhaul_version); | 849 | pr_cont("Longhaul v%d supported\n", longhaul_version); |
| 861 | break; | 850 | break; |
| 862 | case TYPE_POWERSAVER: | 851 | case TYPE_POWERSAVER: |
| 863 | printk(KERN_CONT "Powersaver supported.\n"); | 852 | pr_cont("Powersaver supported\n"); |
| 864 | break; | 853 | break; |
| 865 | }; | 854 | }; |
| 866 | 855 | ||
| @@ -889,15 +878,14 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy) | |||
| 889 | if (!(longhaul_flags & USE_ACPI_C3 | 878 | if (!(longhaul_flags & USE_ACPI_C3 |
| 890 | || longhaul_flags & USE_NORTHBRIDGE) | 879 | || longhaul_flags & USE_NORTHBRIDGE) |
| 891 | && ((pr == NULL) || !(pr->flags.bm_control))) { | 880 | && ((pr == NULL) || !(pr->flags.bm_control))) { |
| 892 | printk(KERN_ERR PFX | 881 | pr_err("No ACPI support: Unsupported northbridge\n"); |
| 893 | "No ACPI support. Unsupported northbridge.\n"); | ||
| 894 | return -ENODEV; | 882 | return -ENODEV; |
| 895 | } | 883 | } |
| 896 | 884 | ||
| 897 | if (longhaul_flags & USE_NORTHBRIDGE) | 885 | if (longhaul_flags & USE_NORTHBRIDGE) |
| 898 | printk(KERN_INFO PFX "Using northbridge support.\n"); | 886 | pr_info("Using northbridge support\n"); |
| 899 | if (longhaul_flags & USE_ACPI_C3) | 887 | if (longhaul_flags & USE_ACPI_C3) |
| 900 | printk(KERN_INFO PFX "Using ACPI support.\n"); | 888 | pr_info("Using ACPI support\n"); |
| 901 | 889 | ||
| 902 | ret = longhaul_get_ranges(); | 890 | ret = longhaul_get_ranges(); |
| 903 | if (ret != 0) | 891 | if (ret != 0) |
| @@ -934,20 +922,18 @@ static int __init longhaul_init(void) | |||
| 934 | return -ENODEV; | 922 | return -ENODEV; |
| 935 | 923 | ||
| 936 | if (!enable) { | 924 | if (!enable) { |
| 937 | printk(KERN_ERR PFX "Option \"enable\" not set. Aborting.\n"); | 925 | pr_err("Option \"enable\" not set - Aborting\n"); |
| 938 | return -ENODEV; | 926 | return -ENODEV; |
| 939 | } | 927 | } |
| 940 | #ifdef CONFIG_SMP | 928 | #ifdef CONFIG_SMP |
| 941 | if (num_online_cpus() > 1) { | 929 | if (num_online_cpus() > 1) { |
| 942 | printk(KERN_ERR PFX "More than 1 CPU detected, " | 930 | pr_err("More than 1 CPU detected, longhaul disabled\n"); |
| 943 | "longhaul disabled.\n"); | ||
| 944 | return -ENODEV; | 931 | return -ENODEV; |
| 945 | } | 932 | } |
| 946 | #endif | 933 | #endif |
| 947 | #ifdef CONFIG_X86_IO_APIC | 934 | #ifdef CONFIG_X86_IO_APIC |
| 948 | if (cpu_has_apic) { | 935 | if (cpu_has_apic) { |
| 949 | printk(KERN_ERR PFX "APIC detected. Longhaul is currently " | 936 | pr_err("APIC detected. Longhaul is currently broken in this configuration.\n"); |
| 950 | "broken in this configuration.\n"); | ||
| 951 | return -ENODEV; | 937 | return -ENODEV; |
| 952 | } | 938 | } |
| 953 | #endif | 939 | #endif |
| @@ -955,7 +941,7 @@ static int __init longhaul_init(void) | |||
| 955 | case 6 ... 9: | 941 | case 6 ... 9: |
| 956 | return cpufreq_register_driver(&longhaul_driver); | 942 | return cpufreq_register_driver(&longhaul_driver); |
| 957 | case 10: | 943 | case 10: |
| 958 | printk(KERN_ERR PFX "Use acpi-cpufreq driver for VIA C7\n"); | 944 | pr_err("Use acpi-cpufreq driver for VIA C7\n"); |
| 959 | default: | 945 | default: |
| 960 | ; | 946 | ; |
| 961 | } | 947 | } |
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c index cd593c1f66dc..6bbdac1065ff 100644 --- a/drivers/cpufreq/loongson2_cpufreq.c +++ b/drivers/cpufreq/loongson2_cpufreq.c | |||
| @@ -10,6 +10,9 @@ | |||
| 10 | * License. See the file "COPYING" in the main directory of this archive | 10 | * License. See the file "COPYING" in the main directory of this archive |
| 11 | * for more details. | 11 | * for more details. |
| 12 | */ | 12 | */ |
| 13 | |||
| 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 15 | |||
| 13 | #include <linux/cpufreq.h> | 16 | #include <linux/cpufreq.h> |
| 14 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 15 | #include <linux/err.h> | 18 | #include <linux/err.h> |
| @@ -76,7 +79,7 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 76 | 79 | ||
| 77 | cpuclk = clk_get(NULL, "cpu_clk"); | 80 | cpuclk = clk_get(NULL, "cpu_clk"); |
| 78 | if (IS_ERR(cpuclk)) { | 81 | if (IS_ERR(cpuclk)) { |
| 79 | printk(KERN_ERR "cpufreq: couldn't get CPU clk\n"); | 82 | pr_err("couldn't get CPU clk\n"); |
| 80 | return PTR_ERR(cpuclk); | 83 | return PTR_ERR(cpuclk); |
| 81 | } | 84 | } |
| 82 | 85 | ||
| @@ -163,7 +166,7 @@ static int __init cpufreq_init(void) | |||
| 163 | if (ret) | 166 | if (ret) |
| 164 | return ret; | 167 | return ret; |
| 165 | 168 | ||
| 166 | pr_info("cpufreq: Loongson-2F CPU frequency driver.\n"); | 169 | pr_info("Loongson-2F CPU frequency driver\n"); |
| 167 | 170 | ||
| 168 | cpufreq_register_notifier(&loongson2_cpufreq_notifier_block, | 171 | cpufreq_register_notifier(&loongson2_cpufreq_notifier_block, |
| 169 | CPUFREQ_TRANSITION_NOTIFIER); | 172 | CPUFREQ_TRANSITION_NOTIFIER); |
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c index cc3408fc073f..d9df89392b84 100644 --- a/drivers/cpufreq/maple-cpufreq.c +++ b/drivers/cpufreq/maple-cpufreq.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | 13 | ||
| 14 | #undef DEBUG | 14 | #undef DEBUG |
| 15 | 15 | ||
| 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 17 | |||
| 16 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 17 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 18 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
| @@ -174,7 +176,7 @@ static int __init maple_cpufreq_init(void) | |||
| 174 | /* Get first CPU node */ | 176 | /* Get first CPU node */ |
| 175 | cpunode = of_cpu_device_node_get(0); | 177 | cpunode = of_cpu_device_node_get(0); |
| 176 | if (cpunode == NULL) { | 178 | if (cpunode == NULL) { |
| 177 | printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n"); | 179 | pr_err("Can't find any CPU 0 node\n"); |
| 178 | goto bail_noprops; | 180 | goto bail_noprops; |
| 179 | } | 181 | } |
| 180 | 182 | ||
| @@ -182,8 +184,7 @@ static int __init maple_cpufreq_init(void) | |||
| 182 | /* we actually don't care on which CPU to access PVR */ | 184 | /* we actually don't care on which CPU to access PVR */ |
| 183 | pvr_hi = PVR_VER(mfspr(SPRN_PVR)); | 185 | pvr_hi = PVR_VER(mfspr(SPRN_PVR)); |
| 184 | if (pvr_hi != 0x3c && pvr_hi != 0x44) { | 186 | if (pvr_hi != 0x3c && pvr_hi != 0x44) { |
| 185 | printk(KERN_ERR "cpufreq: Unsupported CPU version (%x)\n", | 187 | pr_err("Unsupported CPU version (%x)\n", pvr_hi); |
| 186 | pvr_hi); | ||
| 187 | goto bail_noprops; | 188 | goto bail_noprops; |
| 188 | } | 189 | } |
| 189 | 190 | ||
| @@ -222,8 +223,8 @@ static int __init maple_cpufreq_init(void) | |||
| 222 | maple_pmode_cur = -1; | 223 | maple_pmode_cur = -1; |
| 223 | maple_scom_switch_freq(maple_scom_query_freq()); | 224 | maple_scom_switch_freq(maple_scom_query_freq()); |
| 224 | 225 | ||
| 225 | printk(KERN_INFO "Registering Maple CPU frequency driver\n"); | 226 | pr_info("Registering Maple CPU frequency driver\n"); |
| 226 | printk(KERN_INFO "Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n", | 227 | pr_info("Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n", |
| 227 | maple_cpu_freqs[1].frequency/1000, | 228 | maple_cpu_freqs[1].frequency/1000, |
| 228 | maple_cpu_freqs[0].frequency/1000, | 229 | maple_cpu_freqs[0].frequency/1000, |
| 229 | maple_cpu_freqs[maple_pmode_cur].frequency/1000); | 230 | maple_cpu_freqs[maple_pmode_cur].frequency/1000); |
diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c index 2058e6d292ce..6f602c7a71bd 100644 --- a/drivers/cpufreq/mt8173-cpufreq.c +++ b/drivers/cpufreq/mt8173-cpufreq.c | |||
| @@ -59,11 +59,8 @@ static LIST_HEAD(dvfs_info_list); | |||
| 59 | static struct mtk_cpu_dvfs_info *mtk_cpu_dvfs_info_lookup(int cpu) | 59 | static struct mtk_cpu_dvfs_info *mtk_cpu_dvfs_info_lookup(int cpu) |
| 60 | { | 60 | { |
| 61 | struct mtk_cpu_dvfs_info *info; | 61 | struct mtk_cpu_dvfs_info *info; |
| 62 | struct list_head *list; | ||
| 63 | |||
| 64 | list_for_each(list, &dvfs_info_list) { | ||
| 65 | info = list_entry(list, struct mtk_cpu_dvfs_info, list_head); | ||
| 66 | 62 | ||
| 63 | list_for_each_entry(info, &dvfs_info_list, list_head) { | ||
| 67 | if (cpumask_test_cpu(cpu, &info->cpus)) | 64 | if (cpumask_test_cpu(cpu, &info->cpus)) |
| 68 | return info; | 65 | return info; |
| 69 | } | 66 | } |
| @@ -524,8 +521,7 @@ static struct cpufreq_driver mt8173_cpufreq_driver = { | |||
| 524 | 521 | ||
| 525 | static int mt8173_cpufreq_probe(struct platform_device *pdev) | 522 | static int mt8173_cpufreq_probe(struct platform_device *pdev) |
| 526 | { | 523 | { |
| 527 | struct mtk_cpu_dvfs_info *info; | 524 | struct mtk_cpu_dvfs_info *info, *tmp; |
| 528 | struct list_head *list, *tmp; | ||
| 529 | int cpu, ret; | 525 | int cpu, ret; |
| 530 | 526 | ||
| 531 | for_each_possible_cpu(cpu) { | 527 | for_each_possible_cpu(cpu) { |
| @@ -559,11 +555,9 @@ static int mt8173_cpufreq_probe(struct platform_device *pdev) | |||
| 559 | return 0; | 555 | return 0; |
| 560 | 556 | ||
| 561 | release_dvfs_info_list: | 557 | release_dvfs_info_list: |
| 562 | list_for_each_safe(list, tmp, &dvfs_info_list) { | 558 | list_for_each_entry_safe(info, tmp, &dvfs_info_list, list_head) { |
| 563 | info = list_entry(list, struct mtk_cpu_dvfs_info, list_head); | ||
| 564 | |||
| 565 | mtk_cpu_dvfs_info_release(info); | 559 | mtk_cpu_dvfs_info_release(info); |
| 566 | list_del(list); | 560 | list_del(&info->list_head); |
| 567 | } | 561 | } |
| 568 | 562 | ||
| 569 | return ret; | 563 | return ret; |
diff --git a/drivers/cpufreq/mvebu-cpufreq.c b/drivers/cpufreq/mvebu-cpufreq.c new file mode 100644 index 000000000000..e920889b9ac2 --- /dev/null +++ b/drivers/cpufreq/mvebu-cpufreq.c | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | /* | ||
| 2 | * CPUFreq support for Armada 370/XP platforms. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012-2016 Marvell | ||
| 5 | * | ||
| 6 | * Yehuda Yitschak <yehuday@marvell.com> | ||
| 7 | * Gregory Clement <gregory.clement@free-electrons.com> | ||
| 8 | * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | ||
| 9 | * | ||
| 10 | * This file is licensed under the terms of the GNU General Public | ||
| 11 | * License version 2. This program is licensed "as is" without any | ||
| 12 | * warranty of any kind, whether express or implied. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #define pr_fmt(fmt) "mvebu-pmsu: " fmt | ||
| 16 | |||
| 17 | #include <linux/clk.h> | ||
| 18 | #include <linux/cpu.h> | ||
| 19 | #include <linux/init.h> | ||
| 20 | #include <linux/kernel.h> | ||
| 21 | #include <linux/of_address.h> | ||
| 22 | #include <linux/platform_device.h> | ||
| 23 | #include <linux/pm_opp.h> | ||
| 24 | #include <linux/resource.h> | ||
| 25 | |||
| 26 | static int __init armada_xp_pmsu_cpufreq_init(void) | ||
| 27 | { | ||
| 28 | struct device_node *np; | ||
| 29 | struct resource res; | ||
| 30 | int ret, cpu; | ||
| 31 | |||
| 32 | if (!of_machine_is_compatible("marvell,armadaxp")) | ||
| 33 | return 0; | ||
| 34 | |||
| 35 | /* | ||
| 36 | * In order to have proper cpufreq handling, we need to ensure | ||
| 37 | * that the Device Tree description of the CPU clock includes | ||
| 38 | * the definition of the PMU DFS registers. If not, we do not | ||
| 39 | * register the clock notifier and the cpufreq driver. This | ||
| 40 | * piece of code is only for compatibility with old Device | ||
| 41 | * Trees. | ||
| 42 | */ | ||
| 43 | np = of_find_compatible_node(NULL, NULL, "marvell,armada-xp-cpu-clock"); | ||
| 44 | if (!np) | ||
| 45 | return 0; | ||
| 46 | |||
| 47 | ret = of_address_to_resource(np, 1, &res); | ||
| 48 | if (ret) { | ||
| 49 | pr_warn(FW_WARN "not enabling cpufreq, deprecated armada-xp-cpu-clock binding\n"); | ||
| 50 | of_node_put(np); | ||
| 51 | return 0; | ||
| 52 | } | ||
| 53 | |||
| 54 | of_node_put(np); | ||
| 55 | |||
| 56 | /* | ||
| 57 | * For each CPU, this loop registers the operating points | ||
| 58 | * supported (which are the nominal CPU frequency and half of | ||
| 59 | * it), and registers the clock notifier that will take care | ||
| 60 | * of doing the PMSU part of a frequency transition. | ||
| 61 | */ | ||
| 62 | for_each_possible_cpu(cpu) { | ||
| 63 | struct device *cpu_dev; | ||
| 64 | struct clk *clk; | ||
| 65 | int ret; | ||
| 66 | |||
| 67 | cpu_dev = get_cpu_device(cpu); | ||
| 68 | if (!cpu_dev) { | ||
| 69 | pr_err("Cannot get CPU %d\n", cpu); | ||
| 70 | continue; | ||
| 71 | } | ||
| 72 | |||
| 73 | clk = clk_get(cpu_dev, 0); | ||
| 74 | if (IS_ERR(clk)) { | ||
| 75 | pr_err("Cannot get clock for CPU %d\n", cpu); | ||
| 76 | return PTR_ERR(clk); | ||
| 77 | } | ||
| 78 | |||
| 79 | /* | ||
| 80 | * In case of a failure of dev_pm_opp_add(), we don't | ||
| 81 | * bother with cleaning up the registered OPP (there's | ||
| 82 | * no function to do so), and simply cancel the | ||
| 83 | * registration of the cpufreq device. | ||
| 84 | */ | ||
| 85 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0); | ||
| 86 | if (ret) { | ||
| 87 | clk_put(clk); | ||
| 88 | return ret; | ||
| 89 | } | ||
| 90 | |||
| 91 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0); | ||
| 92 | if (ret) { | ||
| 93 | clk_put(clk); | ||
| 94 | return ret; | ||
| 95 | } | ||
| 96 | |||
| 97 | ret = dev_pm_opp_set_sharing_cpus(cpu_dev, | ||
| 98 | cpumask_of(cpu_dev->id)); | ||
| 99 | if (ret) | ||
| 100 | dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", | ||
| 101 | __func__, ret); | ||
| 102 | } | ||
| 103 | |||
| 104 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
| 105 | return 0; | ||
| 106 | } | ||
| 107 | device_initcall(armada_xp_pmsu_cpufreq_init); | ||
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index e3866e0d5bf8..cead9bec4843 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c | |||
| @@ -13,6 +13,9 @@ | |||
| 13 | * it under the terms of the GNU General Public License version 2 as | 13 | * it under the terms of the GNU General Public License version 2 as |
| 14 | * published by the Free Software Foundation. | 14 | * published by the Free Software Foundation. |
| 15 | */ | 15 | */ |
| 16 | |||
| 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 18 | |||
| 16 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 17 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
| 18 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
| @@ -163,13 +166,13 @@ static int omap_cpufreq_probe(struct platform_device *pdev) | |||
| 163 | { | 166 | { |
| 164 | mpu_dev = get_cpu_device(0); | 167 | mpu_dev = get_cpu_device(0); |
| 165 | if (!mpu_dev) { | 168 | if (!mpu_dev) { |
| 166 | pr_warning("%s: unable to get the mpu device\n", __func__); | 169 | pr_warn("%s: unable to get the MPU device\n", __func__); |
| 167 | return -EINVAL; | 170 | return -EINVAL; |
| 168 | } | 171 | } |
| 169 | 172 | ||
| 170 | mpu_reg = regulator_get(mpu_dev, "vcc"); | 173 | mpu_reg = regulator_get(mpu_dev, "vcc"); |
| 171 | if (IS_ERR(mpu_reg)) { | 174 | if (IS_ERR(mpu_reg)) { |
| 172 | pr_warning("%s: unable to get MPU regulator\n", __func__); | 175 | pr_warn("%s: unable to get MPU regulator\n", __func__); |
| 173 | mpu_reg = NULL; | 176 | mpu_reg = NULL; |
| 174 | } else { | 177 | } else { |
| 175 | /* | 178 | /* |
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c index 5dd95dab580d..fd77812313f3 100644 --- a/drivers/cpufreq/p4-clockmod.c +++ b/drivers/cpufreq/p4-clockmod.c | |||
| @@ -20,6 +20,8 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 24 | |||
| 23 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
| 24 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 25 | #include <linux/init.h> | 27 | #include <linux/init.h> |
| @@ -35,8 +37,6 @@ | |||
| 35 | 37 | ||
| 36 | #include "speedstep-lib.h" | 38 | #include "speedstep-lib.h" |
| 37 | 39 | ||
| 38 | #define PFX "p4-clockmod: " | ||
| 39 | |||
| 40 | /* | 40 | /* |
| 41 | * Duty Cycle (3bits), note DC_DISABLE is not specified in | 41 | * Duty Cycle (3bits), note DC_DISABLE is not specified in |
| 42 | * intel docs i just use it to mean disable | 42 | * intel docs i just use it to mean disable |
| @@ -124,11 +124,7 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) | |||
| 124 | { | 124 | { |
| 125 | if (c->x86 == 0x06) { | 125 | if (c->x86 == 0x06) { |
| 126 | if (cpu_has(c, X86_FEATURE_EST)) | 126 | if (cpu_has(c, X86_FEATURE_EST)) |
| 127 | printk_once(KERN_WARNING PFX "Warning: EST-capable " | 127 | pr_warn_once("Warning: EST-capable CPU detected. The acpi-cpufreq module offers voltage scaling in addition to frequency scaling. You should use that instead of p4-clockmod, if possible.\n"); |
| 128 | "CPU detected. The acpi-cpufreq module offers " | ||
| 129 | "voltage scaling in addition to frequency " | ||
| 130 | "scaling. You should use that instead of " | ||
| 131 | "p4-clockmod, if possible.\n"); | ||
| 132 | switch (c->x86_model) { | 128 | switch (c->x86_model) { |
| 133 | case 0x0E: /* Core */ | 129 | case 0x0E: /* Core */ |
| 134 | case 0x0F: /* Core Duo */ | 130 | case 0x0F: /* Core Duo */ |
| @@ -152,11 +148,7 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) | |||
| 152 | p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS; | 148 | p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS; |
| 153 | 149 | ||
| 154 | if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) { | 150 | if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) { |
| 155 | printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. " | 151 | pr_warn("Warning: Pentium 4-M detected. The speedstep-ich or acpi cpufreq modules offer voltage scaling in addition of frequency scaling. You should use either one instead of p4-clockmod, if possible.\n"); |
| 156 | "The speedstep-ich or acpi cpufreq modules offer " | ||
| 157 | "voltage scaling in addition of frequency scaling. " | ||
| 158 | "You should use either one instead of p4-clockmod, " | ||
| 159 | "if possible.\n"); | ||
| 160 | return speedstep_get_frequency(SPEEDSTEP_CPU_P4M); | 152 | return speedstep_get_frequency(SPEEDSTEP_CPU_P4M); |
| 161 | } | 153 | } |
| 162 | 154 | ||
| @@ -265,8 +257,7 @@ static int __init cpufreq_p4_init(void) | |||
| 265 | 257 | ||
| 266 | ret = cpufreq_register_driver(&p4clockmod_driver); | 258 | ret = cpufreq_register_driver(&p4clockmod_driver); |
| 267 | if (!ret) | 259 | if (!ret) |
| 268 | printk(KERN_INFO PFX "P4/Xeon(TM) CPU On-Demand Clock " | 260 | pr_info("P4/Xeon(TM) CPU On-Demand Clock Modulation available\n"); |
| 269 | "Modulation available\n"); | ||
| 270 | 261 | ||
| 271 | return ret; | 262 | return ret; |
| 272 | } | 263 | } |
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c index 1f49d97a70ea..b7b576e53e92 100644 --- a/drivers/cpufreq/pmac32-cpufreq.c +++ b/drivers/cpufreq/pmac32-cpufreq.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | * | 13 | * |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 17 | |||
| 16 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 17 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 18 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
| @@ -481,13 +483,13 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode) | |||
| 481 | freqs = of_get_property(cpunode, "bus-frequencies", &lenp); | 483 | freqs = of_get_property(cpunode, "bus-frequencies", &lenp); |
| 482 | lenp /= sizeof(u32); | 484 | lenp /= sizeof(u32); |
| 483 | if (freqs == NULL || lenp != 2) { | 485 | if (freqs == NULL || lenp != 2) { |
| 484 | printk(KERN_ERR "cpufreq: bus-frequencies incorrect or missing\n"); | 486 | pr_err("bus-frequencies incorrect or missing\n"); |
| 485 | return 1; | 487 | return 1; |
| 486 | } | 488 | } |
| 487 | ratio = of_get_property(cpunode, "processor-to-bus-ratio*2", | 489 | ratio = of_get_property(cpunode, "processor-to-bus-ratio*2", |
| 488 | NULL); | 490 | NULL); |
| 489 | if (ratio == NULL) { | 491 | if (ratio == NULL) { |
| 490 | printk(KERN_ERR "cpufreq: processor-to-bus-ratio*2 missing\n"); | 492 | pr_err("processor-to-bus-ratio*2 missing\n"); |
| 491 | return 1; | 493 | return 1; |
| 492 | } | 494 | } |
| 493 | 495 | ||
| @@ -550,7 +552,7 @@ static int pmac_cpufreq_init_7447A(struct device_node *cpunode) | |||
| 550 | if (volt_gpio_np) | 552 | if (volt_gpio_np) |
| 551 | voltage_gpio = read_gpio(volt_gpio_np); | 553 | voltage_gpio = read_gpio(volt_gpio_np); |
| 552 | if (!voltage_gpio){ | 554 | if (!voltage_gpio){ |
| 553 | printk(KERN_ERR "cpufreq: missing cpu-vcore-select gpio\n"); | 555 | pr_err("missing cpu-vcore-select gpio\n"); |
| 554 | return 1; | 556 | return 1; |
| 555 | } | 557 | } |
| 556 | 558 | ||
| @@ -675,9 +677,9 @@ out: | |||
| 675 | pmac_cpu_freqs[CPUFREQ_HIGH].frequency = hi_freq; | 677 | pmac_cpu_freqs[CPUFREQ_HIGH].frequency = hi_freq; |
| 676 | ppc_proc_freq = cur_freq * 1000ul; | 678 | ppc_proc_freq = cur_freq * 1000ul; |
| 677 | 679 | ||
| 678 | printk(KERN_INFO "Registering PowerMac CPU frequency driver\n"); | 680 | pr_info("Registering PowerMac CPU frequency driver\n"); |
| 679 | printk(KERN_INFO "Low: %d Mhz, High: %d Mhz, Boot: %d Mhz\n", | 681 | pr_info("Low: %d Mhz, High: %d Mhz, Boot: %d Mhz\n", |
| 680 | low_freq/1000, hi_freq/1000, cur_freq/1000); | 682 | low_freq/1000, hi_freq/1000, cur_freq/1000); |
| 681 | 683 | ||
| 682 | return cpufreq_register_driver(&pmac_cpufreq_driver); | 684 | return cpufreq_register_driver(&pmac_cpufreq_driver); |
| 683 | } | 685 | } |
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c index 4ff86878727f..267e0894c62d 100644 --- a/drivers/cpufreq/pmac64-cpufreq.c +++ b/drivers/cpufreq/pmac64-cpufreq.c | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | 12 | ||
| 13 | #undef DEBUG | 13 | #undef DEBUG |
| 14 | 14 | ||
| 15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 16 | |||
| 15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 16 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 17 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
| @@ -138,7 +140,7 @@ static void g5_vdnap_switch_volt(int speed_mode) | |||
| 138 | usleep_range(1000, 1000); | 140 | usleep_range(1000, 1000); |
| 139 | } | 141 | } |
| 140 | if (done == 0) | 142 | if (done == 0) |
| 141 | printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n"); | 143 | pr_warn("Timeout in clock slewing !\n"); |
| 142 | } | 144 | } |
| 143 | 145 | ||
| 144 | 146 | ||
| @@ -266,7 +268,7 @@ static int g5_pfunc_switch_freq(int speed_mode) | |||
| 266 | rc = pmf_call_one(pfunc_cpu_setfreq_low, NULL); | 268 | rc = pmf_call_one(pfunc_cpu_setfreq_low, NULL); |
| 267 | 269 | ||
| 268 | if (rc) | 270 | if (rc) |
| 269 | printk(KERN_WARNING "cpufreq: pfunc switch error %d\n", rc); | 271 | pr_warn("pfunc switch error %d\n", rc); |
| 270 | 272 | ||
| 271 | /* It's an irq GPIO so we should be able to just block here, | 273 | /* It's an irq GPIO so we should be able to just block here, |
| 272 | * I'll do that later after I've properly tested the IRQ code for | 274 | * I'll do that later after I've properly tested the IRQ code for |
| @@ -282,7 +284,7 @@ static int g5_pfunc_switch_freq(int speed_mode) | |||
| 282 | usleep_range(500, 500); | 284 | usleep_range(500, 500); |
| 283 | } | 285 | } |
| 284 | if (done == 0) | 286 | if (done == 0) |
| 285 | printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n"); | 287 | pr_warn("Timeout in clock slewing !\n"); |
| 286 | 288 | ||
| 287 | /* If frequency is going down, last ramp the voltage */ | 289 | /* If frequency is going down, last ramp the voltage */ |
| 288 | if (speed_mode > g5_pmode_cur) | 290 | if (speed_mode > g5_pmode_cur) |
| @@ -368,7 +370,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpunode) | |||
| 368 | } | 370 | } |
| 369 | pvr_hi = (*valp) >> 16; | 371 | pvr_hi = (*valp) >> 16; |
| 370 | if (pvr_hi != 0x3c && pvr_hi != 0x44) { | 372 | if (pvr_hi != 0x3c && pvr_hi != 0x44) { |
| 371 | printk(KERN_ERR "cpufreq: Unsupported CPU version\n"); | 373 | pr_err("Unsupported CPU version\n"); |
| 372 | goto bail_noprops; | 374 | goto bail_noprops; |
| 373 | } | 375 | } |
| 374 | 376 | ||
| @@ -403,8 +405,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpunode) | |||
| 403 | 405 | ||
| 404 | root = of_find_node_by_path("/"); | 406 | root = of_find_node_by_path("/"); |
| 405 | if (root == NULL) { | 407 | if (root == NULL) { |
| 406 | printk(KERN_ERR "cpufreq: Can't find root of " | 408 | pr_err("Can't find root of device tree\n"); |
| 407 | "device tree\n"); | ||
| 408 | goto bail_noprops; | 409 | goto bail_noprops; |
| 409 | } | 410 | } |
| 410 | pfunc_set_vdnap0 = pmf_find_function(root, "set-vdnap0"); | 411 | pfunc_set_vdnap0 = pmf_find_function(root, "set-vdnap0"); |
| @@ -412,8 +413,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpunode) | |||
| 412 | pmf_find_function(root, "slewing-done"); | 413 | pmf_find_function(root, "slewing-done"); |
| 413 | if (pfunc_set_vdnap0 == NULL || | 414 | if (pfunc_set_vdnap0 == NULL || |
| 414 | pfunc_vdnap0_complete == NULL) { | 415 | pfunc_vdnap0_complete == NULL) { |
| 415 | printk(KERN_ERR "cpufreq: Can't find required " | 416 | pr_err("Can't find required platform function\n"); |
| 416 | "platform function\n"); | ||
| 417 | goto bail_noprops; | 417 | goto bail_noprops; |
| 418 | } | 418 | } |
| 419 | 419 | ||
| @@ -453,10 +453,10 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpunode) | |||
| 453 | g5_pmode_cur = -1; | 453 | g5_pmode_cur = -1; |
| 454 | g5_switch_freq(g5_query_freq()); | 454 | g5_switch_freq(g5_query_freq()); |
| 455 | 455 | ||
| 456 | printk(KERN_INFO "Registering G5 CPU frequency driver\n"); | 456 | pr_info("Registering G5 CPU frequency driver\n"); |
| 457 | printk(KERN_INFO "Frequency method: %s, Voltage method: %s\n", | 457 | pr_info("Frequency method: %s, Voltage method: %s\n", |
| 458 | freq_method, volt_method); | 458 | freq_method, volt_method); |
| 459 | printk(KERN_INFO "Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n", | 459 | pr_info("Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n", |
| 460 | g5_cpu_freqs[1].frequency/1000, | 460 | g5_cpu_freqs[1].frequency/1000, |
| 461 | g5_cpu_freqs[0].frequency/1000, | 461 | g5_cpu_freqs[0].frequency/1000, |
| 462 | g5_cpu_freqs[g5_pmode_cur].frequency/1000); | 462 | g5_cpu_freqs[g5_pmode_cur].frequency/1000); |
| @@ -493,7 +493,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 493 | if (cpuid != NULL) | 493 | if (cpuid != NULL) |
| 494 | eeprom = of_get_property(cpuid, "cpuid", NULL); | 494 | eeprom = of_get_property(cpuid, "cpuid", NULL); |
| 495 | if (eeprom == NULL) { | 495 | if (eeprom == NULL) { |
| 496 | printk(KERN_ERR "cpufreq: Can't find cpuid EEPROM !\n"); | 496 | pr_err("Can't find cpuid EEPROM !\n"); |
| 497 | rc = -ENODEV; | 497 | rc = -ENODEV; |
| 498 | goto bail; | 498 | goto bail; |
| 499 | } | 499 | } |
| @@ -511,7 +511,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 511 | break; | 511 | break; |
| 512 | } | 512 | } |
| 513 | if (hwclock == NULL) { | 513 | if (hwclock == NULL) { |
| 514 | printk(KERN_ERR "cpufreq: Can't find i2c clock chip !\n"); | 514 | pr_err("Can't find i2c clock chip !\n"); |
| 515 | rc = -ENODEV; | 515 | rc = -ENODEV; |
| 516 | goto bail; | 516 | goto bail; |
| 517 | } | 517 | } |
| @@ -539,7 +539,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 539 | /* Check we have minimum requirements */ | 539 | /* Check we have minimum requirements */ |
| 540 | if (pfunc_cpu_getfreq == NULL || pfunc_cpu_setfreq_high == NULL || | 540 | if (pfunc_cpu_getfreq == NULL || pfunc_cpu_setfreq_high == NULL || |
| 541 | pfunc_cpu_setfreq_low == NULL || pfunc_slewing_done == NULL) { | 541 | pfunc_cpu_setfreq_low == NULL || pfunc_slewing_done == NULL) { |
| 542 | printk(KERN_ERR "cpufreq: Can't find platform functions !\n"); | 542 | pr_err("Can't find platform functions !\n"); |
| 543 | rc = -ENODEV; | 543 | rc = -ENODEV; |
| 544 | goto bail; | 544 | goto bail; |
| 545 | } | 545 | } |
| @@ -567,7 +567,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 567 | /* Get max frequency from device-tree */ | 567 | /* Get max frequency from device-tree */ |
| 568 | valp = of_get_property(cpunode, "clock-frequency", NULL); | 568 | valp = of_get_property(cpunode, "clock-frequency", NULL); |
| 569 | if (!valp) { | 569 | if (!valp) { |
| 570 | printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n"); | 570 | pr_err("Can't find CPU frequency !\n"); |
| 571 | rc = -ENODEV; | 571 | rc = -ENODEV; |
| 572 | goto bail; | 572 | goto bail; |
| 573 | } | 573 | } |
| @@ -583,8 +583,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 583 | 583 | ||
| 584 | /* Check for machines with no useful settings */ | 584 | /* Check for machines with no useful settings */ |
| 585 | if (il == ih) { | 585 | if (il == ih) { |
| 586 | printk(KERN_WARNING "cpufreq: No low frequency mode available" | 586 | pr_warn("No low frequency mode available on this model !\n"); |
| 587 | " on this model !\n"); | ||
| 588 | rc = -ENODEV; | 587 | rc = -ENODEV; |
| 589 | goto bail; | 588 | goto bail; |
| 590 | } | 589 | } |
| @@ -595,7 +594,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 595 | 594 | ||
| 596 | /* Sanity check */ | 595 | /* Sanity check */ |
| 597 | if (min_freq >= max_freq || min_freq < 1000) { | 596 | if (min_freq >= max_freq || min_freq < 1000) { |
| 598 | printk(KERN_ERR "cpufreq: Can't calculate low frequency !\n"); | 597 | pr_err("Can't calculate low frequency !\n"); |
| 599 | rc = -ENXIO; | 598 | rc = -ENXIO; |
| 600 | goto bail; | 599 | goto bail; |
| 601 | } | 600 | } |
| @@ -619,10 +618,10 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 619 | g5_pmode_cur = -1; | 618 | g5_pmode_cur = -1; |
| 620 | g5_switch_freq(g5_query_freq()); | 619 | g5_switch_freq(g5_query_freq()); |
| 621 | 620 | ||
| 622 | printk(KERN_INFO "Registering G5 CPU frequency driver\n"); | 621 | pr_info("Registering G5 CPU frequency driver\n"); |
| 623 | printk(KERN_INFO "Frequency method: i2c/pfunc, " | 622 | pr_info("Frequency method: i2c/pfunc, Voltage method: %s\n", |
| 624 | "Voltage method: %s\n", has_volt ? "i2c/pfunc" : "none"); | 623 | has_volt ? "i2c/pfunc" : "none"); |
| 625 | printk(KERN_INFO "Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n", | 624 | pr_info("Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n", |
| 626 | g5_cpu_freqs[1].frequency/1000, | 625 | g5_cpu_freqs[1].frequency/1000, |
| 627 | g5_cpu_freqs[0].frequency/1000, | 626 | g5_cpu_freqs[0].frequency/1000, |
| 628 | g5_cpu_freqs[g5_pmode_cur].frequency/1000); | 627 | g5_cpu_freqs[g5_pmode_cur].frequency/1000); |
| @@ -654,7 +653,7 @@ static int __init g5_cpufreq_init(void) | |||
| 654 | /* Get first CPU node */ | 653 | /* Get first CPU node */ |
| 655 | cpunode = of_cpu_device_node_get(0); | 654 | cpunode = of_cpu_device_node_get(0); |
| 656 | if (cpunode == NULL) { | 655 | if (cpunode == NULL) { |
| 657 | pr_err("cpufreq: Can't find any CPU node\n"); | 656 | pr_err("Can't find any CPU node\n"); |
| 658 | return -ENODEV; | 657 | return -ENODEV; |
| 659 | } | 658 | } |
| 660 | 659 | ||
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index e6f24b281e3e..dedd2568e852 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
| @@ -8,6 +8,8 @@ | |||
| 8 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* | 8 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 12 | |||
| 11 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 13 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| @@ -22,7 +24,6 @@ | |||
| 22 | #define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long | 24 | #define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long |
| 23 | as it is unused */ | 25 | as it is unused */ |
| 24 | 26 | ||
| 25 | #define PFX "powernow-k6: " | ||
| 26 | static unsigned int busfreq; /* FSB, in 10 kHz */ | 27 | static unsigned int busfreq; /* FSB, in 10 kHz */ |
| 27 | static unsigned int max_multiplier; | 28 | static unsigned int max_multiplier; |
| 28 | 29 | ||
| @@ -141,7 +142,7 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | |||
| 141 | { | 142 | { |
| 142 | 143 | ||
| 143 | if (clock_ratio[best_i].driver_data > max_multiplier) { | 144 | if (clock_ratio[best_i].driver_data > max_multiplier) { |
| 144 | printk(KERN_ERR PFX "invalid target frequency\n"); | 145 | pr_err("invalid target frequency\n"); |
| 145 | return -EINVAL; | 146 | return -EINVAL; |
| 146 | } | 147 | } |
| 147 | 148 | ||
| @@ -175,13 +176,14 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | |||
| 175 | max_multiplier = param_max_multiplier; | 176 | max_multiplier = param_max_multiplier; |
| 176 | goto have_max_multiplier; | 177 | goto have_max_multiplier; |
| 177 | } | 178 | } |
| 178 | printk(KERN_ERR "powernow-k6: invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n"); | 179 | pr_err("invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n"); |
| 179 | return -EINVAL; | 180 | return -EINVAL; |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | if (!max_multiplier) { | 183 | if (!max_multiplier) { |
| 183 | printk(KERN_WARNING "powernow-k6: unknown frequency %u, cannot determine current multiplier\n", khz); | 184 | pr_warn("unknown frequency %u, cannot determine current multiplier\n", |
| 184 | printk(KERN_WARNING "powernow-k6: use module parameters max_multiplier and bus_frequency\n"); | 185 | khz); |
| 186 | pr_warn("use module parameters max_multiplier and bus_frequency\n"); | ||
| 185 | return -EOPNOTSUPP; | 187 | return -EOPNOTSUPP; |
| 186 | } | 188 | } |
| 187 | 189 | ||
| @@ -193,7 +195,7 @@ have_max_multiplier: | |||
| 193 | busfreq = param_busfreq / 10; | 195 | busfreq = param_busfreq / 10; |
| 194 | goto have_busfreq; | 196 | goto have_busfreq; |
| 195 | } | 197 | } |
| 196 | printk(KERN_ERR "powernow-k6: invalid bus_frequency parameter, allowed range 50000 - 150000 kHz\n"); | 198 | pr_err("invalid bus_frequency parameter, allowed range 50000 - 150000 kHz\n"); |
| 197 | return -EINVAL; | 199 | return -EINVAL; |
| 198 | } | 200 | } |
| 199 | 201 | ||
| @@ -275,7 +277,7 @@ static int __init powernow_k6_init(void) | |||
| 275 | return -ENODEV; | 277 | return -ENODEV; |
| 276 | 278 | ||
| 277 | if (!request_region(POWERNOW_IOPORT, 16, "PowerNow!")) { | 279 | if (!request_region(POWERNOW_IOPORT, 16, "PowerNow!")) { |
| 278 | printk(KERN_INFO PFX "PowerNow IOPORT region already used.\n"); | 280 | pr_info("PowerNow IOPORT region already used\n"); |
| 279 | return -EIO; | 281 | return -EIO; |
| 280 | } | 282 | } |
| 281 | 283 | ||
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index c1ae1999770a..9f013ed42977 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | * - We disable half multipliers if ACPI is used on A0 stepping CPUs. | 13 | * - We disable half multipliers if ACPI is used on A0 stepping CPUs. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 17 | |||
| 16 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
| 17 | #include <linux/module.h> | 19 | #include <linux/module.h> |
| 18 | #include <linux/moduleparam.h> | 20 | #include <linux/moduleparam.h> |
| @@ -35,9 +37,6 @@ | |||
| 35 | 37 | ||
| 36 | #include "powernow-k7.h" | 38 | #include "powernow-k7.h" |
| 37 | 39 | ||
| 38 | #define PFX "powernow: " | ||
| 39 | |||
| 40 | |||
| 41 | struct psb_s { | 40 | struct psb_s { |
| 42 | u8 signature[10]; | 41 | u8 signature[10]; |
| 43 | u8 tableversion; | 42 | u8 tableversion; |
| @@ -127,14 +126,13 @@ static int check_powernow(void) | |||
| 127 | maxei = cpuid_eax(0x80000000); | 126 | maxei = cpuid_eax(0x80000000); |
| 128 | if (maxei < 0x80000007) { /* Any powernow info ? */ | 127 | if (maxei < 0x80000007) { /* Any powernow info ? */ |
| 129 | #ifdef MODULE | 128 | #ifdef MODULE |
| 130 | printk(KERN_INFO PFX "No powernow capabilities detected\n"); | 129 | pr_info("No powernow capabilities detected\n"); |
| 131 | #endif | 130 | #endif |
| 132 | return 0; | 131 | return 0; |
| 133 | } | 132 | } |
| 134 | 133 | ||
| 135 | if ((c->x86_model == 6) && (c->x86_mask == 0)) { | 134 | if ((c->x86_model == 6) && (c->x86_mask == 0)) { |
| 136 | printk(KERN_INFO PFX "K7 660[A0] core detected, " | 135 | pr_info("K7 660[A0] core detected, enabling errata workarounds\n"); |
| 137 | "enabling errata workarounds\n"); | ||
| 138 | have_a0 = 1; | 136 | have_a0 = 1; |
| 139 | } | 137 | } |
| 140 | 138 | ||
| @@ -144,22 +142,22 @@ static int check_powernow(void) | |||
| 144 | if (!(edx & (1 << 1 | 1 << 2))) | 142 | if (!(edx & (1 << 1 | 1 << 2))) |
| 145 | return 0; | 143 | return 0; |
| 146 | 144 | ||
| 147 | printk(KERN_INFO PFX "PowerNOW! Technology present. Can scale: "); | 145 | pr_info("PowerNOW! Technology present. Can scale: "); |
| 148 | 146 | ||
| 149 | if (edx & 1 << 1) { | 147 | if (edx & 1 << 1) { |
| 150 | printk("frequency"); | 148 | pr_cont("frequency"); |
| 151 | can_scale_bus = 1; | 149 | can_scale_bus = 1; |
| 152 | } | 150 | } |
| 153 | 151 | ||
| 154 | if ((edx & (1 << 1 | 1 << 2)) == 0x6) | 152 | if ((edx & (1 << 1 | 1 << 2)) == 0x6) |
| 155 | printk(" and "); | 153 | pr_cont(" and "); |
| 156 | 154 | ||
| 157 | if (edx & 1 << 2) { | 155 | if (edx & 1 << 2) { |
| 158 | printk("voltage"); | 156 | pr_cont("voltage"); |
| 159 | can_scale_vid = 1; | 157 | can_scale_vid = 1; |
| 160 | } | 158 | } |
| 161 | 159 | ||
| 162 | printk(".\n"); | 160 | pr_cont("\n"); |
| 163 | return 1; | 161 | return 1; |
| 164 | } | 162 | } |
| 165 | 163 | ||
| @@ -427,16 +425,14 @@ err1: | |||
| 427 | err05: | 425 | err05: |
| 428 | kfree(acpi_processor_perf); | 426 | kfree(acpi_processor_perf); |
| 429 | err0: | 427 | err0: |
| 430 | printk(KERN_WARNING PFX "ACPI perflib can not be used on " | 428 | pr_warn("ACPI perflib can not be used on this platform\n"); |
| 431 | "this platform\n"); | ||
| 432 | acpi_processor_perf = NULL; | 429 | acpi_processor_perf = NULL; |
| 433 | return retval; | 430 | return retval; |
| 434 | } | 431 | } |
| 435 | #else | 432 | #else |
| 436 | static int powernow_acpi_init(void) | 433 | static int powernow_acpi_init(void) |
| 437 | { | 434 | { |
| 438 | printk(KERN_INFO PFX "no support for ACPI processor found." | 435 | pr_info("no support for ACPI processor found - please recompile your kernel with ACPI processor\n"); |
| 439 | " Please recompile your kernel with ACPI processor\n"); | ||
| 440 | return -EINVAL; | 436 | return -EINVAL; |
| 441 | } | 437 | } |
| 442 | #endif | 438 | #endif |
| @@ -468,8 +464,7 @@ static int powernow_decode_bios(int maxfid, int startvid) | |||
| 468 | psb = (struct psb_s *) p; | 464 | psb = (struct psb_s *) p; |
| 469 | pr_debug("Table version: 0x%x\n", psb->tableversion); | 465 | pr_debug("Table version: 0x%x\n", psb->tableversion); |
| 470 | if (psb->tableversion != 0x12) { | 466 | if (psb->tableversion != 0x12) { |
| 471 | printk(KERN_INFO PFX "Sorry, only v1.2 tables" | 467 | pr_info("Sorry, only v1.2 tables supported right now\n"); |
| 472 | " supported right now\n"); | ||
| 473 | return -ENODEV; | 468 | return -ENODEV; |
| 474 | } | 469 | } |
| 475 | 470 | ||
| @@ -481,10 +476,8 @@ static int powernow_decode_bios(int maxfid, int startvid) | |||
| 481 | 476 | ||
| 482 | latency = psb->settlingtime; | 477 | latency = psb->settlingtime; |
| 483 | if (latency < 100) { | 478 | if (latency < 100) { |
| 484 | printk(KERN_INFO PFX "BIOS set settling time " | 479 | pr_info("BIOS set settling time to %d microseconds. Should be at least 100. Correcting.\n", |
| 485 | "to %d microseconds. " | 480 | latency); |
| 486 | "Should be at least 100. " | ||
| 487 | "Correcting.\n", latency); | ||
| 488 | latency = 100; | 481 | latency = 100; |
| 489 | } | 482 | } |
| 490 | pr_debug("Settling Time: %d microseconds.\n", | 483 | pr_debug("Settling Time: %d microseconds.\n", |
| @@ -516,10 +509,9 @@ static int powernow_decode_bios(int maxfid, int startvid) | |||
| 516 | p += 2; | 509 | p += 2; |
| 517 | } | 510 | } |
| 518 | } | 511 | } |
| 519 | printk(KERN_INFO PFX "No PST tables match this cpuid " | 512 | pr_info("No PST tables match this cpuid (0x%x)\n", |
| 520 | "(0x%x)\n", etuple); | 513 | etuple); |
| 521 | printk(KERN_INFO PFX "This is indicative of a broken " | 514 | pr_info("This is indicative of a broken BIOS\n"); |
| 522 | "BIOS.\n"); | ||
| 523 | 515 | ||
| 524 | return -EINVAL; | 516 | return -EINVAL; |
| 525 | } | 517 | } |
| @@ -552,7 +544,7 @@ static int fixup_sgtc(void) | |||
| 552 | sgtc = 100 * m * latency; | 544 | sgtc = 100 * m * latency; |
| 553 | sgtc = sgtc / 3; | 545 | sgtc = sgtc / 3; |
| 554 | if (sgtc > 0xfffff) { | 546 | if (sgtc > 0xfffff) { |
| 555 | printk(KERN_WARNING PFX "SGTC too large %d\n", sgtc); | 547 | pr_warn("SGTC too large %d\n", sgtc); |
| 556 | sgtc = 0xfffff; | 548 | sgtc = 0xfffff; |
| 557 | } | 549 | } |
| 558 | return sgtc; | 550 | return sgtc; |
| @@ -574,14 +566,10 @@ static unsigned int powernow_get(unsigned int cpu) | |||
| 574 | 566 | ||
| 575 | static int acer_cpufreq_pst(const struct dmi_system_id *d) | 567 | static int acer_cpufreq_pst(const struct dmi_system_id *d) |
| 576 | { | 568 | { |
| 577 | printk(KERN_WARNING PFX | 569 | pr_warn("%s laptop with broken PST tables in BIOS detected\n", |
| 578 | "%s laptop with broken PST tables in BIOS detected.\n", | ||
| 579 | d->ident); | 570 | d->ident); |
| 580 | printk(KERN_WARNING PFX | 571 | pr_warn("You need to downgrade to 3A21 (09/09/2002), or try a newer BIOS than 3A71 (01/20/2003)\n"); |
| 581 | "You need to downgrade to 3A21 (09/09/2002), or try a newer " | 572 | pr_warn("cpufreq scaling has been disabled as a result of this\n"); |
| 582 | "BIOS than 3A71 (01/20/2003)\n"); | ||
| 583 | printk(KERN_WARNING PFX | ||
| 584 | "cpufreq scaling has been disabled as a result of this.\n"); | ||
| 585 | return 0; | 573 | return 0; |
| 586 | } | 574 | } |
| 587 | 575 | ||
| @@ -616,40 +604,38 @@ static int powernow_cpu_init(struct cpufreq_policy *policy) | |||
| 616 | 604 | ||
| 617 | fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID]; | 605 | fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID]; |
| 618 | if (!fsb) { | 606 | if (!fsb) { |
| 619 | printk(KERN_WARNING PFX "can not determine bus frequency\n"); | 607 | pr_warn("can not determine bus frequency\n"); |
| 620 | return -EINVAL; | 608 | return -EINVAL; |
| 621 | } | 609 | } |
| 622 | pr_debug("FSB: %3dMHz\n", fsb/1000); | 610 | pr_debug("FSB: %3dMHz\n", fsb/1000); |
| 623 | 611 | ||
| 624 | if (dmi_check_system(powernow_dmi_table) || acpi_force) { | 612 | if (dmi_check_system(powernow_dmi_table) || acpi_force) { |
| 625 | printk(KERN_INFO PFX "PSB/PST known to be broken. " | 613 | pr_info("PSB/PST known to be broken - trying ACPI instead\n"); |
| 626 | "Trying ACPI instead\n"); | ||
| 627 | result = powernow_acpi_init(); | 614 | result = powernow_acpi_init(); |
| 628 | } else { | 615 | } else { |
| 629 | result = powernow_decode_bios(fidvidstatus.bits.MFID, | 616 | result = powernow_decode_bios(fidvidstatus.bits.MFID, |
| 630 | fidvidstatus.bits.SVID); | 617 | fidvidstatus.bits.SVID); |
| 631 | if (result) { | 618 | if (result) { |
| 632 | printk(KERN_INFO PFX "Trying ACPI perflib\n"); | 619 | pr_info("Trying ACPI perflib\n"); |
| 633 | maximum_speed = 0; | 620 | maximum_speed = 0; |
| 634 | minimum_speed = -1; | 621 | minimum_speed = -1; |
| 635 | latency = 0; | 622 | latency = 0; |
| 636 | result = powernow_acpi_init(); | 623 | result = powernow_acpi_init(); |
| 637 | if (result) { | 624 | if (result) { |
| 638 | printk(KERN_INFO PFX | 625 | pr_info("ACPI and legacy methods failed\n"); |
| 639 | "ACPI and legacy methods failed\n"); | ||
| 640 | } | 626 | } |
| 641 | } else { | 627 | } else { |
| 642 | /* SGTC use the bus clock as timer */ | 628 | /* SGTC use the bus clock as timer */ |
| 643 | latency = fixup_sgtc(); | 629 | latency = fixup_sgtc(); |
| 644 | printk(KERN_INFO PFX "SGTC: %d\n", latency); | 630 | pr_info("SGTC: %d\n", latency); |
| 645 | } | 631 | } |
| 646 | } | 632 | } |
| 647 | 633 | ||
| 648 | if (result) | 634 | if (result) |
| 649 | return result; | 635 | return result; |
| 650 | 636 | ||
| 651 | printk(KERN_INFO PFX "Minimum speed %d MHz. Maximum speed %d MHz.\n", | 637 | pr_info("Minimum speed %d MHz - Maximum speed %d MHz\n", |
| 652 | minimum_speed/1000, maximum_speed/1000); | 638 | minimum_speed/1000, maximum_speed/1000); |
| 653 | 639 | ||
| 654 | policy->cpuinfo.transition_latency = | 640 | policy->cpuinfo.transition_latency = |
| 655 | cpufreq_scale(2000000UL, fsb, latency); | 641 | cpufreq_scale(2000000UL, fsb, latency); |
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 39ac78c94be0..54c45368e3f1 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c | |||
| @@ -36,12 +36,56 @@ | |||
| 36 | #include <asm/reg.h> | 36 | #include <asm/reg.h> |
| 37 | #include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */ | 37 | #include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */ |
| 38 | #include <asm/opal.h> | 38 | #include <asm/opal.h> |
| 39 | #include <linux/timer.h> | ||
| 39 | 40 | ||
| 40 | #define POWERNV_MAX_PSTATES 256 | 41 | #define POWERNV_MAX_PSTATES 256 |
| 41 | #define PMSR_PSAFE_ENABLE (1UL << 30) | 42 | #define PMSR_PSAFE_ENABLE (1UL << 30) |
| 42 | #define PMSR_SPR_EM_DISABLE (1UL << 31) | 43 | #define PMSR_SPR_EM_DISABLE (1UL << 31) |
| 43 | #define PMSR_MAX(x) ((x >> 32) & 0xFF) | 44 | #define PMSR_MAX(x) ((x >> 32) & 0xFF) |
| 44 | 45 | ||
| 46 | #define MAX_RAMP_DOWN_TIME 5120 | ||
| 47 | /* | ||
| 48 | * On an idle system we want the global pstate to ramp-down from max value to | ||
| 49 | * min over a span of ~5 secs. Also we want it to initially ramp-down slowly and | ||
| 50 | * then ramp-down rapidly later on. | ||
| 51 | * | ||
| 52 | * This gives a percentage rampdown for time elapsed in milliseconds. | ||
| 53 | * ramp_down_percentage = ((ms * ms) >> 18) | ||
| 54 | * ~= 3.8 * (sec * sec) | ||
| 55 | * | ||
| 56 | * At 0 ms ramp_down_percent = 0 | ||
| 57 | * At 5120 ms ramp_down_percent = 100 | ||
| 58 | */ | ||
| 59 | #define ramp_down_percent(time) ((time * time) >> 18) | ||
| 60 | |||
| 61 | /* Interval after which the timer is queued to bring down global pstate */ | ||
| 62 | #define GPSTATE_TIMER_INTERVAL 2000 | ||
| 63 | |||
| 64 | /** | ||
| 65 | * struct global_pstate_info - Per policy data structure to maintain history of | ||
| 66 | * global pstates | ||
| 67 | * @highest_lpstate: The local pstate from which we are ramping down | ||
| 68 | * @elapsed_time: Time in ms spent in ramping down from | ||
| 69 | * highest_lpstate | ||
| 70 | * @last_sampled_time: Time from boot in ms when global pstates were | ||
| 71 | * last set | ||
| 72 | * @last_lpstate,last_gpstate: Last set values for local and global pstates | ||
| 73 | * @timer: Is used for ramping down if cpu goes idle for | ||
| 74 | * a long time with global pstate held high | ||
| 75 | * @gpstate_lock: A spinlock to maintain synchronization between | ||
| 76 | * routines called by the timer handler and | ||
| 77 | * governer's target_index calls | ||
| 78 | */ | ||
| 79 | struct global_pstate_info { | ||
| 80 | int highest_lpstate; | ||
| 81 | unsigned int elapsed_time; | ||
| 82 | unsigned int last_sampled_time; | ||
| 83 | int last_lpstate; | ||
| 84 | int last_gpstate; | ||
| 85 | spinlock_t gpstate_lock; | ||
| 86 | struct timer_list timer; | ||
| 87 | }; | ||
| 88 | |||
| 45 | static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1]; | 89 | static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1]; |
| 46 | static bool rebooting, throttled, occ_reset; | 90 | static bool rebooting, throttled, occ_reset; |
| 47 | 91 | ||
| @@ -94,6 +138,17 @@ static struct powernv_pstate_info { | |||
| 94 | int nr_pstates; | 138 | int nr_pstates; |
| 95 | } powernv_pstate_info; | 139 | } powernv_pstate_info; |
| 96 | 140 | ||
| 141 | static inline void reset_gpstates(struct cpufreq_policy *policy) | ||
| 142 | { | ||
| 143 | struct global_pstate_info *gpstates = policy->driver_data; | ||
| 144 | |||
| 145 | gpstates->highest_lpstate = 0; | ||
| 146 | gpstates->elapsed_time = 0; | ||
| 147 | gpstates->last_sampled_time = 0; | ||
| 148 | gpstates->last_lpstate = 0; | ||
| 149 | gpstates->last_gpstate = 0; | ||
| 150 | } | ||
| 151 | |||
| 97 | /* | 152 | /* |
| 98 | * Initialize the freq table based on data obtained | 153 | * Initialize the freq table based on data obtained |
| 99 | * from the firmware passed via device-tree | 154 | * from the firmware passed via device-tree |
| @@ -285,6 +340,7 @@ static inline void set_pmspr(unsigned long sprn, unsigned long val) | |||
| 285 | struct powernv_smp_call_data { | 340 | struct powernv_smp_call_data { |
| 286 | unsigned int freq; | 341 | unsigned int freq; |
| 287 | int pstate_id; | 342 | int pstate_id; |
| 343 | int gpstate_id; | ||
| 288 | }; | 344 | }; |
| 289 | 345 | ||
| 290 | /* | 346 | /* |
| @@ -343,19 +399,21 @@ static unsigned int powernv_cpufreq_get(unsigned int cpu) | |||
| 343 | * (struct powernv_smp_call_data *) and the pstate_id which needs to be set | 399 | * (struct powernv_smp_call_data *) and the pstate_id which needs to be set |
| 344 | * on this CPU should be present in freq_data->pstate_id. | 400 | * on this CPU should be present in freq_data->pstate_id. |
| 345 | */ | 401 | */ |
| 346 | static void set_pstate(void *freq_data) | 402 | static void set_pstate(void *data) |
| 347 | { | 403 | { |
| 348 | unsigned long val; | 404 | unsigned long val; |
| 349 | unsigned long pstate_ul = | 405 | struct powernv_smp_call_data *freq_data = data; |
| 350 | ((struct powernv_smp_call_data *) freq_data)->pstate_id; | 406 | unsigned long pstate_ul = freq_data->pstate_id; |
| 407 | unsigned long gpstate_ul = freq_data->gpstate_id; | ||
| 351 | 408 | ||
| 352 | val = get_pmspr(SPRN_PMCR); | 409 | val = get_pmspr(SPRN_PMCR); |
| 353 | val = val & 0x0000FFFFFFFFFFFFULL; | 410 | val = val & 0x0000FFFFFFFFFFFFULL; |
| 354 | 411 | ||
| 355 | pstate_ul = pstate_ul & 0xFF; | 412 | pstate_ul = pstate_ul & 0xFF; |
| 413 | gpstate_ul = gpstate_ul & 0xFF; | ||
| 356 | 414 | ||
| 357 | /* Set both global(bits 56..63) and local(bits 48..55) PStates */ | 415 | /* Set both global(bits 56..63) and local(bits 48..55) PStates */ |
| 358 | val = val | (pstate_ul << 56) | (pstate_ul << 48); | 416 | val = val | (gpstate_ul << 56) | (pstate_ul << 48); |
| 359 | 417 | ||
| 360 | pr_debug("Setting cpu %d pmcr to %016lX\n", | 418 | pr_debug("Setting cpu %d pmcr to %016lX\n", |
| 361 | raw_smp_processor_id(), val); | 419 | raw_smp_processor_id(), val); |
| @@ -424,6 +482,111 @@ next: | |||
| 424 | } | 482 | } |
| 425 | } | 483 | } |
| 426 | 484 | ||
| 485 | /** | ||
| 486 | * calc_global_pstate - Calculate global pstate | ||
| 487 | * @elapsed_time: Elapsed time in milliseconds | ||
| 488 | * @local_pstate: New local pstate | ||
| 489 | * @highest_lpstate: pstate from which its ramping down | ||
| 490 | * | ||
| 491 | * Finds the appropriate global pstate based on the pstate from which its | ||
| 492 | * ramping down and the time elapsed in ramping down. It follows a quadratic | ||
| 493 | * equation which ensures that it reaches ramping down to pmin in 5sec. | ||
| 494 | */ | ||
| 495 | static inline int calc_global_pstate(unsigned int elapsed_time, | ||
| 496 | int highest_lpstate, int local_pstate) | ||
| 497 | { | ||
| 498 | int pstate_diff; | ||
| 499 | |||
| 500 | /* | ||
| 501 | * Using ramp_down_percent we get the percentage of rampdown | ||
| 502 | * that we are expecting to be dropping. Difference between | ||
| 503 | * highest_lpstate and powernv_pstate_info.min will give a absolute | ||
| 504 | * number of how many pstates we will drop eventually by the end of | ||
| 505 | * 5 seconds, then just scale it get the number pstates to be dropped. | ||
| 506 | */ | ||
| 507 | pstate_diff = ((int)ramp_down_percent(elapsed_time) * | ||
| 508 | (highest_lpstate - powernv_pstate_info.min)) / 100; | ||
| 509 | |||
| 510 | /* Ensure that global pstate is >= to local pstate */ | ||
| 511 | if (highest_lpstate - pstate_diff < local_pstate) | ||
| 512 | return local_pstate; | ||
| 513 | else | ||
| 514 | return highest_lpstate - pstate_diff; | ||
| 515 | } | ||
| 516 | |||
| 517 | static inline void queue_gpstate_timer(struct global_pstate_info *gpstates) | ||
| 518 | { | ||
| 519 | unsigned int timer_interval; | ||
| 520 | |||
| 521 | /* | ||
| 522 | * Setting up timer to fire after GPSTATE_TIMER_INTERVAL ms, But | ||
| 523 | * if it exceeds MAX_RAMP_DOWN_TIME ms for ramp down time. | ||
| 524 | * Set timer such that it fires exactly at MAX_RAMP_DOWN_TIME | ||
| 525 | * seconds of ramp down time. | ||
| 526 | */ | ||
| 527 | if ((gpstates->elapsed_time + GPSTATE_TIMER_INTERVAL) | ||
| 528 | > MAX_RAMP_DOWN_TIME) | ||
| 529 | timer_interval = MAX_RAMP_DOWN_TIME - gpstates->elapsed_time; | ||
| 530 | else | ||
| 531 | timer_interval = GPSTATE_TIMER_INTERVAL; | ||
| 532 | |||
| 533 | mod_timer_pinned(&gpstates->timer, jiffies + | ||
| 534 | msecs_to_jiffies(timer_interval)); | ||
| 535 | } | ||
| 536 | |||
| 537 | /** | ||
| 538 | * gpstate_timer_handler | ||
| 539 | * | ||
| 540 | * @data: pointer to cpufreq_policy on which timer was queued | ||
| 541 | * | ||
| 542 | * This handler brings down the global pstate closer to the local pstate | ||
| 543 | * according quadratic equation. Queues a new timer if it is still not equal | ||
| 544 | * to local pstate | ||
| 545 | */ | ||
| 546 | void gpstate_timer_handler(unsigned long data) | ||
| 547 | { | ||
| 548 | struct cpufreq_policy *policy = (struct cpufreq_policy *)data; | ||
| 549 | struct global_pstate_info *gpstates = policy->driver_data; | ||
| 550 | int gpstate_id; | ||
| 551 | unsigned int time_diff = jiffies_to_msecs(jiffies) | ||
| 552 | - gpstates->last_sampled_time; | ||
| 553 | struct powernv_smp_call_data freq_data; | ||
| 554 | |||
| 555 | if (!spin_trylock(&gpstates->gpstate_lock)) | ||
| 556 | return; | ||
| 557 | |||
| 558 | gpstates->last_sampled_time += time_diff; | ||
| 559 | gpstates->elapsed_time += time_diff; | ||
| 560 | freq_data.pstate_id = gpstates->last_lpstate; | ||
| 561 | |||
| 562 | if ((gpstates->last_gpstate == freq_data.pstate_id) || | ||
| 563 | (gpstates->elapsed_time > MAX_RAMP_DOWN_TIME)) { | ||
| 564 | gpstate_id = freq_data.pstate_id; | ||
| 565 | reset_gpstates(policy); | ||
| 566 | gpstates->highest_lpstate = freq_data.pstate_id; | ||
| 567 | } else { | ||
| 568 | gpstate_id = calc_global_pstate(gpstates->elapsed_time, | ||
| 569 | gpstates->highest_lpstate, | ||
| 570 | freq_data.pstate_id); | ||
| 571 | } | ||
| 572 | |||
| 573 | /* | ||
| 574 | * If local pstate is equal to global pstate, rampdown is over | ||
| 575 | * So timer is not required to be queued. | ||
| 576 | */ | ||
| 577 | if (gpstate_id != freq_data.pstate_id) | ||
| 578 | queue_gpstate_timer(gpstates); | ||
| 579 | |||
| 580 | freq_data.gpstate_id = gpstate_id; | ||
| 581 | gpstates->last_gpstate = freq_data.gpstate_id; | ||
| 582 | gpstates->last_lpstate = freq_data.pstate_id; | ||
| 583 | |||
| 584 | spin_unlock(&gpstates->gpstate_lock); | ||
| 585 | |||
| 586 | /* Timer may get migrated to a different cpu on cpu hot unplug */ | ||
| 587 | smp_call_function_any(policy->cpus, set_pstate, &freq_data, 1); | ||
| 588 | } | ||
| 589 | |||
| 427 | /* | 590 | /* |
| 428 | * powernv_cpufreq_target_index: Sets the frequency corresponding to | 591 | * powernv_cpufreq_target_index: Sets the frequency corresponding to |
| 429 | * the cpufreq table entry indexed by new_index on the cpus in the | 592 | * the cpufreq table entry indexed by new_index on the cpus in the |
| @@ -433,6 +596,8 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy, | |||
| 433 | unsigned int new_index) | 596 | unsigned int new_index) |
| 434 | { | 597 | { |
| 435 | struct powernv_smp_call_data freq_data; | 598 | struct powernv_smp_call_data freq_data; |
| 599 | unsigned int cur_msec, gpstate_id; | ||
| 600 | struct global_pstate_info *gpstates = policy->driver_data; | ||
| 436 | 601 | ||
| 437 | if (unlikely(rebooting) && new_index != get_nominal_index()) | 602 | if (unlikely(rebooting) && new_index != get_nominal_index()) |
| 438 | return 0; | 603 | return 0; |
| @@ -440,28 +605,81 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy, | |||
| 440 | if (!throttled) | 605 | if (!throttled) |
| 441 | powernv_cpufreq_throttle_check(NULL); | 606 | powernv_cpufreq_throttle_check(NULL); |
| 442 | 607 | ||
| 608 | cur_msec = jiffies_to_msecs(get_jiffies_64()); | ||
| 609 | |||
| 610 | spin_lock(&gpstates->gpstate_lock); | ||
| 443 | freq_data.pstate_id = powernv_freqs[new_index].driver_data; | 611 | freq_data.pstate_id = powernv_freqs[new_index].driver_data; |
| 444 | 612 | ||
| 613 | if (!gpstates->last_sampled_time) { | ||
| 614 | gpstate_id = freq_data.pstate_id; | ||
| 615 | gpstates->highest_lpstate = freq_data.pstate_id; | ||
| 616 | goto gpstates_done; | ||
| 617 | } | ||
| 618 | |||
| 619 | if (gpstates->last_gpstate > freq_data.pstate_id) { | ||
| 620 | gpstates->elapsed_time += cur_msec - | ||
| 621 | gpstates->last_sampled_time; | ||
| 622 | |||
| 623 | /* | ||
| 624 | * If its has been ramping down for more than MAX_RAMP_DOWN_TIME | ||
| 625 | * we should be resetting all global pstate related data. Set it | ||
| 626 | * equal to local pstate to start fresh. | ||
| 627 | */ | ||
| 628 | if (gpstates->elapsed_time > MAX_RAMP_DOWN_TIME) { | ||
| 629 | reset_gpstates(policy); | ||
| 630 | gpstates->highest_lpstate = freq_data.pstate_id; | ||
| 631 | gpstate_id = freq_data.pstate_id; | ||
| 632 | } else { | ||
| 633 | /* Elaspsed_time is less than 5 seconds, continue to rampdown */ | ||
| 634 | gpstate_id = calc_global_pstate(gpstates->elapsed_time, | ||
| 635 | gpstates->highest_lpstate, | ||
| 636 | freq_data.pstate_id); | ||
| 637 | } | ||
| 638 | } else { | ||
| 639 | reset_gpstates(policy); | ||
| 640 | gpstates->highest_lpstate = freq_data.pstate_id; | ||
| 641 | gpstate_id = freq_data.pstate_id; | ||
| 642 | } | ||
| 643 | |||
| 644 | /* | ||
| 645 | * If local pstate is equal to global pstate, rampdown is over | ||
| 646 | * So timer is not required to be queued. | ||
| 647 | */ | ||
| 648 | if (gpstate_id != freq_data.pstate_id) | ||
| 649 | queue_gpstate_timer(gpstates); | ||
| 650 | else | ||
| 651 | del_timer_sync(&gpstates->timer); | ||
| 652 | |||
| 653 | gpstates_done: | ||
| 654 | freq_data.gpstate_id = gpstate_id; | ||
| 655 | gpstates->last_sampled_time = cur_msec; | ||
| 656 | gpstates->last_gpstate = freq_data.gpstate_id; | ||
| 657 | gpstates->last_lpstate = freq_data.pstate_id; | ||
| 658 | |||
| 659 | spin_unlock(&gpstates->gpstate_lock); | ||
| 660 | |||
| 445 | /* | 661 | /* |
| 446 | * Use smp_call_function to send IPI and execute the | 662 | * Use smp_call_function to send IPI and execute the |
| 447 | * mtspr on target CPU. We could do that without IPI | 663 | * mtspr on target CPU. We could do that without IPI |
| 448 | * if current CPU is within policy->cpus (core) | 664 | * if current CPU is within policy->cpus (core) |
| 449 | */ | 665 | */ |
| 450 | smp_call_function_any(policy->cpus, set_pstate, &freq_data, 1); | 666 | smp_call_function_any(policy->cpus, set_pstate, &freq_data, 1); |
| 451 | |||
| 452 | return 0; | 667 | return 0; |
| 453 | } | 668 | } |
| 454 | 669 | ||
| 455 | static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy) | 670 | static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy) |
| 456 | { | 671 | { |
| 457 | int base, i; | 672 | int base, i, ret; |
| 673 | struct kernfs_node *kn; | ||
| 674 | struct global_pstate_info *gpstates; | ||
| 458 | 675 | ||
| 459 | base = cpu_first_thread_sibling(policy->cpu); | 676 | base = cpu_first_thread_sibling(policy->cpu); |
| 460 | 677 | ||
| 461 | for (i = 0; i < threads_per_core; i++) | 678 | for (i = 0; i < threads_per_core; i++) |
| 462 | cpumask_set_cpu(base + i, policy->cpus); | 679 | cpumask_set_cpu(base + i, policy->cpus); |
| 463 | 680 | ||
| 464 | if (!policy->driver_data) { | 681 | kn = kernfs_find_and_get(policy->kobj.sd, throttle_attr_grp.name); |
| 682 | if (!kn) { | ||
| 465 | int ret; | 683 | int ret; |
| 466 | 684 | ||
| 467 | ret = sysfs_create_group(&policy->kobj, &throttle_attr_grp); | 685 | ret = sysfs_create_group(&policy->kobj, &throttle_attr_grp); |
| @@ -470,13 +688,37 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 470 | policy->cpu); | 688 | policy->cpu); |
| 471 | return ret; | 689 | return ret; |
| 472 | } | 690 | } |
| 473 | /* | 691 | } else { |
| 474 | * policy->driver_data is used as a flag for one-time | 692 | kernfs_put(kn); |
| 475 | * creation of throttle sysfs files. | ||
| 476 | */ | ||
| 477 | policy->driver_data = policy; | ||
| 478 | } | 693 | } |
| 479 | return cpufreq_table_validate_and_show(policy, powernv_freqs); | 694 | |
| 695 | gpstates = kzalloc(sizeof(*gpstates), GFP_KERNEL); | ||
| 696 | if (!gpstates) | ||
| 697 | return -ENOMEM; | ||
| 698 | |||
| 699 | policy->driver_data = gpstates; | ||
| 700 | |||
| 701 | /* initialize timer */ | ||
| 702 | init_timer_deferrable(&gpstates->timer); | ||
| 703 | gpstates->timer.data = (unsigned long)policy; | ||
| 704 | gpstates->timer.function = gpstate_timer_handler; | ||
| 705 | gpstates->timer.expires = jiffies + | ||
| 706 | msecs_to_jiffies(GPSTATE_TIMER_INTERVAL); | ||
| 707 | spin_lock_init(&gpstates->gpstate_lock); | ||
| 708 | ret = cpufreq_table_validate_and_show(policy, powernv_freqs); | ||
| 709 | |||
| 710 | if (ret < 0) | ||
| 711 | kfree(policy->driver_data); | ||
| 712 | |||
| 713 | return ret; | ||
| 714 | } | ||
| 715 | |||
| 716 | static int powernv_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||
| 717 | { | ||
| 718 | /* timer is deleted in cpufreq_cpu_stop() */ | ||
| 719 | kfree(policy->driver_data); | ||
| 720 | |||
| 721 | return 0; | ||
| 480 | } | 722 | } |
| 481 | 723 | ||
| 482 | static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb, | 724 | static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb, |
| @@ -604,15 +846,19 @@ static struct notifier_block powernv_cpufreq_opal_nb = { | |||
| 604 | static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy) | 846 | static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy) |
| 605 | { | 847 | { |
| 606 | struct powernv_smp_call_data freq_data; | 848 | struct powernv_smp_call_data freq_data; |
| 849 | struct global_pstate_info *gpstates = policy->driver_data; | ||
| 607 | 850 | ||
| 608 | freq_data.pstate_id = powernv_pstate_info.min; | 851 | freq_data.pstate_id = powernv_pstate_info.min; |
| 852 | freq_data.gpstate_id = powernv_pstate_info.min; | ||
| 609 | smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1); | 853 | smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1); |
| 854 | del_timer_sync(&gpstates->timer); | ||
| 610 | } | 855 | } |
| 611 | 856 | ||
| 612 | static struct cpufreq_driver powernv_cpufreq_driver = { | 857 | static struct cpufreq_driver powernv_cpufreq_driver = { |
| 613 | .name = "powernv-cpufreq", | 858 | .name = "powernv-cpufreq", |
| 614 | .flags = CPUFREQ_CONST_LOOPS, | 859 | .flags = CPUFREQ_CONST_LOOPS, |
| 615 | .init = powernv_cpufreq_cpu_init, | 860 | .init = powernv_cpufreq_cpu_init, |
| 861 | .exit = powernv_cpufreq_cpu_exit, | ||
| 616 | .verify = cpufreq_generic_frequency_table_verify, | 862 | .verify = cpufreq_generic_frequency_table_verify, |
| 617 | .target_index = powernv_cpufreq_target_index, | 863 | .target_index = powernv_cpufreq_target_index, |
| 618 | .get = powernv_cpufreq_get, | 864 | .get = powernv_cpufreq_get, |
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.h b/drivers/cpufreq/ppc_cbe_cpufreq.h index b4c00a5a6a59..3eace725ccd6 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.h +++ b/drivers/cpufreq/ppc_cbe_cpufreq.h | |||
| @@ -17,7 +17,7 @@ int cbe_cpufreq_get_pmode(int cpu); | |||
| 17 | 17 | ||
| 18 | int cbe_cpufreq_set_pmode_pmi(int cpu, unsigned int pmode); | 18 | int cbe_cpufreq_set_pmode_pmi(int cpu, unsigned int pmode); |
| 19 | 19 | ||
| 20 | #if defined(CONFIG_CPU_FREQ_CBE_PMI) || defined(CONFIG_CPU_FREQ_CBE_PMI_MODULE) | 20 | #if IS_ENABLED(CONFIG_CPU_FREQ_CBE_PMI) |
| 21 | extern bool cbe_cpufreq_has_pmi; | 21 | extern bool cbe_cpufreq_has_pmi; |
| 22 | #else | 22 | #else |
| 23 | #define cbe_cpufreq_has_pmi (0) | 23 | #define cbe_cpufreq_has_pmi (0) |
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c index 7969f7690498..7c4cd5c634f2 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
| 24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
| 25 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
| 26 | #include <linux/module.h> | 26 | #include <linux/init.h> |
| 27 | #include <linux/of_platform.h> | 27 | #include <linux/of_platform.h> |
| 28 | 28 | ||
| 29 | #include <asm/processor.h> | 29 | #include <asm/processor.h> |
| @@ -142,15 +142,4 @@ static int __init cbe_cpufreq_pmi_init(void) | |||
| 142 | 142 | ||
| 143 | return 0; | 143 | return 0; |
| 144 | } | 144 | } |
| 145 | 145 | device_initcall(cbe_cpufreq_pmi_init); | |
| 146 | static void __exit cbe_cpufreq_pmi_exit(void) | ||
| 147 | { | ||
| 148 | cpufreq_unregister_notifier(&pmi_notifier_block, CPUFREQ_POLICY_NOTIFIER); | ||
| 149 | pmi_unregister_handler(&cbe_pmi_handler); | ||
| 150 | } | ||
| 151 | |||
| 152 | module_init(cbe_cpufreq_pmi_init); | ||
| 153 | module_exit(cbe_cpufreq_pmi_exit); | ||
| 154 | |||
| 155 | MODULE_LICENSE("GPL"); | ||
| 156 | MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>"); | ||
diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c index 46fee1539cc8..ce345bf34d5d 100644 --- a/drivers/cpufreq/pxa2xx-cpufreq.c +++ b/drivers/cpufreq/pxa2xx-cpufreq.c | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | * | 29 | * |
| 30 | */ | 30 | */ |
| 31 | 31 | ||
| 32 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 33 | |||
| 32 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
| 33 | #include <linux/module.h> | 35 | #include <linux/module.h> |
| 34 | #include <linux/sched.h> | 36 | #include <linux/sched.h> |
| @@ -186,8 +188,7 @@ static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq) | |||
| 186 | 188 | ||
| 187 | ret = regulator_set_voltage(vcc_core, vmin, vmax); | 189 | ret = regulator_set_voltage(vcc_core, vmin, vmax); |
| 188 | if (ret) | 190 | if (ret) |
| 189 | pr_err("cpufreq: Failed to set vcc_core in [%dmV..%dmV]\n", | 191 | pr_err("Failed to set vcc_core in [%dmV..%dmV]\n", vmin, vmax); |
| 190 | vmin, vmax); | ||
| 191 | return ret; | 192 | return ret; |
| 192 | } | 193 | } |
| 193 | 194 | ||
| @@ -195,10 +196,10 @@ static void __init pxa_cpufreq_init_voltages(void) | |||
| 195 | { | 196 | { |
| 196 | vcc_core = regulator_get(NULL, "vcc_core"); | 197 | vcc_core = regulator_get(NULL, "vcc_core"); |
| 197 | if (IS_ERR(vcc_core)) { | 198 | if (IS_ERR(vcc_core)) { |
| 198 | pr_info("cpufreq: Didn't find vcc_core regulator\n"); | 199 | pr_info("Didn't find vcc_core regulator\n"); |
| 199 | vcc_core = NULL; | 200 | vcc_core = NULL; |
| 200 | } else { | 201 | } else { |
| 201 | pr_info("cpufreq: Found vcc_core regulator\n"); | 202 | pr_info("Found vcc_core regulator\n"); |
| 202 | } | 203 | } |
| 203 | } | 204 | } |
| 204 | #else | 205 | #else |
| @@ -233,9 +234,8 @@ static void pxa27x_guess_max_freq(void) | |||
| 233 | { | 234 | { |
| 234 | if (!pxa27x_maxfreq) { | 235 | if (!pxa27x_maxfreq) { |
| 235 | pxa27x_maxfreq = 416000; | 236 | pxa27x_maxfreq = 416000; |
| 236 | printk(KERN_INFO "PXA CPU 27x max frequency not defined " | 237 | pr_info("PXA CPU 27x max frequency not defined (pxa27x_maxfreq), assuming pxa271 with %dkHz maxfreq\n", |
| 237 | "(pxa27x_maxfreq), assuming pxa271 with %dkHz maxfreq\n", | 238 | pxa27x_maxfreq); |
| 238 | pxa27x_maxfreq); | ||
| 239 | } else { | 239 | } else { |
| 240 | pxa27x_maxfreq *= 1000; | 240 | pxa27x_maxfreq *= 1000; |
| 241 | } | 241 | } |
| @@ -408,7 +408,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
| 408 | */ | 408 | */ |
| 409 | if (cpu_is_pxa25x()) { | 409 | if (cpu_is_pxa25x()) { |
| 410 | find_freq_tables(&pxa255_freq_table, &pxa255_freqs); | 410 | find_freq_tables(&pxa255_freq_table, &pxa255_freqs); |
| 411 | pr_info("PXA255 cpufreq using %s frequency table\n", | 411 | pr_info("using %s frequency table\n", |
| 412 | pxa255_turbo_table ? "turbo" : "run"); | 412 | pxa255_turbo_table ? "turbo" : "run"); |
| 413 | 413 | ||
| 414 | cpufreq_table_validate_and_show(policy, pxa255_freq_table); | 414 | cpufreq_table_validate_and_show(policy, pxa255_freq_table); |
| @@ -417,7 +417,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
| 417 | cpufreq_table_validate_and_show(policy, pxa27x_freq_table); | 417 | cpufreq_table_validate_and_show(policy, pxa27x_freq_table); |
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | printk(KERN_INFO "PXA CPU frequency change support initialized\n"); | 420 | pr_info("frequency change support initialized\n"); |
| 421 | 421 | ||
| 422 | return 0; | 422 | return 0; |
| 423 | } | 423 | } |
diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index b23e525a7af3..53d8c3fb16f6 100644 --- a/drivers/cpufreq/qoriq-cpufreq.c +++ b/drivers/cpufreq/qoriq-cpufreq.c | |||
| @@ -301,10 +301,11 @@ err_np: | |||
| 301 | return -ENODEV; | 301 | return -ENODEV; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | static int __exit qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy) | 304 | static int qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy) |
| 305 | { | 305 | { |
| 306 | struct cpu_data *data = policy->driver_data; | 306 | struct cpu_data *data = policy->driver_data; |
| 307 | 307 | ||
| 308 | cpufreq_cooling_unregister(data->cdev); | ||
| 308 | kfree(data->pclk); | 309 | kfree(data->pclk); |
| 309 | kfree(data->table); | 310 | kfree(data->table); |
| 310 | kfree(data); | 311 | kfree(data); |
| @@ -333,8 +334,8 @@ static void qoriq_cpufreq_ready(struct cpufreq_policy *policy) | |||
| 333 | cpud->cdev = of_cpufreq_cooling_register(np, | 334 | cpud->cdev = of_cpufreq_cooling_register(np, |
| 334 | policy->related_cpus); | 335 | policy->related_cpus); |
| 335 | 336 | ||
| 336 | if (IS_ERR(cpud->cdev)) { | 337 | if (IS_ERR(cpud->cdev) && PTR_ERR(cpud->cdev) != -ENOSYS) { |
| 337 | pr_err("Failed to register cooling device cpu%d: %ld\n", | 338 | pr_err("cpu%d is not running as cooling device: %ld\n", |
| 338 | policy->cpu, PTR_ERR(cpud->cdev)); | 339 | policy->cpu, PTR_ERR(cpud->cdev)); |
| 339 | 340 | ||
| 340 | cpud->cdev = NULL; | 341 | cpud->cdev = NULL; |
| @@ -348,7 +349,7 @@ static struct cpufreq_driver qoriq_cpufreq_driver = { | |||
| 348 | .name = "qoriq_cpufreq", | 349 | .name = "qoriq_cpufreq", |
| 349 | .flags = CPUFREQ_CONST_LOOPS, | 350 | .flags = CPUFREQ_CONST_LOOPS, |
| 350 | .init = qoriq_cpufreq_cpu_init, | 351 | .init = qoriq_cpufreq_cpu_init, |
| 351 | .exit = __exit_p(qoriq_cpufreq_cpu_exit), | 352 | .exit = qoriq_cpufreq_cpu_exit, |
| 352 | .verify = cpufreq_generic_frequency_table_verify, | 353 | .verify = cpufreq_generic_frequency_table_verify, |
| 353 | .target_index = qoriq_cpufreq_target, | 354 | .target_index = qoriq_cpufreq_target, |
| 354 | .get = cpufreq_generic_get, | 355 | .get = cpufreq_generic_get, |
diff --git a/drivers/cpufreq/s3c2412-cpufreq.c b/drivers/cpufreq/s3c2412-cpufreq.c index eb262133fef2..b04b6f02bbdc 100644 --- a/drivers/cpufreq/s3c2412-cpufreq.c +++ b/drivers/cpufreq/s3c2412-cpufreq.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 14 | |||
| 13 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 14 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 15 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
| @@ -197,21 +199,20 @@ static int s3c2412_cpufreq_add(struct device *dev, | |||
| 197 | 199 | ||
| 198 | hclk = clk_get(NULL, "hclk"); | 200 | hclk = clk_get(NULL, "hclk"); |
| 199 | if (IS_ERR(hclk)) { | 201 | if (IS_ERR(hclk)) { |
| 200 | printk(KERN_ERR "%s: cannot find hclk clock\n", __func__); | 202 | pr_err("cannot find hclk clock\n"); |
| 201 | return -ENOENT; | 203 | return -ENOENT; |
| 202 | } | 204 | } |
| 203 | 205 | ||
| 204 | fclk = clk_get(NULL, "fclk"); | 206 | fclk = clk_get(NULL, "fclk"); |
| 205 | if (IS_ERR(fclk)) { | 207 | if (IS_ERR(fclk)) { |
| 206 | printk(KERN_ERR "%s: cannot find fclk clock\n", __func__); | 208 | pr_err("cannot find fclk clock\n"); |
| 207 | goto err_fclk; | 209 | goto err_fclk; |
| 208 | } | 210 | } |
| 209 | 211 | ||
| 210 | fclk_rate = clk_get_rate(fclk); | 212 | fclk_rate = clk_get_rate(fclk); |
| 211 | if (fclk_rate > 200000000) { | 213 | if (fclk_rate > 200000000) { |
| 212 | printk(KERN_INFO | 214 | pr_info("fclk %ld MHz, assuming 266MHz capable part\n", |
| 213 | "%s: fclk %ld MHz, assuming 266MHz capable part\n", | 215 | fclk_rate / 1000000); |
| 214 | __func__, fclk_rate / 1000000); | ||
| 215 | s3c2412_cpufreq_info.max.fclk = 266000000; | 216 | s3c2412_cpufreq_info.max.fclk = 266000000; |
| 216 | s3c2412_cpufreq_info.max.hclk = 133000000; | 217 | s3c2412_cpufreq_info.max.hclk = 133000000; |
| 217 | s3c2412_cpufreq_info.max.pclk = 66000000; | 218 | s3c2412_cpufreq_info.max.pclk = 66000000; |
| @@ -219,13 +220,13 @@ static int s3c2412_cpufreq_add(struct device *dev, | |||
| 219 | 220 | ||
| 220 | armclk = clk_get(NULL, "armclk"); | 221 | armclk = clk_get(NULL, "armclk"); |
| 221 | if (IS_ERR(armclk)) { | 222 | if (IS_ERR(armclk)) { |
| 222 | printk(KERN_ERR "%s: cannot find arm clock\n", __func__); | 223 | pr_err("cannot find arm clock\n"); |
| 223 | goto err_armclk; | 224 | goto err_armclk; |
| 224 | } | 225 | } |
| 225 | 226 | ||
| 226 | xtal = clk_get(NULL, "xtal"); | 227 | xtal = clk_get(NULL, "xtal"); |
| 227 | if (IS_ERR(xtal)) { | 228 | if (IS_ERR(xtal)) { |
| 228 | printk(KERN_ERR "%s: cannot find xtal clock\n", __func__); | 229 | pr_err("cannot find xtal clock\n"); |
| 229 | goto err_xtal; | 230 | goto err_xtal; |
| 230 | } | 231 | } |
| 231 | 232 | ||
diff --git a/drivers/cpufreq/s3c2440-cpufreq.c b/drivers/cpufreq/s3c2440-cpufreq.c index 0129f5c70a61..d0d75b65ddd6 100644 --- a/drivers/cpufreq/s3c2440-cpufreq.c +++ b/drivers/cpufreq/s3c2440-cpufreq.c | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 15 | |||
| 14 | #include <linux/init.h> | 16 | #include <linux/init.h> |
| 15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 16 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
| @@ -66,7 +68,7 @@ static int s3c2440_cpufreq_calcdivs(struct s3c_cpufreq_config *cfg) | |||
| 66 | __func__, fclk, armclk, hclk_max); | 68 | __func__, fclk, armclk, hclk_max); |
| 67 | 69 | ||
| 68 | if (armclk > fclk) { | 70 | if (armclk > fclk) { |
| 69 | printk(KERN_WARNING "%s: armclk > fclk\n", __func__); | 71 | pr_warn("%s: armclk > fclk\n", __func__); |
| 70 | armclk = fclk; | 72 | armclk = fclk; |
| 71 | } | 73 | } |
| 72 | 74 | ||
| @@ -273,7 +275,7 @@ static int s3c2440_cpufreq_add(struct device *dev, | |||
| 273 | armclk = s3c_cpufreq_clk_get(NULL, "armclk"); | 275 | armclk = s3c_cpufreq_clk_get(NULL, "armclk"); |
| 274 | 276 | ||
| 275 | if (IS_ERR(xtal) || IS_ERR(hclk) || IS_ERR(fclk) || IS_ERR(armclk)) { | 277 | if (IS_ERR(xtal) || IS_ERR(hclk) || IS_ERR(fclk) || IS_ERR(armclk)) { |
| 276 | printk(KERN_ERR "%s: failed to get clocks\n", __func__); | 278 | pr_err("%s: failed to get clocks\n", __func__); |
| 277 | return -ENOENT; | 279 | return -ENOENT; |
| 278 | } | 280 | } |
| 279 | 281 | ||
diff --git a/drivers/cpufreq/s3c24xx-cpufreq-debugfs.c b/drivers/cpufreq/s3c24xx-cpufreq-debugfs.c index 9b7b4289d66c..4d976e8dbb2f 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq-debugfs.c +++ b/drivers/cpufreq/s3c24xx-cpufreq-debugfs.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 14 | |||
| 13 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 14 | #include <linux/export.h> | 16 | #include <linux/export.h> |
| 15 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
| @@ -178,7 +180,7 @@ static int __init s3c_freq_debugfs_init(void) | |||
| 178 | { | 180 | { |
| 179 | dbgfs_root = debugfs_create_dir("s3c-cpufreq", NULL); | 181 | dbgfs_root = debugfs_create_dir("s3c-cpufreq", NULL); |
| 180 | if (IS_ERR(dbgfs_root)) { | 182 | if (IS_ERR(dbgfs_root)) { |
| 181 | printk(KERN_ERR "%s: error creating debugfs root\n", __func__); | 183 | pr_err("%s: error creating debugfs root\n", __func__); |
| 182 | return PTR_ERR(dbgfs_root); | 184 | return PTR_ERR(dbgfs_root); |
| 183 | } | 185 | } |
| 184 | 186 | ||
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index 68ef8fd9482f..ae8eaed77b70 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 14 | |||
| 13 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 14 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 15 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
| @@ -175,7 +177,7 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy, | |||
| 175 | cpu_new.freq.fclk = cpu_new.pll.frequency; | 177 | cpu_new.freq.fclk = cpu_new.pll.frequency; |
| 176 | 178 | ||
| 177 | if (s3c_cpufreq_calcdivs(&cpu_new) < 0) { | 179 | if (s3c_cpufreq_calcdivs(&cpu_new) < 0) { |
| 178 | printk(KERN_ERR "no divisors for %d\n", target_freq); | 180 | pr_err("no divisors for %d\n", target_freq); |
| 179 | goto err_notpossible; | 181 | goto err_notpossible; |
| 180 | } | 182 | } |
| 181 | 183 | ||
| @@ -187,7 +189,7 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy, | |||
| 187 | 189 | ||
| 188 | if (cpu_new.freq.hclk != cpu_cur.freq.hclk) { | 190 | if (cpu_new.freq.hclk != cpu_cur.freq.hclk) { |
| 189 | if (s3c_cpufreq_calcio(&cpu_new) < 0) { | 191 | if (s3c_cpufreq_calcio(&cpu_new) < 0) { |
| 190 | printk(KERN_ERR "%s: no IO timings\n", __func__); | 192 | pr_err("%s: no IO timings\n", __func__); |
| 191 | goto err_notpossible; | 193 | goto err_notpossible; |
| 192 | } | 194 | } |
| 193 | } | 195 | } |
| @@ -262,7 +264,7 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy, | |||
| 262 | return 0; | 264 | return 0; |
| 263 | 265 | ||
| 264 | err_notpossible: | 266 | err_notpossible: |
| 265 | printk(KERN_ERR "no compatible settings for %d\n", target_freq); | 267 | pr_err("no compatible settings for %d\n", target_freq); |
| 266 | return -EINVAL; | 268 | return -EINVAL; |
| 267 | } | 269 | } |
| 268 | 270 | ||
| @@ -331,7 +333,7 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy, | |||
| 331 | &index); | 333 | &index); |
| 332 | 334 | ||
| 333 | if (ret < 0) { | 335 | if (ret < 0) { |
| 334 | printk(KERN_ERR "%s: no PLL available\n", __func__); | 336 | pr_err("%s: no PLL available\n", __func__); |
| 335 | goto err_notpossible; | 337 | goto err_notpossible; |
| 336 | } | 338 | } |
| 337 | 339 | ||
| @@ -346,7 +348,7 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy, | |||
| 346 | return s3c_cpufreq_settarget(policy, target_freq, pll); | 348 | return s3c_cpufreq_settarget(policy, target_freq, pll); |
| 347 | 349 | ||
| 348 | err_notpossible: | 350 | err_notpossible: |
| 349 | printk(KERN_ERR "no compatible settings for %d\n", target_freq); | 351 | pr_err("no compatible settings for %d\n", target_freq); |
| 350 | return -EINVAL; | 352 | return -EINVAL; |
| 351 | } | 353 | } |
| 352 | 354 | ||
| @@ -356,7 +358,7 @@ struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name) | |||
| 356 | 358 | ||
| 357 | clk = clk_get(dev, name); | 359 | clk = clk_get(dev, name); |
| 358 | if (IS_ERR(clk)) | 360 | if (IS_ERR(clk)) |
| 359 | printk(KERN_ERR "cpufreq: failed to get clock '%s'\n", name); | 361 | pr_err("failed to get clock '%s'\n", name); |
| 360 | 362 | ||
| 361 | return clk; | 363 | return clk; |
| 362 | } | 364 | } |
| @@ -378,15 +380,16 @@ static int __init s3c_cpufreq_initclks(void) | |||
| 378 | 380 | ||
| 379 | if (IS_ERR(clk_fclk) || IS_ERR(clk_hclk) || IS_ERR(clk_pclk) || | 381 | if (IS_ERR(clk_fclk) || IS_ERR(clk_hclk) || IS_ERR(clk_pclk) || |
| 380 | IS_ERR(_clk_mpll) || IS_ERR(clk_arm) || IS_ERR(_clk_xtal)) { | 382 | IS_ERR(_clk_mpll) || IS_ERR(clk_arm) || IS_ERR(_clk_xtal)) { |
| 381 | printk(KERN_ERR "%s: could not get clock(s)\n", __func__); | 383 | pr_err("%s: could not get clock(s)\n", __func__); |
| 382 | return -ENOENT; | 384 | return -ENOENT; |
| 383 | } | 385 | } |
| 384 | 386 | ||
| 385 | printk(KERN_INFO "%s: clocks f=%lu,h=%lu,p=%lu,a=%lu\n", __func__, | 387 | pr_info("%s: clocks f=%lu,h=%lu,p=%lu,a=%lu\n", |
| 386 | clk_get_rate(clk_fclk) / 1000, | 388 | __func__, |
| 387 | clk_get_rate(clk_hclk) / 1000, | 389 | clk_get_rate(clk_fclk) / 1000, |
| 388 | clk_get_rate(clk_pclk) / 1000, | 390 | clk_get_rate(clk_hclk) / 1000, |
| 389 | clk_get_rate(clk_arm) / 1000); | 391 | clk_get_rate(clk_pclk) / 1000, |
| 392 | clk_get_rate(clk_arm) / 1000); | ||
| 390 | 393 | ||
| 391 | return 0; | 394 | return 0; |
| 392 | } | 395 | } |
| @@ -424,7 +427,7 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy) | |||
| 424 | 427 | ||
| 425 | ret = s3c_cpufreq_settarget(NULL, suspend_freq, &suspend_pll); | 428 | ret = s3c_cpufreq_settarget(NULL, suspend_freq, &suspend_pll); |
| 426 | if (ret) { | 429 | if (ret) { |
| 427 | printk(KERN_ERR "%s: failed to reset pll/freq\n", __func__); | 430 | pr_err("%s: failed to reset pll/freq\n", __func__); |
| 428 | return ret; | 431 | return ret; |
| 429 | } | 432 | } |
| 430 | 433 | ||
| @@ -449,13 +452,12 @@ static struct cpufreq_driver s3c24xx_driver = { | |||
| 449 | int s3c_cpufreq_register(struct s3c_cpufreq_info *info) | 452 | int s3c_cpufreq_register(struct s3c_cpufreq_info *info) |
| 450 | { | 453 | { |
| 451 | if (!info || !info->name) { | 454 | if (!info || !info->name) { |
| 452 | printk(KERN_ERR "%s: failed to pass valid information\n", | 455 | pr_err("%s: failed to pass valid information\n", __func__); |
| 453 | __func__); | ||
| 454 | return -EINVAL; | 456 | return -EINVAL; |
| 455 | } | 457 | } |
| 456 | 458 | ||
| 457 | printk(KERN_INFO "S3C24XX CPU Frequency driver, %s cpu support\n", | 459 | pr_info("S3C24XX CPU Frequency driver, %s cpu support\n", |
| 458 | info->name); | 460 | info->name); |
| 459 | 461 | ||
| 460 | /* check our driver info has valid data */ | 462 | /* check our driver info has valid data */ |
| 461 | 463 | ||
| @@ -478,7 +480,7 @@ int __init s3c_cpufreq_setboard(struct s3c_cpufreq_board *board) | |||
| 478 | struct s3c_cpufreq_board *ours; | 480 | struct s3c_cpufreq_board *ours; |
| 479 | 481 | ||
| 480 | if (!board) { | 482 | if (!board) { |
| 481 | printk(KERN_INFO "%s: no board data\n", __func__); | 483 | pr_info("%s: no board data\n", __func__); |
| 482 | return -EINVAL; | 484 | return -EINVAL; |
| 483 | } | 485 | } |
| 484 | 486 | ||
| @@ -487,7 +489,7 @@ int __init s3c_cpufreq_setboard(struct s3c_cpufreq_board *board) | |||
| 487 | 489 | ||
| 488 | ours = kzalloc(sizeof(*ours), GFP_KERNEL); | 490 | ours = kzalloc(sizeof(*ours), GFP_KERNEL); |
| 489 | if (ours == NULL) { | 491 | if (ours == NULL) { |
| 490 | printk(KERN_ERR "%s: no memory\n", __func__); | 492 | pr_err("%s: no memory\n", __func__); |
| 491 | return -ENOMEM; | 493 | return -ENOMEM; |
| 492 | } | 494 | } |
| 493 | 495 | ||
| @@ -502,15 +504,15 @@ static int __init s3c_cpufreq_auto_io(void) | |||
| 502 | int ret; | 504 | int ret; |
| 503 | 505 | ||
| 504 | if (!cpu_cur.info->get_iotiming) { | 506 | if (!cpu_cur.info->get_iotiming) { |
| 505 | printk(KERN_ERR "%s: get_iotiming undefined\n", __func__); | 507 | pr_err("%s: get_iotiming undefined\n", __func__); |
| 506 | return -ENOENT; | 508 | return -ENOENT; |
| 507 | } | 509 | } |
| 508 | 510 | ||
| 509 | printk(KERN_INFO "%s: working out IO settings\n", __func__); | 511 | pr_info("%s: working out IO settings\n", __func__); |
| 510 | 512 | ||
| 511 | ret = (cpu_cur.info->get_iotiming)(&cpu_cur, &s3c24xx_iotiming); | 513 | ret = (cpu_cur.info->get_iotiming)(&cpu_cur, &s3c24xx_iotiming); |
| 512 | if (ret) | 514 | if (ret) |
| 513 | printk(KERN_ERR "%s: failed to get timings\n", __func__); | 515 | pr_err("%s: failed to get timings\n", __func__); |
| 514 | 516 | ||
| 515 | return ret; | 517 | return ret; |
| 516 | } | 518 | } |
| @@ -561,7 +563,7 @@ static void s3c_cpufreq_update_loctkime(void) | |||
| 561 | val = calc_locktime(rate, cpu_cur.info->locktime_u) << bits; | 563 | val = calc_locktime(rate, cpu_cur.info->locktime_u) << bits; |
| 562 | val |= calc_locktime(rate, cpu_cur.info->locktime_m); | 564 | val |= calc_locktime(rate, cpu_cur.info->locktime_m); |
| 563 | 565 | ||
| 564 | printk(KERN_INFO "%s: new locktime is 0x%08x\n", __func__, val); | 566 | pr_info("%s: new locktime is 0x%08x\n", __func__, val); |
| 565 | __raw_writel(val, S3C2410_LOCKTIME); | 567 | __raw_writel(val, S3C2410_LOCKTIME); |
| 566 | } | 568 | } |
| 567 | 569 | ||
| @@ -580,7 +582,7 @@ static int s3c_cpufreq_build_freq(void) | |||
| 580 | 582 | ||
| 581 | ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL); | 583 | ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL); |
| 582 | if (!ftab) { | 584 | if (!ftab) { |
| 583 | printk(KERN_ERR "%s: no memory for tables\n", __func__); | 585 | pr_err("%s: no memory for tables\n", __func__); |
| 584 | return -ENOMEM; | 586 | return -ENOMEM; |
| 585 | } | 587 | } |
| 586 | 588 | ||
| @@ -608,15 +610,14 @@ static int __init s3c_cpufreq_initcall(void) | |||
| 608 | if (cpu_cur.board->auto_io) { | 610 | if (cpu_cur.board->auto_io) { |
| 609 | ret = s3c_cpufreq_auto_io(); | 611 | ret = s3c_cpufreq_auto_io(); |
| 610 | if (ret) { | 612 | if (ret) { |
| 611 | printk(KERN_ERR "%s: failed to get io timing\n", | 613 | pr_err("%s: failed to get io timing\n", |
| 612 | __func__); | 614 | __func__); |
| 613 | goto out; | 615 | goto out; |
| 614 | } | 616 | } |
| 615 | } | 617 | } |
| 616 | 618 | ||
| 617 | if (cpu_cur.board->need_io && !cpu_cur.info->set_iotiming) { | 619 | if (cpu_cur.board->need_io && !cpu_cur.info->set_iotiming) { |
| 618 | printk(KERN_ERR "%s: no IO support registered\n", | 620 | pr_err("%s: no IO support registered\n", __func__); |
| 619 | __func__); | ||
| 620 | ret = -EINVAL; | 621 | ret = -EINVAL; |
| 621 | goto out; | 622 | goto out; |
| 622 | } | 623 | } |
| @@ -666,9 +667,9 @@ int s3c_plltab_register(struct cpufreq_frequency_table *plls, | |||
| 666 | vals += plls_no; | 667 | vals += plls_no; |
| 667 | vals->frequency = CPUFREQ_TABLE_END; | 668 | vals->frequency = CPUFREQ_TABLE_END; |
| 668 | 669 | ||
| 669 | printk(KERN_INFO "cpufreq: %d PLL entries\n", plls_no); | 670 | pr_info("%d PLL entries\n", plls_no); |
| 670 | } else | 671 | } else |
| 671 | printk(KERN_ERR "cpufreq: no memory for PLL tables\n"); | 672 | pr_err("no memory for PLL tables\n"); |
| 672 | 673 | ||
| 673 | return vals ? 0 : -ENOMEM; | 674 | return vals ? 0 : -ENOMEM; |
| 674 | } | 675 | } |
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index a145b319d171..06d85917b6d5 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 13 | |||
| 12 | #include <linux/types.h> | 14 | #include <linux/types.h> |
| 13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> | 16 | #include <linux/init.h> |
| @@ -205,7 +207,7 @@ static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq) | |||
| 205 | } else if (ch == DMC1) { | 207 | } else if (ch == DMC1) { |
| 206 | reg = (dmc_base[1] + 0x30); | 208 | reg = (dmc_base[1] + 0x30); |
| 207 | } else { | 209 | } else { |
| 208 | printk(KERN_ERR "Cannot find DMC port\n"); | 210 | pr_err("Cannot find DMC port\n"); |
| 209 | return; | 211 | return; |
| 210 | } | 212 | } |
| 211 | 213 | ||
| @@ -534,7 +536,7 @@ static int s5pv210_cpu_init(struct cpufreq_policy *policy) | |||
| 534 | mem_type = check_mem_type(dmc_base[0]); | 536 | mem_type = check_mem_type(dmc_base[0]); |
| 535 | 537 | ||
| 536 | if ((mem_type != LPDDR) && (mem_type != LPDDR2)) { | 538 | if ((mem_type != LPDDR) && (mem_type != LPDDR2)) { |
| 537 | printk(KERN_ERR "CPUFreq doesn't support this memory type\n"); | 539 | pr_err("CPUFreq doesn't support this memory type\n"); |
| 538 | ret = -EINVAL; | 540 | ret = -EINVAL; |
| 539 | goto out_dmc1; | 541 | goto out_dmc1; |
| 540 | } | 542 | } |
| @@ -635,13 +637,13 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) | |||
| 635 | 637 | ||
| 636 | arm_regulator = regulator_get(NULL, "vddarm"); | 638 | arm_regulator = regulator_get(NULL, "vddarm"); |
| 637 | if (IS_ERR(arm_regulator)) { | 639 | if (IS_ERR(arm_regulator)) { |
| 638 | pr_err("failed to get regulator vddarm"); | 640 | pr_err("failed to get regulator vddarm\n"); |
| 639 | return PTR_ERR(arm_regulator); | 641 | return PTR_ERR(arm_regulator); |
| 640 | } | 642 | } |
| 641 | 643 | ||
| 642 | int_regulator = regulator_get(NULL, "vddint"); | 644 | int_regulator = regulator_get(NULL, "vddint"); |
| 643 | if (IS_ERR(int_regulator)) { | 645 | if (IS_ERR(int_regulator)) { |
| 644 | pr_err("failed to get regulator vddint"); | 646 | pr_err("failed to get regulator vddint\n"); |
| 645 | regulator_put(arm_regulator); | 647 | regulator_put(arm_regulator); |
| 646 | return PTR_ERR(int_regulator); | 648 | return PTR_ERR(int_regulator); |
| 647 | } | 649 | } |
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c index ac84e4818014..4225501a4b78 100644 --- a/drivers/cpufreq/sc520_freq.c +++ b/drivers/cpufreq/sc520_freq.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | * 2005-03-30: - initial revision | 13 | * 2005-03-30: - initial revision |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 17 | |||
| 16 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
| 17 | #include <linux/module.h> | 19 | #include <linux/module.h> |
| 18 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| @@ -30,8 +32,6 @@ | |||
| 30 | 32 | ||
| 31 | static __u8 __iomem *cpuctl; | 33 | static __u8 __iomem *cpuctl; |
| 32 | 34 | ||
| 33 | #define PFX "sc520_freq: " | ||
| 34 | |||
| 35 | static struct cpufreq_frequency_table sc520_freq_table[] = { | 35 | static struct cpufreq_frequency_table sc520_freq_table[] = { |
| 36 | {0, 0x01, 100000}, | 36 | {0, 0x01, 100000}, |
| 37 | {0, 0x02, 133000}, | 37 | {0, 0x02, 133000}, |
| @@ -44,8 +44,8 @@ static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu) | |||
| 44 | 44 | ||
| 45 | switch (clockspeed_reg & 0x03) { | 45 | switch (clockspeed_reg & 0x03) { |
| 46 | default: | 46 | default: |
| 47 | printk(KERN_ERR PFX "error: cpuctl register has unexpected " | 47 | pr_err("error: cpuctl register has unexpected value %02x\n", |
| 48 | "value %02x\n", clockspeed_reg); | 48 | clockspeed_reg); |
| 49 | case 0x01: | 49 | case 0x01: |
| 50 | return 100000; | 50 | return 100000; |
| 51 | case 0x02: | 51 | case 0x02: |
| @@ -112,7 +112,7 @@ static int __init sc520_freq_init(void) | |||
| 112 | 112 | ||
| 113 | cpuctl = ioremap((unsigned long)(MMCR_BASE + OFFS_CPUCTL), 1); | 113 | cpuctl = ioremap((unsigned long)(MMCR_BASE + OFFS_CPUCTL), 1); |
| 114 | if (!cpuctl) { | 114 | if (!cpuctl) { |
| 115 | printk(KERN_ERR "sc520_freq: error: failed to remap memory\n"); | 115 | pr_err("sc520_freq: error: failed to remap memory\n"); |
| 116 | return -ENOMEM; | 116 | return -ENOMEM; |
| 117 | } | 117 | } |
| 118 | 118 | ||
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c index de5e89b2eaaa..e8a7bf57b31b 100644 --- a/drivers/cpufreq/scpi-cpufreq.c +++ b/drivers/cpufreq/scpi-cpufreq.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 20 | 20 | ||
| 21 | #include <linux/cpu.h> | ||
| 21 | #include <linux/cpufreq.h> | 22 | #include <linux/cpufreq.h> |
| 22 | #include <linux/module.h> | 23 | #include <linux/module.h> |
| 23 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
| @@ -38,10 +39,20 @@ static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev) | |||
| 38 | return scpi_ops->dvfs_get_info(domain); | 39 | return scpi_ops->dvfs_get_info(domain); |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | static int scpi_opp_table_ops(struct device *cpu_dev, bool remove) | 42 | static int scpi_get_transition_latency(struct device *cpu_dev) |
| 42 | { | 43 | { |
| 43 | int idx, ret = 0; | 44 | struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); |
| 45 | |||
| 46 | if (IS_ERR(info)) | ||
| 47 | return PTR_ERR(info); | ||
| 48 | return info->latency; | ||
| 49 | } | ||
| 50 | |||
| 51 | static int scpi_init_opp_table(const struct cpumask *cpumask) | ||
| 52 | { | ||
| 53 | int idx, ret; | ||
| 44 | struct scpi_opp *opp; | 54 | struct scpi_opp *opp; |
| 55 | struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask)); | ||
| 45 | struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); | 56 | struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); |
| 46 | 57 | ||
| 47 | if (IS_ERR(info)) | 58 | if (IS_ERR(info)) |
| @@ -51,11 +62,7 @@ static int scpi_opp_table_ops(struct device *cpu_dev, bool remove) | |||
| 51 | return -EIO; | 62 | return -EIO; |
| 52 | 63 | ||
| 53 | for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) { | 64 | for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) { |
| 54 | if (remove) | 65 | ret = dev_pm_opp_add(cpu_dev, opp->freq, opp->m_volt * 1000); |
| 55 | dev_pm_opp_remove(cpu_dev, opp->freq); | ||
| 56 | else | ||
| 57 | ret = dev_pm_opp_add(cpu_dev, opp->freq, | ||
| 58 | opp->m_volt * 1000); | ||
| 59 | if (ret) { | 66 | if (ret) { |
| 60 | dev_warn(cpu_dev, "failed to add opp %uHz %umV\n", | 67 | dev_warn(cpu_dev, "failed to add opp %uHz %umV\n", |
| 61 | opp->freq, opp->m_volt); | 68 | opp->freq, opp->m_volt); |
| @@ -64,33 +71,19 @@ static int scpi_opp_table_ops(struct device *cpu_dev, bool remove) | |||
| 64 | return ret; | 71 | return ret; |
| 65 | } | 72 | } |
| 66 | } | 73 | } |
| 67 | return ret; | ||
| 68 | } | ||
| 69 | 74 | ||
| 70 | static int scpi_get_transition_latency(struct device *cpu_dev) | 75 | ret = dev_pm_opp_set_sharing_cpus(cpu_dev, cpumask); |
| 71 | { | 76 | if (ret) |
| 72 | struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); | 77 | dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", |
| 73 | 78 | __func__, ret); | |
| 74 | if (IS_ERR(info)) | 79 | return ret; |
| 75 | return PTR_ERR(info); | ||
| 76 | return info->latency; | ||
| 77 | } | ||
| 78 | |||
| 79 | static int scpi_init_opp_table(struct device *cpu_dev) | ||
| 80 | { | ||
| 81 | return scpi_opp_table_ops(cpu_dev, false); | ||
| 82 | } | ||
| 83 | |||
| 84 | static void scpi_free_opp_table(struct device *cpu_dev) | ||
| 85 | { | ||
| 86 | scpi_opp_table_ops(cpu_dev, true); | ||
| 87 | } | 80 | } |
| 88 | 81 | ||
| 89 | static struct cpufreq_arm_bL_ops scpi_cpufreq_ops = { | 82 | static struct cpufreq_arm_bL_ops scpi_cpufreq_ops = { |
| 90 | .name = "scpi", | 83 | .name = "scpi", |
| 91 | .get_transition_latency = scpi_get_transition_latency, | 84 | .get_transition_latency = scpi_get_transition_latency, |
| 92 | .init_opp_table = scpi_init_opp_table, | 85 | .init_opp_table = scpi_init_opp_table, |
| 93 | .free_opp_table = scpi_free_opp_table, | 86 | .free_opp_table = dev_pm_opp_cpumask_remove_table, |
| 94 | }; | 87 | }; |
| 95 | 88 | ||
| 96 | static int scpi_cpufreq_probe(struct platform_device *pdev) | 89 | static int scpi_cpufreq_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 7d4a31571608..41bc5397f4bb 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | * Copyright (C) 2003 Jeremy Fitzhardinge <jeremy@goop.org> | 13 | * Copyright (C) 2003 Jeremy Fitzhardinge <jeremy@goop.org> |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 17 | |||
| 16 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
| 17 | #include <linux/module.h> | 19 | #include <linux/module.h> |
| 18 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| @@ -27,7 +29,6 @@ | |||
| 27 | #include <asm/cpufeature.h> | 29 | #include <asm/cpufeature.h> |
| 28 | #include <asm/cpu_device_id.h> | 30 | #include <asm/cpu_device_id.h> |
| 29 | 31 | ||
| 30 | #define PFX "speedstep-centrino: " | ||
| 31 | #define MAINTAINER "linux-pm@vger.kernel.org" | 32 | #define MAINTAINER "linux-pm@vger.kernel.org" |
| 32 | 33 | ||
| 33 | #define INTEL_MSR_RANGE (0xffff) | 34 | #define INTEL_MSR_RANGE (0xffff) |
| @@ -386,8 +387,7 @@ static int centrino_cpu_init(struct cpufreq_policy *policy) | |||
| 386 | /* check to see if it stuck */ | 387 | /* check to see if it stuck */ |
| 387 | rdmsr(MSR_IA32_MISC_ENABLE, l, h); | 388 | rdmsr(MSR_IA32_MISC_ENABLE, l, h); |
| 388 | if (!(l & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP)) { | 389 | if (!(l & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP)) { |
| 389 | printk(KERN_INFO PFX | 390 | pr_info("couldn't enable Enhanced SpeedStep\n"); |
| 390 | "couldn't enable Enhanced SpeedStep\n"); | ||
| 391 | return -ENODEV; | 391 | return -ENODEV; |
| 392 | } | 392 | } |
| 393 | } | 393 | } |
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c index 37555c6b86a7..b86953a3ddc4 100644 --- a/drivers/cpufreq/speedstep-ich.c +++ b/drivers/cpufreq/speedstep-ich.c | |||
| @@ -18,6 +18,8 @@ | |||
| 18 | * SPEEDSTEP - DEFINITIONS * | 18 | * SPEEDSTEP - DEFINITIONS * |
| 19 | *********************************************************************/ | 19 | *********************************************************************/ |
| 20 | 20 | ||
| 21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 22 | |||
| 21 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
| 22 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 23 | #include <linux/init.h> | 25 | #include <linux/init.h> |
| @@ -68,13 +70,13 @@ static int speedstep_find_register(void) | |||
| 68 | /* get PMBASE */ | 70 | /* get PMBASE */ |
| 69 | pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase); | 71 | pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase); |
| 70 | if (!(pmbase & 0x01)) { | 72 | if (!(pmbase & 0x01)) { |
| 71 | printk(KERN_ERR "speedstep-ich: could not find speedstep register\n"); | 73 | pr_err("could not find speedstep register\n"); |
| 72 | return -ENODEV; | 74 | return -ENODEV; |
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | pmbase &= 0xFFFFFFFE; | 77 | pmbase &= 0xFFFFFFFE; |
| 76 | if (!pmbase) { | 78 | if (!pmbase) { |
| 77 | printk(KERN_ERR "speedstep-ich: could not find speedstep register\n"); | 79 | pr_err("could not find speedstep register\n"); |
| 78 | return -ENODEV; | 80 | return -ENODEV; |
| 79 | } | 81 | } |
| 80 | 82 | ||
| @@ -136,7 +138,7 @@ static void speedstep_set_state(unsigned int state) | |||
| 136 | pr_debug("change to %u MHz succeeded\n", | 138 | pr_debug("change to %u MHz succeeded\n", |
| 137 | speedstep_get_frequency(speedstep_processor) / 1000); | 139 | speedstep_get_frequency(speedstep_processor) / 1000); |
| 138 | else | 140 | else |
| 139 | printk(KERN_ERR "cpufreq: change failed - I/O error\n"); | 141 | pr_err("change failed - I/O error\n"); |
| 140 | 142 | ||
| 141 | return; | 143 | return; |
| 142 | } | 144 | } |
diff --git a/drivers/cpufreq/speedstep-lib.c b/drivers/cpufreq/speedstep-lib.c index 15d3214aaa00..1b8062182c81 100644 --- a/drivers/cpufreq/speedstep-lib.c +++ b/drivers/cpufreq/speedstep-lib.c | |||
| @@ -8,6 +8,8 @@ | |||
| 8 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* | 8 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 12 | |||
| 11 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 13 | #include <linux/moduleparam.h> | 15 | #include <linux/moduleparam.h> |
| @@ -153,7 +155,7 @@ static unsigned int pentium_core_get_frequency(void) | |||
| 153 | fsb = 333333; | 155 | fsb = 333333; |
| 154 | break; | 156 | break; |
| 155 | default: | 157 | default: |
| 156 | printk(KERN_ERR "PCORE - MSR_FSB_FREQ undefined value"); | 158 | pr_err("PCORE - MSR_FSB_FREQ undefined value\n"); |
| 157 | } | 159 | } |
| 158 | 160 | ||
| 159 | rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); | 161 | rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); |
| @@ -453,11 +455,8 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor, | |||
| 453 | */ | 455 | */ |
| 454 | if (*transition_latency > 10000000 || | 456 | if (*transition_latency > 10000000 || |
| 455 | *transition_latency < 50000) { | 457 | *transition_latency < 50000) { |
| 456 | printk(KERN_WARNING PFX "frequency transition " | 458 | pr_warn("frequency transition measured seems out of range (%u nSec), falling back to a safe one of %u nSec\n", |
| 457 | "measured seems out of range (%u " | 459 | *transition_latency, 500000); |
| 458 | "nSec), falling back to a safe one of" | ||
| 459 | "%u nSec.\n", | ||
| 460 | *transition_latency, 500000); | ||
| 461 | *transition_latency = 500000; | 460 | *transition_latency = 500000; |
| 462 | } | 461 | } |
| 463 | } | 462 | } |
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c index 819229e824fb..770a9ae1999a 100644 --- a/drivers/cpufreq/speedstep-smi.c +++ b/drivers/cpufreq/speedstep-smi.c | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | * SPEEDSTEP - DEFINITIONS * | 12 | * SPEEDSTEP - DEFINITIONS * |
| 13 | *********************************************************************/ | 13 | *********************************************************************/ |
| 14 | 14 | ||
| 15 | #define pr_fmt(fmt) "cpufreq: " fmt | ||
| 16 | |||
| 15 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 16 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 17 | #include <linux/moduleparam.h> | 19 | #include <linux/moduleparam.h> |
| @@ -204,9 +206,8 @@ static void speedstep_set_state(unsigned int state) | |||
| 204 | (speedstep_freqs[new_state].frequency / 1000), | 206 | (speedstep_freqs[new_state].frequency / 1000), |
| 205 | retry, result); | 207 | retry, result); |
| 206 | else | 208 | else |
| 207 | printk(KERN_ERR "cpufreq: change to state %u " | 209 | pr_err("change to state %u failed with new_state %u and result %u\n", |
| 208 | "failed with new_state %u and result %u\n", | 210 | state, new_state, result); |
| 209 | state, new_state, result); | ||
| 210 | 211 | ||
| 211 | return; | 212 | return; |
| 212 | } | 213 | } |
diff --git a/drivers/cpufreq/tegra124-cpufreq.c b/drivers/cpufreq/tegra124-cpufreq.c index 20bcceb58ccc..43530254201a 100644 --- a/drivers/cpufreq/tegra124-cpufreq.c +++ b/drivers/cpufreq/tegra124-cpufreq.c | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 15 | 15 | ||
| 16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
| 17 | #include <linux/cpufreq-dt.h> | ||
| 18 | #include <linux/err.h> | 17 | #include <linux/err.h> |
| 19 | #include <linux/init.h> | 18 | #include <linux/init.h> |
| 20 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| @@ -69,10 +68,6 @@ static void tegra124_cpu_switch_to_pllx(struct tegra124_cpufreq_priv *priv) | |||
| 69 | clk_set_parent(priv->cpu_clk, priv->pllx_clk); | 68 | clk_set_parent(priv->cpu_clk, priv->pllx_clk); |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | static struct cpufreq_dt_platform_data cpufreq_dt_pd = { | ||
| 73 | .independent_clocks = false, | ||
| 74 | }; | ||
| 75 | |||
| 76 | static int tegra124_cpufreq_probe(struct platform_device *pdev) | 71 | static int tegra124_cpufreq_probe(struct platform_device *pdev) |
| 77 | { | 72 | { |
| 78 | struct tegra124_cpufreq_priv *priv; | 73 | struct tegra124_cpufreq_priv *priv; |
| @@ -129,8 +124,6 @@ static int tegra124_cpufreq_probe(struct platform_device *pdev) | |||
| 129 | 124 | ||
| 130 | cpufreq_dt_devinfo.name = "cpufreq-dt"; | 125 | cpufreq_dt_devinfo.name = "cpufreq-dt"; |
| 131 | cpufreq_dt_devinfo.parent = &pdev->dev; | 126 | cpufreq_dt_devinfo.parent = &pdev->dev; |
| 132 | cpufreq_dt_devinfo.data = &cpufreq_dt_pd; | ||
| 133 | cpufreq_dt_devinfo.size_data = sizeof(cpufreq_dt_pd); | ||
| 134 | 127 | ||
| 135 | priv->cpufreq_dt_pdev = | 128 | priv->cpufreq_dt_pdev = |
| 136 | platform_device_register_full(&cpufreq_dt_devinfo); | 129 | platform_device_register_full(&cpufreq_dt_devinfo); |
diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c b/drivers/cpufreq/vexpress-spc-cpufreq.c index 433e93fd4900..87e5bdc5ec74 100644 --- a/drivers/cpufreq/vexpress-spc-cpufreq.c +++ b/drivers/cpufreq/vexpress-spc-cpufreq.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 20 | 20 | ||
| 21 | #include <linux/cpu.h> | ||
| 21 | #include <linux/cpufreq.h> | 22 | #include <linux/cpufreq.h> |
| 22 | #include <linux/module.h> | 23 | #include <linux/module.h> |
| 23 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
| @@ -26,8 +27,9 @@ | |||
| 26 | 27 | ||
| 27 | #include "arm_big_little.h" | 28 | #include "arm_big_little.h" |
| 28 | 29 | ||
| 29 | static int ve_spc_init_opp_table(struct device *cpu_dev) | 30 | static int ve_spc_init_opp_table(const struct cpumask *cpumask) |
| 30 | { | 31 | { |
| 32 | struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask)); | ||
| 31 | /* | 33 | /* |
| 32 | * platform specific SPC code must initialise the opp table | 34 | * platform specific SPC code must initialise the opp table |
| 33 | * so just check if the OPP count is non-zero | 35 | * so just check if the OPP count is non-zero |
diff --git a/include/linux/cpufreq-dt.h b/include/linux/cpufreq-dt.h deleted file mode 100644 index 0414009e2c30..000000000000 --- a/include/linux/cpufreq-dt.h +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014 Marvell | ||
| 3 | * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #ifndef __CPUFREQ_DT_H__ | ||
| 11 | #define __CPUFREQ_DT_H__ | ||
| 12 | |||
| 13 | struct cpufreq_dt_platform_data { | ||
| 14 | /* | ||
| 15 | * True when each CPU has its own clock to control its | ||
| 16 | * frequency, false when all CPUs are controlled by a single | ||
| 17 | * clock. | ||
| 18 | */ | ||
| 19 | bool independent_clocks; | ||
| 20 | }; | ||
| 21 | |||
| 22 | #endif /* __CPUFREQ_DT_H__ */ | ||
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 718e8725de8a..4e81e08db752 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
| @@ -102,6 +102,17 @@ struct cpufreq_policy { | |||
| 102 | */ | 102 | */ |
| 103 | struct rw_semaphore rwsem; | 103 | struct rw_semaphore rwsem; |
| 104 | 104 | ||
| 105 | /* | ||
| 106 | * Fast switch flags: | ||
| 107 | * - fast_switch_possible should be set by the driver if it can | ||
| 108 | * guarantee that frequency can be changed on any CPU sharing the | ||
| 109 | * policy and that the change will affect all of the policy CPUs then. | ||
| 110 | * - fast_switch_enabled is to be set by governors that support fast | ||
| 111 | * freqnency switching with the help of cpufreq_enable_fast_switch(). | ||
| 112 | */ | ||
| 113 | bool fast_switch_possible; | ||
| 114 | bool fast_switch_enabled; | ||
| 115 | |||
| 105 | /* Synchronization for frequency transitions */ | 116 | /* Synchronization for frequency transitions */ |
| 106 | bool transition_ongoing; /* Tracks transition status */ | 117 | bool transition_ongoing; /* Tracks transition status */ |
| 107 | spinlock_t transition_lock; | 118 | spinlock_t transition_lock; |
| @@ -156,6 +167,8 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); | |||
| 156 | int cpufreq_update_policy(unsigned int cpu); | 167 | int cpufreq_update_policy(unsigned int cpu); |
| 157 | bool have_governor_per_policy(void); | 168 | bool have_governor_per_policy(void); |
| 158 | struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); | 169 | struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); |
| 170 | void cpufreq_enable_fast_switch(struct cpufreq_policy *policy); | ||
| 171 | void cpufreq_disable_fast_switch(struct cpufreq_policy *policy); | ||
| 159 | #else | 172 | #else |
| 160 | static inline unsigned int cpufreq_get(unsigned int cpu) | 173 | static inline unsigned int cpufreq_get(unsigned int cpu) |
| 161 | { | 174 | { |
| @@ -236,6 +249,8 @@ struct cpufreq_driver { | |||
| 236 | unsigned int relation); /* Deprecated */ | 249 | unsigned int relation); /* Deprecated */ |
| 237 | int (*target_index)(struct cpufreq_policy *policy, | 250 | int (*target_index)(struct cpufreq_policy *policy, |
| 238 | unsigned int index); | 251 | unsigned int index); |
| 252 | unsigned int (*fast_switch)(struct cpufreq_policy *policy, | ||
| 253 | unsigned int target_freq); | ||
| 239 | /* | 254 | /* |
| 240 | * Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION | 255 | * Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION |
| 241 | * unset. | 256 | * unset. |
| @@ -426,6 +441,20 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, | |||
| 426 | #define CPUFREQ_POLICY_POWERSAVE (1) | 441 | #define CPUFREQ_POLICY_POWERSAVE (1) |
| 427 | #define CPUFREQ_POLICY_PERFORMANCE (2) | 442 | #define CPUFREQ_POLICY_PERFORMANCE (2) |
| 428 | 443 | ||
| 444 | /* | ||
| 445 | * The polling frequency depends on the capability of the processor. Default | ||
| 446 | * polling frequency is 1000 times the transition latency of the processor. The | ||
| 447 | * ondemand governor will work on any processor with transition latency <= 10ms, | ||
| 448 | * using appropriate sampling rate. | ||
| 449 | * | ||
| 450 | * For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL) | ||
| 451 | * the ondemand governor will not work. All times here are in us (microseconds). | ||
| 452 | */ | ||
| 453 | #define MIN_SAMPLING_RATE_RATIO (2) | ||
| 454 | #define LATENCY_MULTIPLIER (1000) | ||
| 455 | #define MIN_LATENCY_MULTIPLIER (20) | ||
| 456 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) | ||
| 457 | |||
| 429 | /* Governor Events */ | 458 | /* Governor Events */ |
| 430 | #define CPUFREQ_GOV_START 1 | 459 | #define CPUFREQ_GOV_START 1 |
| 431 | #define CPUFREQ_GOV_STOP 2 | 460 | #define CPUFREQ_GOV_STOP 2 |
| @@ -450,6 +479,8 @@ struct cpufreq_governor { | |||
| 450 | }; | 479 | }; |
| 451 | 480 | ||
| 452 | /* Pass a target to the cpufreq driver */ | 481 | /* Pass a target to the cpufreq driver */ |
| 482 | unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, | ||
| 483 | unsigned int target_freq); | ||
| 453 | int cpufreq_driver_target(struct cpufreq_policy *policy, | 484 | int cpufreq_driver_target(struct cpufreq_policy *policy, |
| 454 | unsigned int target_freq, | 485 | unsigned int target_freq, |
| 455 | unsigned int relation); | 486 | unsigned int relation); |
| @@ -462,6 +493,29 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor); | |||
| 462 | struct cpufreq_governor *cpufreq_default_governor(void); | 493 | struct cpufreq_governor *cpufreq_default_governor(void); |
| 463 | struct cpufreq_governor *cpufreq_fallback_governor(void); | 494 | struct cpufreq_governor *cpufreq_fallback_governor(void); |
| 464 | 495 | ||
| 496 | /* Governor attribute set */ | ||
| 497 | struct gov_attr_set { | ||
| 498 | struct kobject kobj; | ||
| 499 | struct list_head policy_list; | ||
| 500 | struct mutex update_lock; | ||
| 501 | int usage_count; | ||
| 502 | }; | ||
| 503 | |||
| 504 | /* sysfs ops for cpufreq governors */ | ||
| 505 | extern const struct sysfs_ops governor_sysfs_ops; | ||
| 506 | |||
| 507 | void gov_attr_set_init(struct gov_attr_set *attr_set, struct list_head *list_node); | ||
| 508 | void gov_attr_set_get(struct gov_attr_set *attr_set, struct list_head *list_node); | ||
| 509 | unsigned int gov_attr_set_put(struct gov_attr_set *attr_set, struct list_head *list_node); | ||
| 510 | |||
| 511 | /* Governor sysfs attribute */ | ||
| 512 | struct governor_attr { | ||
| 513 | struct attribute attr; | ||
| 514 | ssize_t (*show)(struct gov_attr_set *attr_set, char *buf); | ||
| 515 | ssize_t (*store)(struct gov_attr_set *attr_set, const char *buf, | ||
| 516 | size_t count); | ||
| 517 | }; | ||
| 518 | |||
| 465 | /********************************************************************* | 519 | /********************************************************************* |
| 466 | * FREQUENCY TABLE HELPERS * | 520 | * FREQUENCY TABLE HELPERS * |
| 467 | *********************************************************************/ | 521 | *********************************************************************/ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 52c4847b05e2..8344e1947eec 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -3240,7 +3240,10 @@ struct update_util_data { | |||
| 3240 | u64 time, unsigned long util, unsigned long max); | 3240 | u64 time, unsigned long util, unsigned long max); |
| 3241 | }; | 3241 | }; |
| 3242 | 3242 | ||
| 3243 | void cpufreq_set_update_util_data(int cpu, struct update_util_data *data); | 3243 | void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data, |
| 3244 | void (*func)(struct update_util_data *data, u64 time, | ||
| 3245 | unsigned long util, unsigned long max)); | ||
| 3246 | void cpufreq_remove_update_util_hook(int cpu); | ||
| 3244 | #endif /* CONFIG_CPU_FREQ */ | 3247 | #endif /* CONFIG_CPU_FREQ */ |
| 3245 | 3248 | ||
| 3246 | #endif | 3249 | #endif |
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile index 414d9c16da42..5e59b832ae2b 100644 --- a/kernel/sched/Makefile +++ b/kernel/sched/Makefile | |||
| @@ -24,3 +24,4 @@ obj-$(CONFIG_SCHEDSTATS) += stats.o | |||
| 24 | obj-$(CONFIG_SCHED_DEBUG) += debug.o | 24 | obj-$(CONFIG_SCHED_DEBUG) += debug.o |
| 25 | obj-$(CONFIG_CGROUP_CPUACCT) += cpuacct.o | 25 | obj-$(CONFIG_CGROUP_CPUACCT) += cpuacct.o |
| 26 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | 26 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o |
| 27 | obj-$(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) += cpufreq_schedutil.o | ||
diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c index 928c4ba32f68..1141954e73b4 100644 --- a/kernel/sched/cpufreq.c +++ b/kernel/sched/cpufreq.c | |||
| @@ -14,24 +14,50 @@ | |||
| 14 | DEFINE_PER_CPU(struct update_util_data *, cpufreq_update_util_data); | 14 | DEFINE_PER_CPU(struct update_util_data *, cpufreq_update_util_data); |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | * cpufreq_set_update_util_data - Populate the CPU's update_util_data pointer. | 17 | * cpufreq_add_update_util_hook - Populate the CPU's update_util_data pointer. |
| 18 | * @cpu: The CPU to set the pointer for. | 18 | * @cpu: The CPU to set the pointer for. |
| 19 | * @data: New pointer value. | 19 | * @data: New pointer value. |
| 20 | * @func: Callback function to set for the CPU. | ||
| 20 | * | 21 | * |
| 21 | * Set and publish the update_util_data pointer for the given CPU. That pointer | 22 | * Set and publish the update_util_data pointer for the given CPU. |
| 22 | * points to a struct update_util_data object containing a callback function | ||
| 23 | * to call from cpufreq_update_util(). That function will be called from an RCU | ||
| 24 | * read-side critical section, so it must not sleep. | ||
| 25 | * | 23 | * |
| 26 | * Callers must use RCU-sched callbacks to free any memory that might be | 24 | * The update_util_data pointer of @cpu is set to @data and the callback |
| 27 | * accessed via the old update_util_data pointer or invoke synchronize_sched() | 25 | * function pointer in the target struct update_util_data is set to @func. |
| 28 | * right after this function to avoid use-after-free. | 26 | * That function will be called by cpufreq_update_util() from RCU-sched |
| 27 | * read-side critical sections, so it must not sleep. @data will always be | ||
| 28 | * passed to it as the first argument which allows the function to get to the | ||
| 29 | * target update_util_data structure and its container. | ||
| 30 | * | ||
| 31 | * The update_util_data pointer of @cpu must be NULL when this function is | ||
| 32 | * called or it will WARN() and return with no effect. | ||
| 29 | */ | 33 | */ |
| 30 | void cpufreq_set_update_util_data(int cpu, struct update_util_data *data) | 34 | void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data, |
| 35 | void (*func)(struct update_util_data *data, u64 time, | ||
| 36 | unsigned long util, unsigned long max)) | ||
| 31 | { | 37 | { |
| 32 | if (WARN_ON(data && !data->func)) | 38 | if (WARN_ON(!data || !func)) |
| 33 | return; | 39 | return; |
| 34 | 40 | ||
| 41 | if (WARN_ON(per_cpu(cpufreq_update_util_data, cpu))) | ||
| 42 | return; | ||
| 43 | |||
| 44 | data->func = func; | ||
| 35 | rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data); | 45 | rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data); |
| 36 | } | 46 | } |
| 37 | EXPORT_SYMBOL_GPL(cpufreq_set_update_util_data); | 47 | EXPORT_SYMBOL_GPL(cpufreq_add_update_util_hook); |
| 48 | |||
| 49 | /** | ||
| 50 | * cpufreq_remove_update_util_hook - Clear the CPU's update_util_data pointer. | ||
| 51 | * @cpu: The CPU to clear the pointer for. | ||
| 52 | * | ||
| 53 | * Clear the update_util_data pointer for the given CPU. | ||
| 54 | * | ||
| 55 | * Callers must use RCU-sched callbacks to free any memory that might be | ||
| 56 | * accessed via the old update_util_data pointer or invoke synchronize_sched() | ||
| 57 | * right after this function to avoid use-after-free. | ||
| 58 | */ | ||
| 59 | void cpufreq_remove_update_util_hook(int cpu) | ||
| 60 | { | ||
| 61 | rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), NULL); | ||
| 62 | } | ||
| 63 | EXPORT_SYMBOL_GPL(cpufreq_remove_update_util_hook); | ||
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c new file mode 100644 index 000000000000..154ae3a51e86 --- /dev/null +++ b/kernel/sched/cpufreq_schedutil.c | |||
| @@ -0,0 +1,530 @@ | |||
| 1 | /* | ||
| 2 | * CPUFreq governor based on scheduler-provided CPU utilization data. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016, Intel Corporation | ||
| 5 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/cpufreq.h> | ||
| 13 | #include <linux/module.h> | ||
| 14 | #include <linux/slab.h> | ||
| 15 | #include <trace/events/power.h> | ||
| 16 | |||
| 17 | #include "sched.h" | ||
| 18 | |||
| 19 | struct sugov_tunables { | ||
| 20 | struct gov_attr_set attr_set; | ||
| 21 | unsigned int rate_limit_us; | ||
| 22 | }; | ||
| 23 | |||
| 24 | struct sugov_policy { | ||
| 25 | struct cpufreq_policy *policy; | ||
| 26 | |||
| 27 | struct sugov_tunables *tunables; | ||
| 28 | struct list_head tunables_hook; | ||
| 29 | |||
| 30 | raw_spinlock_t update_lock; /* For shared policies */ | ||
| 31 | u64 last_freq_update_time; | ||
| 32 | s64 freq_update_delay_ns; | ||
| 33 | unsigned int next_freq; | ||
| 34 | |||
| 35 | /* The next fields are only needed if fast switch cannot be used. */ | ||
| 36 | struct irq_work irq_work; | ||
| 37 | struct work_struct work; | ||
| 38 | struct mutex work_lock; | ||
| 39 | bool work_in_progress; | ||
| 40 | |||
| 41 | bool need_freq_update; | ||
| 42 | }; | ||
| 43 | |||
| 44 | struct sugov_cpu { | ||
| 45 | struct update_util_data update_util; | ||
| 46 | struct sugov_policy *sg_policy; | ||
| 47 | |||
| 48 | /* The fields below are only needed when sharing a policy. */ | ||
| 49 | unsigned long util; | ||
| 50 | unsigned long max; | ||
| 51 | u64 last_update; | ||
| 52 | }; | ||
| 53 | |||
| 54 | static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu); | ||
| 55 | |||
| 56 | /************************ Governor internals ***********************/ | ||
| 57 | |||
| 58 | static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) | ||
| 59 | { | ||
| 60 | s64 delta_ns; | ||
| 61 | |||
| 62 | if (sg_policy->work_in_progress) | ||
| 63 | return false; | ||
| 64 | |||
| 65 | if (unlikely(sg_policy->need_freq_update)) { | ||
| 66 | sg_policy->need_freq_update = false; | ||
| 67 | /* | ||
| 68 | * This happens when limits change, so forget the previous | ||
| 69 | * next_freq value and force an update. | ||
| 70 | */ | ||
| 71 | sg_policy->next_freq = UINT_MAX; | ||
| 72 | return true; | ||
| 73 | } | ||
| 74 | |||
| 75 | delta_ns = time - sg_policy->last_freq_update_time; | ||
| 76 | return delta_ns >= sg_policy->freq_update_delay_ns; | ||
| 77 | } | ||
| 78 | |||
| 79 | static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, | ||
| 80 | unsigned int next_freq) | ||
| 81 | { | ||
| 82 | struct cpufreq_policy *policy = sg_policy->policy; | ||
| 83 | |||
| 84 | sg_policy->last_freq_update_time = time; | ||
| 85 | |||
| 86 | if (policy->fast_switch_enabled) { | ||
| 87 | if (sg_policy->next_freq == next_freq) { | ||
| 88 | trace_cpu_frequency(policy->cur, smp_processor_id()); | ||
| 89 | return; | ||
| 90 | } | ||
| 91 | sg_policy->next_freq = next_freq; | ||
| 92 | next_freq = cpufreq_driver_fast_switch(policy, next_freq); | ||
| 93 | if (next_freq == CPUFREQ_ENTRY_INVALID) | ||
| 94 | return; | ||
| 95 | |||
| 96 | policy->cur = next_freq; | ||
| 97 | trace_cpu_frequency(next_freq, smp_processor_id()); | ||
| 98 | } else if (sg_policy->next_freq != next_freq) { | ||
| 99 | sg_policy->next_freq = next_freq; | ||
| 100 | sg_policy->work_in_progress = true; | ||
| 101 | irq_work_queue(&sg_policy->irq_work); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | /** | ||
| 106 | * get_next_freq - Compute a new frequency for a given cpufreq policy. | ||
| 107 | * @policy: cpufreq policy object to compute the new frequency for. | ||
| 108 | * @util: Current CPU utilization. | ||
| 109 | * @max: CPU capacity. | ||
| 110 | * | ||
| 111 | * If the utilization is frequency-invariant, choose the new frequency to be | ||
| 112 | * proportional to it, that is | ||
| 113 | * | ||
| 114 | * next_freq = C * max_freq * util / max | ||
| 115 | * | ||
| 116 | * Otherwise, approximate the would-be frequency-invariant utilization by | ||
| 117 | * util_raw * (curr_freq / max_freq) which leads to | ||
| 118 | * | ||
| 119 | * next_freq = C * curr_freq * util_raw / max | ||
| 120 | * | ||
| 121 | * Take C = 1.25 for the frequency tipping point at (util / max) = 0.8. | ||
| 122 | */ | ||
| 123 | static unsigned int get_next_freq(struct cpufreq_policy *policy, | ||
| 124 | unsigned long util, unsigned long max) | ||
| 125 | { | ||
| 126 | unsigned int freq = arch_scale_freq_invariant() ? | ||
| 127 | policy->cpuinfo.max_freq : policy->cur; | ||
| 128 | |||
| 129 | return (freq + (freq >> 2)) * util / max; | ||
| 130 | } | ||
| 131 | |||
| 132 | static void sugov_update_single(struct update_util_data *hook, u64 time, | ||
| 133 | unsigned long util, unsigned long max) | ||
| 134 | { | ||
| 135 | struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util); | ||
| 136 | struct sugov_policy *sg_policy = sg_cpu->sg_policy; | ||
| 137 | struct cpufreq_policy *policy = sg_policy->policy; | ||
| 138 | unsigned int next_f; | ||
| 139 | |||
| 140 | if (!sugov_should_update_freq(sg_policy, time)) | ||
| 141 | return; | ||
| 142 | |||
| 143 | next_f = util == ULONG_MAX ? policy->cpuinfo.max_freq : | ||
| 144 | get_next_freq(policy, util, max); | ||
| 145 | sugov_update_commit(sg_policy, time, next_f); | ||
| 146 | } | ||
| 147 | |||
| 148 | static unsigned int sugov_next_freq_shared(struct sugov_policy *sg_policy, | ||
| 149 | unsigned long util, unsigned long max) | ||
| 150 | { | ||
| 151 | struct cpufreq_policy *policy = sg_policy->policy; | ||
| 152 | unsigned int max_f = policy->cpuinfo.max_freq; | ||
| 153 | u64 last_freq_update_time = sg_policy->last_freq_update_time; | ||
| 154 | unsigned int j; | ||
| 155 | |||
| 156 | if (util == ULONG_MAX) | ||
| 157 | return max_f; | ||
| 158 | |||
| 159 | for_each_cpu(j, policy->cpus) { | ||
| 160 | struct sugov_cpu *j_sg_cpu; | ||
| 161 | unsigned long j_util, j_max; | ||
| 162 | s64 delta_ns; | ||
| 163 | |||
| 164 | if (j == smp_processor_id()) | ||
| 165 | continue; | ||
| 166 | |||
| 167 | j_sg_cpu = &per_cpu(sugov_cpu, j); | ||
| 168 | /* | ||
| 169 | * If the CPU utilization was last updated before the previous | ||
| 170 | * frequency update and the time elapsed between the last update | ||
| 171 | * of the CPU utilization and the last frequency update is long | ||
| 172 | * enough, don't take the CPU into account as it probably is | ||
| 173 | * idle now. | ||
| 174 | */ | ||
| 175 | delta_ns = last_freq_update_time - j_sg_cpu->last_update; | ||
| 176 | if (delta_ns > TICK_NSEC) | ||
| 177 | continue; | ||
| 178 | |||
| 179 | j_util = j_sg_cpu->util; | ||
| 180 | if (j_util == ULONG_MAX) | ||
| 181 | return max_f; | ||
| 182 | |||
| 183 | j_max = j_sg_cpu->max; | ||
| 184 | if (j_util * max > j_max * util) { | ||
| 185 | util = j_util; | ||
| 186 | max = j_max; | ||
| 187 | } | ||
| 188 | } | ||
| 189 | |||
| 190 | return get_next_freq(policy, util, max); | ||
| 191 | } | ||
| 192 | |||
| 193 | static void sugov_update_shared(struct update_util_data *hook, u64 time, | ||
| 194 | unsigned long util, unsigned long max) | ||
| 195 | { | ||
| 196 | struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util); | ||
| 197 | struct sugov_policy *sg_policy = sg_cpu->sg_policy; | ||
| 198 | unsigned int next_f; | ||
| 199 | |||
| 200 | raw_spin_lock(&sg_policy->update_lock); | ||
| 201 | |||
| 202 | sg_cpu->util = util; | ||
| 203 | sg_cpu->max = max; | ||
| 204 | sg_cpu->last_update = time; | ||
| 205 | |||
| 206 | if (sugov_should_update_freq(sg_policy, time)) { | ||
| 207 | next_f = sugov_next_freq_shared(sg_policy, util, max); | ||
| 208 | sugov_update_commit(sg_policy, time, next_f); | ||
| 209 | } | ||
| 210 | |||
| 211 | raw_spin_unlock(&sg_policy->update_lock); | ||
| 212 | } | ||
| 213 | |||
| 214 | static void sugov_work(struct work_struct *work) | ||
| 215 | { | ||
| 216 | struct sugov_policy *sg_policy = container_of(work, struct sugov_policy, work); | ||
| 217 | |||
| 218 | mutex_lock(&sg_policy->work_lock); | ||
| 219 | __cpufreq_driver_target(sg_policy->policy, sg_policy->next_freq, | ||
| 220 | CPUFREQ_RELATION_L); | ||
| 221 | mutex_unlock(&sg_policy->work_lock); | ||
| 222 | |||
| 223 | sg_policy->work_in_progress = false; | ||
| 224 | } | ||
| 225 | |||
| 226 | static void sugov_irq_work(struct irq_work *irq_work) | ||
| 227 | { | ||
| 228 | struct sugov_policy *sg_policy; | ||
| 229 | |||
| 230 | sg_policy = container_of(irq_work, struct sugov_policy, irq_work); | ||
| 231 | schedule_work_on(smp_processor_id(), &sg_policy->work); | ||
| 232 | } | ||
| 233 | |||
| 234 | /************************** sysfs interface ************************/ | ||
| 235 | |||
| 236 | static struct sugov_tunables *global_tunables; | ||
| 237 | static DEFINE_MUTEX(global_tunables_lock); | ||
| 238 | |||
| 239 | static inline struct sugov_tunables *to_sugov_tunables(struct gov_attr_set *attr_set) | ||
| 240 | { | ||
| 241 | return container_of(attr_set, struct sugov_tunables, attr_set); | ||
| 242 | } | ||
| 243 | |||
| 244 | static ssize_t rate_limit_us_show(struct gov_attr_set *attr_set, char *buf) | ||
| 245 | { | ||
| 246 | struct sugov_tunables *tunables = to_sugov_tunables(attr_set); | ||
| 247 | |||
| 248 | return sprintf(buf, "%u\n", tunables->rate_limit_us); | ||
| 249 | } | ||
| 250 | |||
| 251 | static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, | ||
| 252 | size_t count) | ||
| 253 | { | ||
| 254 | struct sugov_tunables *tunables = to_sugov_tunables(attr_set); | ||
| 255 | struct sugov_policy *sg_policy; | ||
| 256 | unsigned int rate_limit_us; | ||
| 257 | |||
| 258 | if (kstrtouint(buf, 10, &rate_limit_us)) | ||
| 259 | return -EINVAL; | ||
| 260 | |||
| 261 | tunables->rate_limit_us = rate_limit_us; | ||
| 262 | |||
| 263 | list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook) | ||
| 264 | sg_policy->freq_update_delay_ns = rate_limit_us * NSEC_PER_USEC; | ||
| 265 | |||
| 266 | return count; | ||
| 267 | } | ||
| 268 | |||
| 269 | static struct governor_attr rate_limit_us = __ATTR_RW(rate_limit_us); | ||
| 270 | |||
| 271 | static struct attribute *sugov_attributes[] = { | ||
| 272 | &rate_limit_us.attr, | ||
| 273 | NULL | ||
| 274 | }; | ||
| 275 | |||
| 276 | static struct kobj_type sugov_tunables_ktype = { | ||
| 277 | .default_attrs = sugov_attributes, | ||
| 278 | .sysfs_ops = &governor_sysfs_ops, | ||
| 279 | }; | ||
| 280 | |||
| 281 | /********************** cpufreq governor interface *********************/ | ||
| 282 | |||
| 283 | static struct cpufreq_governor schedutil_gov; | ||
| 284 | |||
| 285 | static struct sugov_policy *sugov_policy_alloc(struct cpufreq_policy *policy) | ||
| 286 | { | ||
| 287 | struct sugov_policy *sg_policy; | ||
| 288 | |||
| 289 | sg_policy = kzalloc(sizeof(*sg_policy), GFP_KERNEL); | ||
| 290 | if (!sg_policy) | ||
| 291 | return NULL; | ||
| 292 | |||
| 293 | sg_policy->policy = policy; | ||
| 294 | init_irq_work(&sg_policy->irq_work, sugov_irq_work); | ||
| 295 | INIT_WORK(&sg_policy->work, sugov_work); | ||
| 296 | mutex_init(&sg_policy->work_lock); | ||
| 297 | raw_spin_lock_init(&sg_policy->update_lock); | ||
| 298 | return sg_policy; | ||
| 299 | } | ||
| 300 | |||
| 301 | static void sugov_policy_free(struct sugov_policy *sg_policy) | ||
| 302 | { | ||
| 303 | mutex_destroy(&sg_policy->work_lock); | ||
| 304 | kfree(sg_policy); | ||
| 305 | } | ||
| 306 | |||
| 307 | static struct sugov_tunables *sugov_tunables_alloc(struct sugov_policy *sg_policy) | ||
| 308 | { | ||
| 309 | struct sugov_tunables *tunables; | ||
| 310 | |||
| 311 | tunables = kzalloc(sizeof(*tunables), GFP_KERNEL); | ||
| 312 | if (tunables) { | ||
| 313 | gov_attr_set_init(&tunables->attr_set, &sg_policy->tunables_hook); | ||
| 314 | if (!have_governor_per_policy()) | ||
| 315 | global_tunables = tunables; | ||
| 316 | } | ||
| 317 | return tunables; | ||
| 318 | } | ||
| 319 | |||
| 320 | static void sugov_tunables_free(struct sugov_tunables *tunables) | ||
| 321 | { | ||
| 322 | if (!have_governor_per_policy()) | ||
| 323 | global_tunables = NULL; | ||
| 324 | |||
| 325 | kfree(tunables); | ||
| 326 | } | ||
| 327 | |||
| 328 | static int sugov_init(struct cpufreq_policy *policy) | ||
| 329 | { | ||
| 330 | struct sugov_policy *sg_policy; | ||
| 331 | struct sugov_tunables *tunables; | ||
| 332 | unsigned int lat; | ||
| 333 | int ret = 0; | ||
| 334 | |||
| 335 | /* State should be equivalent to EXIT */ | ||
| 336 | if (policy->governor_data) | ||
| 337 | return -EBUSY; | ||
| 338 | |||
| 339 | sg_policy = sugov_policy_alloc(policy); | ||
| 340 | if (!sg_policy) | ||
| 341 | return -ENOMEM; | ||
| 342 | |||
| 343 | mutex_lock(&global_tunables_lock); | ||
| 344 | |||
| 345 | if (global_tunables) { | ||
| 346 | if (WARN_ON(have_governor_per_policy())) { | ||
| 347 | ret = -EINVAL; | ||
| 348 | goto free_sg_policy; | ||
| 349 | } | ||
| 350 | policy->governor_data = sg_policy; | ||
| 351 | sg_policy->tunables = global_tunables; | ||
| 352 | |||
| 353 | gov_attr_set_get(&global_tunables->attr_set, &sg_policy->tunables_hook); | ||
| 354 | goto out; | ||
| 355 | } | ||
| 356 | |||
| 357 | tunables = sugov_tunables_alloc(sg_policy); | ||
| 358 | if (!tunables) { | ||
| 359 | ret = -ENOMEM; | ||
| 360 | goto free_sg_policy; | ||
| 361 | } | ||
| 362 | |||
| 363 | tunables->rate_limit_us = LATENCY_MULTIPLIER; | ||
| 364 | lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC; | ||
| 365 | if (lat) | ||
| 366 | tunables->rate_limit_us *= lat; | ||
| 367 | |||
| 368 | policy->governor_data = sg_policy; | ||
| 369 | sg_policy->tunables = tunables; | ||
| 370 | |||
| 371 | ret = kobject_init_and_add(&tunables->attr_set.kobj, &sugov_tunables_ktype, | ||
| 372 | get_governor_parent_kobj(policy), "%s", | ||
| 373 | schedutil_gov.name); | ||
| 374 | if (ret) | ||
| 375 | goto fail; | ||
| 376 | |||
| 377 | out: | ||
| 378 | mutex_unlock(&global_tunables_lock); | ||
| 379 | |||
| 380 | cpufreq_enable_fast_switch(policy); | ||
| 381 | return 0; | ||
| 382 | |||
| 383 | fail: | ||
| 384 | policy->governor_data = NULL; | ||
| 385 | sugov_tunables_free(tunables); | ||
| 386 | |||
| 387 | free_sg_policy: | ||
| 388 | mutex_unlock(&global_tunables_lock); | ||
| 389 | |||
| 390 | sugov_policy_free(sg_policy); | ||
| 391 | pr_err("cpufreq: schedutil governor initialization failed (error %d)\n", ret); | ||
| 392 | return ret; | ||
| 393 | } | ||
| 394 | |||
| 395 | static int sugov_exit(struct cpufreq_policy *policy) | ||
| 396 | { | ||
| 397 | struct sugov_policy *sg_policy = policy->governor_data; | ||
| 398 | struct sugov_tunables *tunables = sg_policy->tunables; | ||
| 399 | unsigned int count; | ||
| 400 | |||
| 401 | cpufreq_disable_fast_switch(policy); | ||
| 402 | |||
| 403 | mutex_lock(&global_tunables_lock); | ||
| 404 | |||
| 405 | count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook); | ||
| 406 | policy->governor_data = NULL; | ||
| 407 | if (!count) | ||
| 408 | sugov_tunables_free(tunables); | ||
| 409 | |||
| 410 | mutex_unlock(&global_tunables_lock); | ||
| 411 | |||
| 412 | sugov_policy_free(sg_policy); | ||
| 413 | return 0; | ||
| 414 | } | ||
| 415 | |||
| 416 | static int sugov_start(struct cpufreq_policy *policy) | ||
| 417 | { | ||
| 418 | struct sugov_policy *sg_policy = policy->governor_data; | ||
| 419 | unsigned int cpu; | ||
| 420 | |||
| 421 | sg_policy->freq_update_delay_ns = sg_policy->tunables->rate_limit_us * NSEC_PER_USEC; | ||
| 422 | sg_policy->last_freq_update_time = 0; | ||
| 423 | sg_policy->next_freq = UINT_MAX; | ||
| 424 | sg_policy->work_in_progress = false; | ||
| 425 | sg_policy->need_freq_update = false; | ||
| 426 | |||
| 427 | for_each_cpu(cpu, policy->cpus) { | ||
| 428 | struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu); | ||
| 429 | |||
| 430 | sg_cpu->sg_policy = sg_policy; | ||
| 431 | if (policy_is_shared(policy)) { | ||
| 432 | sg_cpu->util = ULONG_MAX; | ||
| 433 | sg_cpu->max = 0; | ||
| 434 | sg_cpu->last_update = 0; | ||
| 435 | cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, | ||
| 436 | sugov_update_shared); | ||
| 437 | } else { | ||
| 438 | cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, | ||
| 439 | sugov_update_single); | ||
| 440 | } | ||
| 441 | } | ||
| 442 | return 0; | ||
| 443 | } | ||
| 444 | |||
| 445 | static int sugov_stop(struct cpufreq_policy *policy) | ||
| 446 | { | ||
| 447 | struct sugov_policy *sg_policy = policy->governor_data; | ||
| 448 | unsigned int cpu; | ||
| 449 | |||
| 450 | for_each_cpu(cpu, policy->cpus) | ||
| 451 | cpufreq_remove_update_util_hook(cpu); | ||
| 452 | |||
| 453 | synchronize_sched(); | ||
| 454 | |||
| 455 | irq_work_sync(&sg_policy->irq_work); | ||
| 456 | cancel_work_sync(&sg_policy->work); | ||
| 457 | return 0; | ||
| 458 | } | ||
| 459 | |||
| 460 | static int sugov_limits(struct cpufreq_policy *policy) | ||
| 461 | { | ||
| 462 | struct sugov_policy *sg_policy = policy->governor_data; | ||
| 463 | |||
| 464 | if (!policy->fast_switch_enabled) { | ||
| 465 | mutex_lock(&sg_policy->work_lock); | ||
| 466 | |||
| 467 | if (policy->max < policy->cur) | ||
| 468 | __cpufreq_driver_target(policy, policy->max, | ||
| 469 | CPUFREQ_RELATION_H); | ||
| 470 | else if (policy->min > policy->cur) | ||
| 471 | __cpufreq_driver_target(policy, policy->min, | ||
| 472 | CPUFREQ_RELATION_L); | ||
| 473 | |||
| 474 | mutex_unlock(&sg_policy->work_lock); | ||
| 475 | } | ||
| 476 | |||
| 477 | sg_policy->need_freq_update = true; | ||
| 478 | return 0; | ||
| 479 | } | ||
| 480 | |||
| 481 | int sugov_governor(struct cpufreq_policy *policy, unsigned int event) | ||
| 482 | { | ||
| 483 | if (event == CPUFREQ_GOV_POLICY_INIT) { | ||
| 484 | return sugov_init(policy); | ||
| 485 | } else if (policy->governor_data) { | ||
| 486 | switch (event) { | ||
| 487 | case CPUFREQ_GOV_POLICY_EXIT: | ||
| 488 | return sugov_exit(policy); | ||
| 489 | case CPUFREQ_GOV_START: | ||
| 490 | return sugov_start(policy); | ||
| 491 | case CPUFREQ_GOV_STOP: | ||
| 492 | return sugov_stop(policy); | ||
| 493 | case CPUFREQ_GOV_LIMITS: | ||
| 494 | return sugov_limits(policy); | ||
| 495 | } | ||
| 496 | } | ||
| 497 | return -EINVAL; | ||
| 498 | } | ||
| 499 | |||
| 500 | static struct cpufreq_governor schedutil_gov = { | ||
| 501 | .name = "schedutil", | ||
| 502 | .governor = sugov_governor, | ||
| 503 | .owner = THIS_MODULE, | ||
| 504 | }; | ||
| 505 | |||
| 506 | static int __init sugov_module_init(void) | ||
| 507 | { | ||
| 508 | return cpufreq_register_governor(&schedutil_gov); | ||
| 509 | } | ||
| 510 | |||
| 511 | static void __exit sugov_module_exit(void) | ||
| 512 | { | ||
| 513 | cpufreq_unregister_governor(&schedutil_gov); | ||
| 514 | } | ||
| 515 | |||
| 516 | MODULE_AUTHOR("Rafael J. Wysocki <rafael.j.wysocki@intel.com>"); | ||
| 517 | MODULE_DESCRIPTION("Utilization-based CPU frequency selection"); | ||
| 518 | MODULE_LICENSE("GPL"); | ||
| 519 | |||
| 520 | #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL | ||
| 521 | struct cpufreq_governor *cpufreq_default_governor(void) | ||
| 522 | { | ||
| 523 | return &schedutil_gov; | ||
| 524 | } | ||
| 525 | |||
| 526 | fs_initcall(sugov_module_init); | ||
| 527 | #else | ||
| 528 | module_init(sugov_module_init); | ||
| 529 | #endif | ||
| 530 | module_exit(sugov_module_exit); | ||
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index ec2e8d23527e..921d6e5d33b7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
| @@ -1842,6 +1842,14 @@ static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned lo | |||
| 1842 | static inline void cpufreq_trigger_update(u64 time) {} | 1842 | static inline void cpufreq_trigger_update(u64 time) {} |
| 1843 | #endif /* CONFIG_CPU_FREQ */ | 1843 | #endif /* CONFIG_CPU_FREQ */ |
| 1844 | 1844 | ||
| 1845 | #ifdef arch_scale_freq_capacity | ||
| 1846 | #ifndef arch_scale_freq_invariant | ||
| 1847 | #define arch_scale_freq_invariant() (true) | ||
| 1848 | #endif | ||
| 1849 | #else /* arch_scale_freq_capacity */ | ||
| 1850 | #define arch_scale_freq_invariant() (false) | ||
| 1851 | #endif | ||
| 1852 | |||
| 1845 | static inline void account_reset_rq(struct rq *rq) | 1853 | static inline void account_reset_rq(struct rq *rq) |
| 1846 | { | 1854 | { |
| 1847 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | 1855 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING |
diff --git a/kernel/trace/power-traces.c b/kernel/trace/power-traces.c index 81b87451c0ea..0c7dee221dca 100644 --- a/kernel/trace/power-traces.c +++ b/kernel/trace/power-traces.c | |||
| @@ -15,5 +15,6 @@ | |||
| 15 | 15 | ||
| 16 | EXPORT_TRACEPOINT_SYMBOL_GPL(suspend_resume); | 16 | EXPORT_TRACEPOINT_SYMBOL_GPL(suspend_resume); |
| 17 | EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle); | 17 | EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle); |
| 18 | EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_frequency); | ||
| 18 | EXPORT_TRACEPOINT_SYMBOL_GPL(powernv_throttle); | 19 | EXPORT_TRACEPOINT_SYMBOL_GPL(powernv_throttle); |
| 19 | 20 | ||
