diff options
| -rw-r--r-- | drivers/cpufreq/intel_pstate.c | 154 |
1 files changed, 67 insertions, 87 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 59312dc4c401..f8496faa1085 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -328,14 +328,6 @@ struct pstate_funcs { | |||
| 328 | unsigned int flags); | 328 | unsigned int flags); |
| 329 | }; | 329 | }; |
| 330 | 330 | ||
| 331 | /** | ||
| 332 | * struct cpu_defaults- Per CPU model default config data | ||
| 333 | * @funcs: Callback function data | ||
| 334 | */ | ||
| 335 | struct cpu_defaults { | ||
| 336 | struct pstate_funcs funcs; | ||
| 337 | }; | ||
| 338 | |||
| 339 | static struct pstate_funcs pstate_funcs __read_mostly; | 331 | static struct pstate_funcs pstate_funcs __read_mostly; |
| 340 | static struct pstate_adjust_policy pid_params __read_mostly = { | 332 | static struct pstate_adjust_policy pid_params __read_mostly = { |
| 341 | .sample_rate_ms = 10, | 333 | .sample_rate_ms = 10, |
| @@ -1809,66 +1801,56 @@ static void intel_pstate_update_util(struct update_util_data *data, u64 time, | |||
| 1809 | } | 1801 | } |
| 1810 | } | 1802 | } |
| 1811 | 1803 | ||
| 1812 | static struct cpu_defaults core_params = { | 1804 | static struct pstate_funcs core_funcs = { |
| 1813 | .funcs = { | 1805 | .get_max = core_get_max_pstate, |
| 1814 | .get_max = core_get_max_pstate, | 1806 | .get_max_physical = core_get_max_pstate_physical, |
| 1815 | .get_max_physical = core_get_max_pstate_physical, | 1807 | .get_min = core_get_min_pstate, |
| 1816 | .get_min = core_get_min_pstate, | 1808 | .get_turbo = core_get_turbo_pstate, |
| 1817 | .get_turbo = core_get_turbo_pstate, | 1809 | .get_scaling = core_get_scaling, |
| 1818 | .get_scaling = core_get_scaling, | 1810 | .get_val = core_get_val, |
| 1819 | .get_val = core_get_val, | 1811 | .update_util = intel_pstate_update_util_pid, |
| 1820 | .update_util = intel_pstate_update_util_pid, | ||
| 1821 | }, | ||
| 1822 | }; | 1812 | }; |
| 1823 | 1813 | ||
| 1824 | static const struct cpu_defaults silvermont_params = { | 1814 | static const struct pstate_funcs silvermont_funcs = { |
| 1825 | .funcs = { | 1815 | .get_max = atom_get_max_pstate, |
| 1826 | .get_max = atom_get_max_pstate, | 1816 | .get_max_physical = atom_get_max_pstate, |
| 1827 | .get_max_physical = atom_get_max_pstate, | 1817 | .get_min = atom_get_min_pstate, |
| 1828 | .get_min = atom_get_min_pstate, | 1818 | .get_turbo = atom_get_turbo_pstate, |
| 1829 | .get_turbo = atom_get_turbo_pstate, | 1819 | .get_val = atom_get_val, |
| 1830 | .get_val = atom_get_val, | 1820 | .get_scaling = silvermont_get_scaling, |
| 1831 | .get_scaling = silvermont_get_scaling, | 1821 | .get_vid = atom_get_vid, |
| 1832 | .get_vid = atom_get_vid, | 1822 | .update_util = intel_pstate_update_util, |
| 1833 | .update_util = intel_pstate_update_util, | ||
| 1834 | }, | ||
| 1835 | }; | 1823 | }; |
| 1836 | 1824 | ||
| 1837 | static const struct cpu_defaults airmont_params = { | 1825 | static const struct pstate_funcs airmont_funcs = { |
| 1838 | .funcs = { | 1826 | .get_max = atom_get_max_pstate, |
| 1839 | .get_max = atom_get_max_pstate, | 1827 | .get_max_physical = atom_get_max_pstate, |
| 1840 | .get_max_physical = atom_get_max_pstate, | 1828 | .get_min = atom_get_min_pstate, |
| 1841 | .get_min = atom_get_min_pstate, | 1829 | .get_turbo = atom_get_turbo_pstate, |
| 1842 | .get_turbo = atom_get_turbo_pstate, | 1830 | .get_val = atom_get_val, |
| 1843 | .get_val = atom_get_val, | 1831 | .get_scaling = airmont_get_scaling, |
| 1844 | .get_scaling = airmont_get_scaling, | 1832 | .get_vid = atom_get_vid, |
| 1845 | .get_vid = atom_get_vid, | 1833 | .update_util = intel_pstate_update_util, |
| 1846 | .update_util = intel_pstate_update_util, | ||
| 1847 | }, | ||
| 1848 | }; | 1834 | }; |
| 1849 | 1835 | ||
| 1850 | static const struct cpu_defaults knl_params = { | 1836 | static const struct pstate_funcs knl_funcs = { |
| 1851 | .funcs = { | 1837 | .get_max = core_get_max_pstate, |
| 1852 | .get_max = core_get_max_pstate, | 1838 | .get_max_physical = core_get_max_pstate_physical, |
| 1853 | .get_max_physical = core_get_max_pstate_physical, | 1839 | .get_min = core_get_min_pstate, |
| 1854 | .get_min = core_get_min_pstate, | 1840 | .get_turbo = knl_get_turbo_pstate, |
| 1855 | .get_turbo = knl_get_turbo_pstate, | 1841 | .get_scaling = core_get_scaling, |
| 1856 | .get_scaling = core_get_scaling, | 1842 | .get_val = core_get_val, |
| 1857 | .get_val = core_get_val, | 1843 | .update_util = intel_pstate_update_util_pid, |
| 1858 | .update_util = intel_pstate_update_util_pid, | ||
| 1859 | }, | ||
| 1860 | }; | 1844 | }; |
| 1861 | 1845 | ||
| 1862 | static const struct cpu_defaults bxt_params = { | 1846 | static const struct pstate_funcs bxt_funcs = { |
| 1863 | .funcs = { | 1847 | .get_max = core_get_max_pstate, |
| 1864 | .get_max = core_get_max_pstate, | 1848 | .get_max_physical = core_get_max_pstate_physical, |
| 1865 | .get_max_physical = core_get_max_pstate_physical, | 1849 | .get_min = core_get_min_pstate, |
| 1866 | .get_min = core_get_min_pstate, | 1850 | .get_turbo = core_get_turbo_pstate, |
| 1867 | .get_turbo = core_get_turbo_pstate, | 1851 | .get_scaling = core_get_scaling, |
| 1868 | .get_scaling = core_get_scaling, | 1852 | .get_val = core_get_val, |
| 1869 | .get_val = core_get_val, | 1853 | .update_util = intel_pstate_update_util, |
| 1870 | .update_util = intel_pstate_update_util, | ||
| 1871 | }, | ||
| 1872 | }; | 1854 | }; |
| 1873 | 1855 | ||
| 1874 | #define ICPU(model, policy) \ | 1856 | #define ICPU(model, policy) \ |
| @@ -1876,38 +1858,38 @@ static const struct cpu_defaults bxt_params = { | |||
| 1876 | (unsigned long)&policy } | 1858 | (unsigned long)&policy } |
| 1877 | 1859 | ||
| 1878 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { | 1860 | static const struct x86_cpu_id intel_pstate_cpu_ids[] = { |
| 1879 | ICPU(INTEL_FAM6_SANDYBRIDGE, core_params), | 1861 | ICPU(INTEL_FAM6_SANDYBRIDGE, core_funcs), |
| 1880 | ICPU(INTEL_FAM6_SANDYBRIDGE_X, core_params), | 1862 | ICPU(INTEL_FAM6_SANDYBRIDGE_X, core_funcs), |
| 1881 | ICPU(INTEL_FAM6_ATOM_SILVERMONT1, silvermont_params), | 1863 | ICPU(INTEL_FAM6_ATOM_SILVERMONT1, silvermont_funcs), |
| 1882 | ICPU(INTEL_FAM6_IVYBRIDGE, core_params), | 1864 | ICPU(INTEL_FAM6_IVYBRIDGE, core_funcs), |
| 1883 | ICPU(INTEL_FAM6_HASWELL_CORE, core_params), | 1865 | ICPU(INTEL_FAM6_HASWELL_CORE, core_funcs), |
| 1884 | ICPU(INTEL_FAM6_BROADWELL_CORE, core_params), | 1866 | ICPU(INTEL_FAM6_BROADWELL_CORE, core_funcs), |
| 1885 | ICPU(INTEL_FAM6_IVYBRIDGE_X, core_params), | 1867 | ICPU(INTEL_FAM6_IVYBRIDGE_X, core_funcs), |
| 1886 | ICPU(INTEL_FAM6_HASWELL_X, core_params), | 1868 | ICPU(INTEL_FAM6_HASWELL_X, core_funcs), |
| 1887 | ICPU(INTEL_FAM6_HASWELL_ULT, core_params), | 1869 | ICPU(INTEL_FAM6_HASWELL_ULT, core_funcs), |
| 1888 | ICPU(INTEL_FAM6_HASWELL_GT3E, core_params), | 1870 | ICPU(INTEL_FAM6_HASWELL_GT3E, core_funcs), |
| 1889 | ICPU(INTEL_FAM6_BROADWELL_GT3E, core_params), | 1871 | ICPU(INTEL_FAM6_BROADWELL_GT3E, core_funcs), |
| 1890 | ICPU(INTEL_FAM6_ATOM_AIRMONT, airmont_params), | 1872 | ICPU(INTEL_FAM6_ATOM_AIRMONT, airmont_funcs), |
| 1891 | ICPU(INTEL_FAM6_SKYLAKE_MOBILE, core_params), | 1873 | ICPU(INTEL_FAM6_SKYLAKE_MOBILE, core_funcs), |
| 1892 | ICPU(INTEL_FAM6_BROADWELL_X, core_params), | 1874 | ICPU(INTEL_FAM6_BROADWELL_X, core_funcs), |
| 1893 | ICPU(INTEL_FAM6_SKYLAKE_DESKTOP, core_params), | 1875 | ICPU(INTEL_FAM6_SKYLAKE_DESKTOP, core_funcs), |
| 1894 | ICPU(INTEL_FAM6_BROADWELL_XEON_D, core_params), | 1876 | ICPU(INTEL_FAM6_BROADWELL_XEON_D, core_funcs), |
| 1895 | ICPU(INTEL_FAM6_XEON_PHI_KNL, knl_params), | 1877 | ICPU(INTEL_FAM6_XEON_PHI_KNL, knl_funcs), |
| 1896 | ICPU(INTEL_FAM6_XEON_PHI_KNM, knl_params), | 1878 | ICPU(INTEL_FAM6_XEON_PHI_KNM, knl_funcs), |
| 1897 | ICPU(INTEL_FAM6_ATOM_GOLDMONT, bxt_params), | 1879 | ICPU(INTEL_FAM6_ATOM_GOLDMONT, bxt_funcs), |
| 1898 | {} | 1880 | {} |
| 1899 | }; | 1881 | }; |
| 1900 | MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); | 1882 | MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); |
| 1901 | 1883 | ||
| 1902 | static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = { | 1884 | static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = { |
| 1903 | ICPU(INTEL_FAM6_BROADWELL_XEON_D, core_params), | 1885 | ICPU(INTEL_FAM6_BROADWELL_XEON_D, core_funcs), |
| 1904 | ICPU(INTEL_FAM6_BROADWELL_X, core_params), | 1886 | ICPU(INTEL_FAM6_BROADWELL_X, core_funcs), |
| 1905 | ICPU(INTEL_FAM6_SKYLAKE_X, core_params), | 1887 | ICPU(INTEL_FAM6_SKYLAKE_X, core_funcs), |
| 1906 | {} | 1888 | {} |
| 1907 | }; | 1889 | }; |
| 1908 | 1890 | ||
| 1909 | static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = { | 1891 | static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = { |
| 1910 | ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, core_params), | 1892 | ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, core_funcs), |
| 1911 | {} | 1893 | {} |
| 1912 | }; | 1894 | }; |
| 1913 | 1895 | ||
| @@ -2576,7 +2558,7 @@ static int __init intel_pstate_init(void) | |||
| 2576 | return -ENODEV; | 2558 | return -ENODEV; |
| 2577 | 2559 | ||
| 2578 | if (x86_match_cpu(hwp_support_ids)) { | 2560 | if (x86_match_cpu(hwp_support_ids)) { |
| 2579 | copy_cpu_funcs(&core_params.funcs); | 2561 | copy_cpu_funcs(&core_funcs); |
| 2580 | if (no_hwp) { | 2562 | if (no_hwp) { |
| 2581 | pstate_funcs.update_util = intel_pstate_update_util; | 2563 | pstate_funcs.update_util = intel_pstate_update_util; |
| 2582 | } else { | 2564 | } else { |
| @@ -2587,14 +2569,12 @@ static int __init intel_pstate_init(void) | |||
| 2587 | } | 2569 | } |
| 2588 | } else { | 2570 | } else { |
| 2589 | const struct x86_cpu_id *id; | 2571 | const struct x86_cpu_id *id; |
| 2590 | struct cpu_defaults *cpu_def; | ||
| 2591 | 2572 | ||
| 2592 | id = x86_match_cpu(intel_pstate_cpu_ids); | 2573 | id = x86_match_cpu(intel_pstate_cpu_ids); |
| 2593 | if (!id) | 2574 | if (!id) |
| 2594 | return -ENODEV; | 2575 | return -ENODEV; |
| 2595 | 2576 | ||
| 2596 | cpu_def = (struct cpu_defaults *)id->driver_data; | 2577 | copy_cpu_funcs((struct pstate_funcs *)id->driver_data); |
| 2597 | copy_cpu_funcs(&cpu_def->funcs); | ||
| 2598 | } | 2578 | } |
| 2599 | 2579 | ||
| 2600 | if (intel_pstate_msrs_not_valid()) | 2580 | if (intel_pstate_msrs_not_valid()) |
