diff mbox

[Precise,SRU] x86/amd: Re-enable CPU topology extensions in case BIOS has disabled it

Message ID 1339619493-7952-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner June 13, 2012, 8:31 p.m. UTC
From: Andreas Herrmann <andreas.herrmann3@amd.com>

BugLink: http://bugs.launchpad.net/bugs/1009087

BIOS will switch off the corresponding feature flag on family
15h models 10h-1fh non-desktop CPUs.

The topology extension CPUID leafs are required to detect which
cores belong to the same compute unit. (thread siblings mask is
set accordingly and also correct information about L1i and L2
cache sharing depends on this).

W/o this patch we wouldn't see which cores belong to the same
compute unit and also cache sharing information for L1i and L2
would be incorrect on such systems.

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit f7f286a910221ae18b21c18d9d0f4cd88965829f)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 arch/x86/kernel/cpu/amd.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Leann Ogasawara June 13, 2012, 8:58 p.m. UTC | #1
On 06/13/2012 01:31 PM, Tim Gardner wrote:
> From: Andreas Herrmann <andreas.herrmann3@amd.com>
>
> BugLink: http://bugs.launchpad.net/bugs/1009087
>
> BIOS will switch off the corresponding feature flag on family
> 15h models 10h-1fh non-desktop CPUs.
>
> The topology extension CPUID leafs are required to detect which
> cores belong to the same compute unit. (thread siblings mask is
> set accordingly and also correct information about L1i and L2
> cache sharing depends on this).
>
> W/o this patch we wouldn't see which cores belong to the same
> compute unit and also cache sharing information for L1i and L2
> would be incorrect on such systems.
>
> Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> (cherry picked from commit f7f286a910221ae18b21c18d9d0f4cd88965829f)
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

Looks to be hardware specific and thus low risk of regression.  It seems
like a good enough candidate for upstream stable which I'll leave to you
to sort out.

Acked-by: Leann Ogasawara <leann.ogasawara@canonical.com>

> ---
>  arch/x86/kernel/cpu/amd.c |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index ef21bdc..9aa4a62 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -578,6 +578,24 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
>  		}
>  	}
>  
> +	/* re-enable TopologyExtensions if switched off by BIOS */
> +	if ((c->x86 == 0x15) &&
> +	    (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
> +	    !cpu_has(c, X86_FEATURE_TOPOEXT)) {
> +		u64 val;
> +
> +		if (!rdmsrl_amd_safe(0xc0011005, &val)) {
> +			val |= 1ULL << 54;
> +			wrmsrl_amd_safe(0xc0011005, val);
> +			rdmsrl(0xc0011005, val);
> +			if (val & (1ULL << 54)) {
> +				set_cpu_cap(c, X86_FEATURE_TOPOEXT);
> +				printk(KERN_INFO FW_INFO "CPU: Re-enabling "
> +				  "disabled Topology Extensions Support\n");
> +			}
> +		}
> +	}
> +
>  	cpu_detect_cache_sizes(c);
>  
>  	/* Multi core CPU? */
Herton Ronaldo Krzesinski June 13, 2012, 10:16 p.m. UTC | #2

Brad Figg June 13, 2012, 10:47 p.m. UTC | #3
On 06/13/2012 01:31 PM, Tim Gardner wrote:
> From: Andreas Herrmann <andreas.herrmann3@amd.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1009087
> 
> BIOS will switch off the corresponding feature flag on family
> 15h models 10h-1fh non-desktop CPUs.
> 
> The topology extension CPUID leafs are required to detect which
> cores belong to the same compute unit. (thread siblings mask is
> set accordingly and also correct information about L1i and L2
> cache sharing depends on this).
> 
> W/o this patch we wouldn't see which cores belong to the same
> compute unit and also cache sharing information for L1i and L2
> would be incorrect on such systems.
> 
> Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> (cherry picked from commit f7f286a910221ae18b21c18d9d0f4cd88965829f)
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  arch/x86/kernel/cpu/amd.c |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index ef21bdc..9aa4a62 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -578,6 +578,24 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
>  		}
>  	}
>  
> +	/* re-enable TopologyExtensions if switched off by BIOS */
> +	if ((c->x86 == 0x15) &&
> +	    (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
> +	    !cpu_has(c, X86_FEATURE_TOPOEXT)) {
> +		u64 val;
> +
> +		if (!rdmsrl_amd_safe(0xc0011005, &val)) {
> +			val |= 1ULL << 54;
> +			wrmsrl_amd_safe(0xc0011005, val);
> +			rdmsrl(0xc0011005, val);
> +			if (val & (1ULL << 54)) {
> +				set_cpu_cap(c, X86_FEATURE_TOPOEXT);
> +				printk(KERN_INFO FW_INFO "CPU: Re-enabling "
> +				  "disabled Topology Extensions Support\n");
> +			}
> +		}
> +	}
> +
>  	cpu_detect_cache_sizes(c);
>  
>  	/* Multi core CPU? */
Tim Gardner June 14, 2012, 12:12 p.m. UTC | #4

Tim Gardner June 14, 2012, 12:31 p.m. UTC | #5
On 06/13/2012 02:58 PM, Leann Ogasawara wrote:
> On 06/13/2012 01:31 PM, Tim Gardner wrote:
>> From: Andreas Herrmann <andreas.herrmann3@amd.com>
>>
>> BugLink: http://bugs.launchpad.net/bugs/1009087
>>
>> BIOS will switch off the corresponding feature flag on family
>> 15h models 10h-1fh non-desktop CPUs.
>>
>> The topology extension CPUID leafs are required to detect which
>> cores belong to the same compute unit. (thread siblings mask is
>> set accordingly and also correct information about L1i and L2
>> cache sharing depends on this).
>>
>> W/o this patch we wouldn't see which cores belong to the same
>> compute unit and also cache sharing information for L1i and L2
>> would be incorrect on such systems.
>>
>> Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
>> Signed-off-by: Ingo Molnar <mingo@kernel.org>
>> (cherry picked from commit f7f286a910221ae18b21c18d9d0f4cd88965829f)
>> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> 
> Looks to be hardware specific and thus low risk of regression.  It seems
> like a good enough candidate for upstream stable which I'll leave to you
> to sort out.
> 
> Acked-by: Leann Ogasawara <leann.ogasawara@canonical.com>
> 

Sent to stable.
diff mbox

Patch

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index ef21bdc..9aa4a62 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -578,6 +578,24 @@  static void __cpuinit init_amd(struct cpuinfo_x86 *c)
 		}
 	}
 
+	/* re-enable TopologyExtensions if switched off by BIOS */
+	if ((c->x86 == 0x15) &&
+	    (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
+	    !cpu_has(c, X86_FEATURE_TOPOEXT)) {
+		u64 val;
+
+		if (!rdmsrl_amd_safe(0xc0011005, &val)) {
+			val |= 1ULL << 54;
+			wrmsrl_amd_safe(0xc0011005, val);
+			rdmsrl(0xc0011005, val);
+			if (val & (1ULL << 54)) {
+				set_cpu_cap(c, X86_FEATURE_TOPOEXT);
+				printk(KERN_INFO FW_INFO "CPU: Re-enabling "
+				  "disabled Topology Extensions Support\n");
+			}
+		}
+	}
+
 	cpu_detect_cache_sizes(c);
 
 	/* Multi core CPU? */