diff mbox series

[v4,2/2] arm64: topology: Use PPTT to determine if PE is a thread

Message ID 20190808204007.30110-3-jeremy.linton@arm.com
State Accepted
Commit 98dc19902a0b2e5348e43d6a2c39a0a7d0fc639e
Headers show
Series arm64/PPTT ACPI 6.3 thread flag support | expand

Commit Message

Jeremy Linton Aug. 8, 2019, 8:40 p.m. UTC
ACPI 6.3 adds a thread flag to represent if a CPU/PE is
actually a thread. Given that the MPIDR_MT bit may not
represent this information consistently on homogeneous machines
we should prefer the PPTT flag if its available.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

---
 arch/arm64/kernel/topology.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

-- 
2.21.0

Comments

Robert Richter Aug. 8, 2019, 10:23 p.m. UTC | #1
On 08.08.19 15:40:07, Jeremy Linton wrote:
> ACPI 6.3 adds a thread flag to represent if a CPU/PE is

> actually a thread. Given that the MPIDR_MT bit may not

> represent this information consistently on homogeneous machines

> we should prefer the PPTT flag if its available.

> 

> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>

> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

> ---

>  arch/arm64/kernel/topology.c | 19 +++++++++++++++----

>  1 file changed, 15 insertions(+), 4 deletions(-)

> 

> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c

> index 0825c4a856e3..bad9c42ea825 100644

> --- a/arch/arm64/kernel/topology.c

> +++ b/arch/arm64/kernel/topology.c

> @@ -340,17 +340,28 @@ void remove_cpu_topology(unsigned int cpu)

>  }

>  

>  #ifdef CONFIG_ACPI

> +static int __init acpi_cpu_is_threaded(int cpu)

> +{

> +	int is_threaded = acpi_pptt_cpu_is_thread(cpu);

> +

> +	/*

> +	 * if the PPTT doesn't have thread information, assume a homogeneous

> +	 * machine and return the current CPU's thread state.

> +	 */

> +	if (is_threaded < 0)

> +		is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;


Since this is no longer bool now, better have a !!(...) or (...) != 0
here.

> +

> +	return is_threaded;

> +}

> +

>  /*

>   * Propagate the topology information of the processor_topology_node tree to the

>   * cpu_topology array.

>   */

>  static int __init parse_acpi_topology(void)

>  {

> -	bool is_threaded;

>  	int cpu, topology_id;

>  

> -	is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;

> -

>  	for_each_possible_cpu(cpu) {

>  		int i, cache_id;

>  

> @@ -358,7 +369,7 @@ static int __init parse_acpi_topology(void)

>  		if (topology_id < 0)

>  			return topology_id;

>  

> -		if (is_threaded) {

> +		if (acpi_cpu_is_threaded(cpu)) {

>  			cpu_topology[cpu].thread_id = topology_id;

>  			topology_id = find_acpi_cpu_topology(cpu, 1);

>  			cpu_topology[cpu].core_id   = topology_id;


Looks otherwise ok.

Reviewed-by: Robert Richter <rrichter@marvell.com>
diff mbox series

Patch

diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 0825c4a856e3..bad9c42ea825 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -340,17 +340,28 @@  void remove_cpu_topology(unsigned int cpu)
 }
 
 #ifdef CONFIG_ACPI
+static int __init acpi_cpu_is_threaded(int cpu)
+{
+	int is_threaded = acpi_pptt_cpu_is_thread(cpu);
+
+	/*
+	 * if the PPTT doesn't have thread information, assume a homogeneous
+	 * machine and return the current CPU's thread state.
+	 */
+	if (is_threaded < 0)
+		is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
+
+	return is_threaded;
+}
+
 /*
  * Propagate the topology information of the processor_topology_node tree to the
  * cpu_topology array.
  */
 static int __init parse_acpi_topology(void)
 {
-	bool is_threaded;
 	int cpu, topology_id;
 
-	is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
-
 	for_each_possible_cpu(cpu) {
 		int i, cache_id;
 
@@ -358,7 +369,7 @@  static int __init parse_acpi_topology(void)
 		if (topology_id < 0)
 			return topology_id;
 
-		if (is_threaded) {
+		if (acpi_cpu_is_threaded(cpu)) {
 			cpu_topology[cpu].thread_id = topology_id;
 			topology_id = find_acpi_cpu_topology(cpu, 1);
 			cpu_topology[cpu].core_id   = topology_id;