From patchwork Wed Jun 8 13:51:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9164757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4746B60572 for ; Wed, 8 Jun 2016 13:53:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35E3525D91 for ; Wed, 8 Jun 2016 13:53:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AD312824F; Wed, 8 Jun 2016 13:53:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C253225D91 for ; Wed, 8 Jun 2016 13:53:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAdtc-0006vZ-17; Wed, 08 Jun 2016 13:51:48 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAdta-0006vF-RF for xen-devel@lists.xenproject.org; Wed, 08 Jun 2016 13:51:46 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id 50/D4-31080-2F228575; Wed, 08 Jun 2016 13:51:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsXS6fjDS/ejUkS 4wbsJ4hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bntVOYCk6rVVw7tYytgfGlQhcjJ4eQQJ7E geM7GUFsXgE7ifbzV8BsCQFDiX3zV7F1MXJwsAioSkzaEwASZhNQl2h7tp0VJCwiYCBx7mgSi MksoC+xbR0LSIWwgI1Ea8tdRojhdhL37r1mB7E5BewlHu/bCtbJKyAo8XeHMEiYGajk1Yef7B MYeWYhZGYhyUDYWhIPf91igbC1JZYtfM08C2yvtMTyfxwQprPEk826qCpAbD+Jif8fsC1g5Fj FqF6cWlSWWqRrqZdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJERikDECwg3Ftq/Mh RkkOJiVRXkX38HAhvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxvFCPChQSLUtNTK9Iyc4DxApOW4 OBREuE9DpLmLS5IzC3OTIdInWJUlBLn3QCSEABJZJTmwbXBYvQSo6yUMC8j0CFCPAWpRbmZJa jyrxjFORiVhHkfgEzhycwrgZv+CmgxE9Di5UfCQRaXJCKkpBoYTaJXrFmvczJ1ffbrNdpzJ4Y 5rPkRt2+hT+T7Nzynoxe/1s9mVd/Lo8T03yHViFmOMYznZYjZkZDsyVfNzh7sKttkKRDFJntR 642ypeiMk/OVz1c4c7B3e1YtsSpVOVvccGnXhorzKW+jlteWbd4zV4h776vuJOO30xMdi88s0 mNfG3nG+DmrEktxRqKhFnNRcSIADY/PP8wCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1465393903!7467787!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18599 invoked from network); 8 Jun 2016 13:51:45 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Jun 2016 13:51:45 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 08 Jun 2016 07:51:43 -0600 Message-Id: <57583F0A02000078000F320D@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 08 Jun 2016 07:51:38 -0600 From: "Jan Beulich" To: "xen-devel" References: <57583E0D02000078000F31F2@prv-mh.provo.novell.com> In-Reply-To: <57583E0D02000078000F31F2@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH 5/5] mwait-idle: correct/improve BXT support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Linux commit 5dcef69486 ("intel_idle: add BXT support") added an 8-element lookup array with just a 2-bit value used for lookups. As per the SDM that bit field is really 3 bits wide. Since the top two array entries are zero, deal with the resulting invalid (zero) values by moving the zero-MSR-value check into irtl_2_usec() and having that function's caller check its result instead. Signed-off-by: Jan Beulich mwait-idle: correct/improve BXT support Linux commit 5dcef69486 ("intel_idle: add BXT support") added an 8-element lookup array with just a 2-bit value used for lookups. As per the SDM that bit field is really 3 bits wide. Since the top two array entries are zero, deal with the resulting invalid (zero) values by moving the zero-MSR-value check into irtl_2_usec() and having that function's caller check its result instead. Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -922,7 +922,10 @@ static unsigned long long __init irtl_2_ { unsigned long long ns; - ns = irtl_ns_units[(irtl >> 10) & 0x3]; + if (!irtl) + return 0; + + ns = irtl_ns_units[(irtl >> 10) & 0x7]; return (irtl & 0x3FF) * ns / 1000; } @@ -935,43 +938,39 @@ static unsigned long long __init irtl_2_ static void __init bxt_idle_state_table_update(void) { unsigned long long msr; + unsigned int usec; rdmsrl(MSR_PKGC6_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[2].exit_latency = usec; bxt_cstates[2].target_residency = usec; } rdmsrl(MSR_PKGC7_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[3].exit_latency = usec; bxt_cstates[3].target_residency = usec; } rdmsrl(MSR_PKGC8_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[4].exit_latency = usec; bxt_cstates[4].target_residency = usec; } rdmsrl(MSR_PKGC9_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[5].exit_latency = usec; bxt_cstates[5].target_residency = usec; } rdmsrl(MSR_PKGC10_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[6].exit_latency = usec; bxt_cstates[6].target_residency = usec; } --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -922,7 +922,10 @@ static unsigned long long __init irtl_2_ { unsigned long long ns; - ns = irtl_ns_units[(irtl >> 10) & 0x3]; + if (!irtl) + return 0; + + ns = irtl_ns_units[(irtl >> 10) & 0x7]; return (irtl & 0x3FF) * ns / 1000; } @@ -935,43 +938,39 @@ static unsigned long long __init irtl_2_ static void __init bxt_idle_state_table_update(void) { unsigned long long msr; + unsigned int usec; rdmsrl(MSR_PKGC6_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[2].exit_latency = usec; bxt_cstates[2].target_residency = usec; } rdmsrl(MSR_PKGC7_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[3].exit_latency = usec; bxt_cstates[3].target_residency = usec; } rdmsrl(MSR_PKGC8_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[4].exit_latency = usec; bxt_cstates[4].target_residency = usec; } rdmsrl(MSR_PKGC9_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[5].exit_latency = usec; bxt_cstates[5].target_residency = usec; } rdmsrl(MSR_PKGC10_IRTL, msr); - if (msr) { - unsigned int usec = irtl_2_usec(msr); - + usec = irtl_2_usec(msr); + if (usec) { bxt_cstates[6].exit_latency = usec; bxt_cstates[6].target_residency = usec; }