[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] mwait-idle: correct/improve BXT support



commit feb7747be7fab49d929266e8b775ebb04198340a
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Aug 1 18:21:37 2016 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Aug 1 18:21:37 2016 +0200

    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 <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    [Linux commit: 3451ab3ebf92b12801878d8b5c94845afd4219f0]
    [Linux commit: bef450962597ff39a7f9d53a30523aae9eb55843]
---
 xen/arch/x86/cpu/mwait-idle.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index 4b33974..27361f9 100644
--- 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_usec(unsigned long 
long irtl)
 {
        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_usec(unsigned 
long long irtl)
 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;
        }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.