From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omzsmtpe01.verizonbusiness.com ([199.249.25.210]:5235 "EHLO omzsmtpe01.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754288AbdDDTek (ORCPT ); Tue, 4 Apr 2017 15:34:40 -0400 From: alexander.levin@verizon.com To: "gregkh@linuxfoundation.org" CC: "stable@vger.kernel.org" Subject: [PATCH for 4.9 93/98] tools/power turbostat: dump Atom P-states correctly Date: Tue, 4 Apr 2017 19:32:37 +0000 Message-ID: <20170404193158.19041-94-alexander.levin@verizon.com> References: <20170404193158.19041-1-alexander.levin@verizon.com> In-Reply-To: <20170404193158.19041-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Len Brown [ Upstream commit 0f7887c49b0c454aef9936a6eadabe1c91b5af55 ] Turbostat dumps MSR_TURBO_RATIO_LIMIT on Core Architecture. But Atom Architecture uses MSR_ATOM_CORE_RATIOS and MSR_ATOM_CORE_TURBO_RATIOS. Signed-off-by: Len Brown Signed-off-by: Sasha Levin --- tools/power/x86/turbostat/turbostat.c | 103 +++++++++++++++++++++++++++---= ---- 1 file changed, 82 insertions(+), 21 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbos= tat/turbostat.c index 76c9954..7809056 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -1470,6 +1470,54 @@ dump_nhm_turbo_ratio_limits(void) } =20 static void +dump_atom_turbo_ratio_limits(void) +{ + unsigned long long msr; + unsigned int ratio; + + get_msr(base_cpu, MSR_ATOM_CORE_RATIOS, &msr); + fprintf(outf, "cpu%d: MSR_ATOM_CORE_RATIOS: 0x%08llx\n", base_cpu, msr & = 0xFFFFFFFF); + + ratio =3D (msr >> 0) & 0x3F; + if (ratio) + fprintf(outf, "%d * %.1f =3D %.1f MHz minimum operating frequency\n", + ratio, bclk, ratio * bclk); + + ratio =3D (msr >> 8) & 0x3F; + if (ratio) + fprintf(outf, "%d * %.1f =3D %.1f MHz low frequency mode (LFM)\n", + ratio, bclk, ratio * bclk); + + ratio =3D (msr >> 16) & 0x3F; + if (ratio) + fprintf(outf, "%d * %.1f =3D %.1f MHz base frequency\n", + ratio, bclk, ratio * bclk); + + get_msr(base_cpu, MSR_ATOM_CORE_TURBO_RATIOS, &msr); + fprintf(outf, "cpu%d: MSR_ATOM_CORE_TURBO_RATIOS: 0x%08llx\n", base_cpu, = msr & 0xFFFFFFFF); + + ratio =3D (msr >> 24) & 0x3F; + if (ratio) + fprintf(outf, "%d * %.1f =3D %.1f MHz max turbo 4 active cores\n", + ratio, bclk, ratio * bclk); + + ratio =3D (msr >> 16) & 0x3F; + if (ratio) + fprintf(outf, "%d * %.1f =3D %.1f MHz max turbo 3 active cores\n", + ratio, bclk, ratio * bclk); + + ratio =3D (msr >> 8) & 0x3F; + if (ratio) + fprintf(outf, "%d * %.1f =3D %.1f MHz max turbo 2 active cores\n", + ratio, bclk, ratio * bclk); + + ratio =3D (msr >> 0) & 0x3F; + if (ratio) + fprintf(outf, "%d * %.1f =3D %.1f MHz max turbo 1 active core\n", + ratio, bclk, ratio * bclk); +} + +static void dump_knl_turbo_ratio_limits(void) { const unsigned int buckets_no =3D 7; @@ -2230,8 +2278,32 @@ int probe_nhm_msrs(unsigned int family, unsigned int= model) has_base_hz =3D 1; return 1; } +/* + * SLV client has supporet for unique MSRs: + * + * MSR_CC6_DEMOTION_POLICY_CONFIG + * MSR_MC6_DEMOTION_POLICY_CONFIG + */ + +int has_slv_msrs(unsigned int family, unsigned int model) +{ + if (!genuine_intel) + return 0; + + switch (model) { + case INTEL_FAM6_ATOM_SILVERMONT1: + case INTEL_FAM6_ATOM_MERRIFIELD: + case INTEL_FAM6_ATOM_MOOREFIELD: + return 1; + } + return 0; +} + int has_nhm_turbo_ratio_limit(unsigned int family, unsigned int model) { + if (has_slv_msrs(family, model)) + return 0; + switch (model) { /* Nehalem compatible, but do not include turbo-ratio limit support */ case 0x2E: /* Nehalem-EX Xeon - Beckton */ @@ -2242,6 +2314,13 @@ int has_nhm_turbo_ratio_limit(unsigned int family, u= nsigned int model) return 1; } } +int has_atom_turbo_ratio_limit(unsigned int family, unsigned int model) +{ + if (has_slv_msrs(family, model)) + return 1; + + return 0; +} int has_ivt_turbo_ratio_limit(unsigned int family, unsigned int model) { if (!genuine_intel) @@ -2337,6 +2416,9 @@ dump_cstate_pstate_config_info(unsigned int family, u= nsigned int model) if (has_nhm_turbo_ratio_limit(family, model)) dump_nhm_turbo_ratio_limits(); =20 + if (has_atom_turbo_ratio_limit(family, model)) + dump_atom_turbo_ratio_limits(); + if (has_knl_turbo_ratio_limit(family, model)) dump_knl_turbo_ratio_limits(); =20 @@ -2951,27 +3033,6 @@ int has_snb_msrs(unsigned int family, unsigned int m= odel) } =20 /* - * SLV client has supporet for unique MSRs: - * - * MSR_CC6_DEMOTION_POLICY_CONFIG - * MSR_MC6_DEMOTION_POLICY_CONFIG - */ - -int has_slv_msrs(unsigned int family, unsigned int model) -{ - if (!genuine_intel) - return 0; - - switch (model) { - case INTEL_FAM6_ATOM_SILVERMONT1: - case INTEL_FAM6_ATOM_MERRIFIELD: - case INTEL_FAM6_ATOM_MOOREFIELD: - return 1; - } - return 0; -} - -/* * HSW adds support for additional MSRs: * * MSR_PKG_C8_RESIDENCY 0x00000630 --=20 2.9.3