linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2]  arm64/PPTT ACPI 6.3 thread flag support
@ 2019-08-08 20:40 Jeremy Linton
  2019-08-08 20:40 ` [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
  2019-08-08 20:40 ` [PATCH v4 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
  0 siblings, 2 replies; 15+ messages in thread
From: Jeremy Linton @ 2019-08-08 20:40 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will, rjw, lenb, lorenzo.pieralisi,
	sudeep.holla, rric, Jeremy Linton

ACPI 6.3 adds a flag to the CPU node to indicate whether
the given CPU is a thread. Add a function to return that
information for a given linux logical CPU and then utilize
it while building the arm64 topology.

v4->v5: Add Sudeep's Reviewed tag
	Trivial comment tweaks
	Move is_threaded logic from parse_acpi_topology()
	      to apci_cpu_is_threaded()

v3->v4: Remove table revision cache as this code path is only
	      called during boot and there aren't any
	      indications that it presents a perf issue.
	Rebase to 5.3

v2->v3: Clarify and tweak the return from check_acpi_cpu_flag()
	Cache the PPTT table revision to avoid repeat
	      acpi_table_get/put calls in the case of
	      missing or old PPTT tables.

v1->v2:
	Return ENOENT instead on ENONET.

Jeremy Linton (2):
  ACPI/PPTT: Add support for ACPI 6.3 thread flag
  arm64: topology: Use PPTT to determine if PE is a thread

 arch/arm64/kernel/topology.c | 19 ++++++++++---
 drivers/acpi/pptt.c          | 53 +++++++++++++++++++++++++++++++++++-
 include/linux/acpi.h         |  5 ++++
 3 files changed, 72 insertions(+), 5 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-08 20:40 [PATCH v4 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
@ 2019-08-08 20:40 ` Jeremy Linton
  2019-08-08 22:25   ` Robert Richter
  2019-08-08 20:40 ` [PATCH v4 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
  1 sibling, 1 reply; 15+ messages in thread
From: Jeremy Linton @ 2019-08-08 20:40 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will, rjw, lenb, lorenzo.pieralisi,
	sudeep.holla, rric, Jeremy Linton

ACPI 6.3 adds a flag to the CPU node to indicate whether
the given PE is a thread. Add a function to return that
information for a given linux logical CPU.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/acpi/pptt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++-
 include/linux/acpi.h |  5 +++++
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index 1e7ac0bd0d3a..f31544d3656e 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -540,6 +540,44 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
 	return retval;
 }
 
+/**
+ * check_acpi_cpu_flag() - Determine if CPU node has a flag set
+ * @cpu: Kernel logical CPU number
+ * @rev: The minimum PPTT revision defining the flag
+ * @flag: The flag itself
+ *
+ * Check the node representing a CPU for a given flag.
+ *
+ * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
+ *	   the table revision isn't new enough.
+ *	   1, any passed flag set
+ *	   0, flag unset
+ */
+static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
+{
+	struct acpi_table_header *table;
+	acpi_status status;
+	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
+	struct acpi_pptt_processor *cpu_node = NULL;
+	int ret = -ENOENT;
+
+	status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
+	if (ACPI_FAILURE(status)) {
+		acpi_pptt_warn_missing();
+		return ret;
+	}
+
+	if (table->revision >= rev)
+		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
+
+	if (cpu_node)
+		ret = (cpu_node->flags & flag) != 0;
+
+	acpi_put_table(table);
+
+	return ret;
+}
+
 /**
  * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
  * @cpu: Kernel logical CPU number
@@ -604,6 +642,20 @@ int cache_setup_acpi(unsigned int cpu)
 	return status;
 }
 
+/**
+ * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread
+ * @cpu: Kernel logical CPU number
+ *
+ * Return: 1, a thread
+ *         0, not a thread
+ *         -ENOENT ,if the PPTT doesn't exist, the CPU cannot be found or
+ *         the table revision isn't new enough.
+ */
+int acpi_pptt_cpu_is_thread(unsigned int cpu)
+{
+	return check_acpi_cpu_flag(cpu, 2, ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD);
+}
+
 /**
  * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU
  * @cpu: Kernel logical CPU number
@@ -664,7 +716,6 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
 	return ret;
 }
 
-
 /**
  * find_acpi_cpu_topology_package() - Determine a unique CPU package value
  * @cpu: Kernel logical CPU number
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 9426b9aaed86..9d0e20a2ac83 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1302,11 +1302,16 @@ static inline int lpit_read_residency_count_address(u64 *address)
 #endif
 
 #ifdef CONFIG_ACPI_PPTT
+int acpi_pptt_cpu_is_thread(unsigned int cpu);
 int find_acpi_cpu_topology(unsigned int cpu, int level);
 int find_acpi_cpu_topology_package(unsigned int cpu);
 int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
 int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
 #else
+static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
+{
+	return -EINVAL;
+}
 static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
 {
 	return -EINVAL;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v4 2/2] arm64: topology: Use PPTT to determine if PE is a thread
  2019-08-08 20:40 [PATCH v4 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
  2019-08-08 20:40 ` [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
@ 2019-08-08 20:40 ` Jeremy Linton
  2019-08-08 22:23   ` Robert Richter
  1 sibling, 1 reply; 15+ messages in thread
From: Jeremy Linton @ 2019-08-08 20:40 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will, rjw, lenb, lorenzo.pieralisi,
	sudeep.holla, rric, Jeremy Linton

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;
+
+	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;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 2/2] arm64: topology: Use PPTT to determine if PE is a thread
  2019-08-08 20:40 ` [PATCH v4 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
@ 2019-08-08 22:23   ` Robert Richter
  0 siblings, 0 replies; 15+ messages in thread
From: Robert Richter @ 2019-08-08 22:23 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-arm-kernel, linux-acpi, catalin.marinas, will, rjw, lenb,
	lorenzo.pieralisi, sudeep.holla, rric

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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-08 20:40 ` [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
@ 2019-08-08 22:25   ` Robert Richter
  2019-08-12  9:06     ` Rafael J. Wysocki
  0 siblings, 1 reply; 15+ messages in thread
From: Robert Richter @ 2019-08-08 22:25 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-arm-kernel, linux-acpi, catalin.marinas, will, rjw, lenb,
	lorenzo.pieralisi, sudeep.holla, rric

On 08.08.19 15:40:06, Jeremy Linton wrote:
> ACPI 6.3 adds a flag to the CPU node to indicate whether
> the given PE is a thread. Add a function to return that
> information for a given linux logical CPU.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/acpi/pptt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++-
>  include/linux/acpi.h |  5 +++++
>  2 files changed, 57 insertions(+), 1 deletion(-)

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-08 22:25   ` Robert Richter
@ 2019-08-12  9:06     ` Rafael J. Wysocki
  2019-08-12 11:59       ` Will Deacon
  0 siblings, 1 reply; 15+ messages in thread
From: Rafael J. Wysocki @ 2019-08-12  9:06 UTC (permalink / raw)
  To: Robert Richter
  Cc: Jeremy Linton, linux-arm-kernel, linux-acpi, catalin.marinas,
	will, rjw, lenb, lorenzo.pieralisi, sudeep.holla, rric

On Fri, Aug 9, 2019 at 12:25 AM Robert Richter <rrichter@marvell.com> wrote:
>
> On 08.08.19 15:40:06, Jeremy Linton wrote:
> > ACPI 6.3 adds a flag to the CPU node to indicate whether
> > the given PE is a thread. Add a function to return that
> > information for a given linux logical CPU.
> >
> > Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> >  drivers/acpi/pptt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++-
> >  include/linux/acpi.h |  5 +++++
> >  2 files changed, 57 insertions(+), 1 deletion(-)
>
> Reviewed-by: Robert Richter <rrichter@marvell.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

and please push it through ARM64 along with the second patch.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-12  9:06     ` Rafael J. Wysocki
@ 2019-08-12 11:59       ` Will Deacon
  2019-08-20  9:01         ` John Garry
  0 siblings, 1 reply; 15+ messages in thread
From: Will Deacon @ 2019-08-12 11:59 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Robert Richter, Jeremy Linton, linux-arm-kernel, linux-acpi,
	catalin.marinas, rjw, lenb, lorenzo.pieralisi, sudeep.holla,
	rric

On Mon, Aug 12, 2019 at 11:06:07AM +0200, Rafael J. Wysocki wrote:
> On Fri, Aug 9, 2019 at 12:25 AM Robert Richter <rrichter@marvell.com> wrote:
> >
> > On 08.08.19 15:40:06, Jeremy Linton wrote:
> > > ACPI 6.3 adds a flag to the CPU node to indicate whether
> > > the given PE is a thread. Add a function to return that
> > > information for a given linux logical CPU.
> > >
> > > Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> > > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> > > ---
> > >  drivers/acpi/pptt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++-
> > >  include/linux/acpi.h |  5 +++++
> > >  2 files changed, 57 insertions(+), 1 deletion(-)
> >
> > Reviewed-by: Robert Richter <rrichter@marvell.com>
> 
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> and please push it through ARM64 along with the second patch.

Thanks. I'll push these into -next shortly.

Will

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-12 11:59       ` Will Deacon
@ 2019-08-20  9:01         ` John Garry
  2019-08-21 13:20           ` Jeremy Linton
  0 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2019-08-20  9:01 UTC (permalink / raw)
  To: Will Deacon, Rafael J. Wysocki, Jeremy Linton
  Cc: lorenzo.pieralisi, rric, catalin.marinas, rjw, linux-acpi,
	Robert Richter, sudeep.holla, linux-arm-kernel, lenb,
	wanghuiqiang

On 12/08/2019 12:59, Will Deacon wrote:
> On Mon, Aug 12, 2019 at 11:06:07AM +0200, Rafael J. Wysocki wrote:
>> On Fri, Aug 9, 2019 at 12:25 AM Robert Richter <rrichter@marvell.com> wrote:
>>>
>>> On 08.08.19 15:40:06, Jeremy Linton wrote:
>>>> ACPI 6.3 adds a flag to the CPU node to indicate whether
>>>> the given PE is a thread. Add a function to return that
>>>> information for a given linux logical CPU.
>>>>
>>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>>> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
>>>> ---
>>>>  drivers/acpi/pptt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++-
>>>>  include/linux/acpi.h |  5 +++++
>>>>  2 files changed, 57 insertions(+), 1 deletion(-)
>>>
>>> Reviewed-by: Robert Richter <rrichter@marvell.com>
>>
>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> and please push it through ARM64 along with the second patch.
>
> Thanks. I'll push these into -next shortly.


Hi Jeremy,

We're considering requesting this support is backported to stable. We 
have a platform which incorrectly sets the MT bit. To update our 
firmware to PPTT v2, we need the kernel to support PPTT v2 also.

Please let me know if you anticipate an issue in this.

Cheers,
John

>
> Will
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-20  9:01         ` John Garry
@ 2019-08-21 13:20           ` Jeremy Linton
  2019-08-21 13:25             ` John Garry
  0 siblings, 1 reply; 15+ messages in thread
From: Jeremy Linton @ 2019-08-21 13:20 UTC (permalink / raw)
  To: John Garry, Will Deacon, Rafael J. Wysocki
  Cc: lorenzo.pieralisi, rric, catalin.marinas, rjw, linux-acpi,
	Robert Richter, sudeep.holla, linux-arm-kernel, lenb,
	wanghuiqiang

Hi,

On 8/20/19 4:01 AM, John Garry wrote:
> On 12/08/2019 12:59, Will Deacon wrote:
>> On Mon, Aug 12, 2019 at 11:06:07AM +0200, Rafael J. Wysocki wrote:
>>> On Fri, Aug 9, 2019 at 12:25 AM Robert Richter <rrichter@marvell.com> 
>>> wrote:
>>>>
>>>> On 08.08.19 15:40:06, Jeremy Linton wrote:
>>>>> ACPI 6.3 adds a flag to the CPU node to indicate whether
>>>>> the given PE is a thread. Add a function to return that
>>>>> information for a given linux logical CPU.
>>>>>
>>>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>>>> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
>>>>> ---
>>>>>  drivers/acpi/pptt.c  | 53 
>>>>> +++++++++++++++++++++++++++++++++++++++++++-
>>>>>  include/linux/acpi.h |  5 +++++
>>>>>  2 files changed, 57 insertions(+), 1 deletion(-)
>>>>
>>>> Reviewed-by: Robert Richter <rrichter@marvell.com>
>>>
>>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>
>>> and please push it through ARM64 along with the second patch.
>>
>> Thanks. I'll push these into -next shortly.
> 
> 
> Hi Jeremy,
> 
> We're considering requesting this support is backported to stable. We 
> have a platform which incorrectly sets the MT bit. To update our 
> firmware to PPTT v2, we need the kernel to support PPTT v2 also.
> 
> Please let me know if you anticipate an issue in this.

No I don't see any issues with that once it lands.

I believe the ball is rolling in the case of some older distro kernel's 
as well.

Thanks,

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-21 13:20           ` Jeremy Linton
@ 2019-08-21 13:25             ` John Garry
  0 siblings, 0 replies; 15+ messages in thread
From: John Garry @ 2019-08-21 13:25 UTC (permalink / raw)
  To: Jeremy Linton, Will Deacon, Rafael J. Wysocki
  Cc: lorenzo.pieralisi, rric, catalin.marinas, rjw, linux-acpi,
	Robert Richter, sudeep.holla, linux-arm-kernel, lenb,
	wanghuiqiang

On 21/08/2019 14:20, Jeremy Linton wrote:
> Hi,
>
> On 8/20/19 4:01 AM, John Garry wrote:
>> On 12/08/2019 12:59, Will Deacon wrote:
>>> On Mon, Aug 12, 2019 at 11:06:07AM +0200, Rafael J. Wysocki wrote:
>>>> On Fri, Aug 9, 2019 at 12:25 AM Robert Richter
>>>> <rrichter@marvell.com> wrote:
>>>>>
>>>>> On 08.08.19 15:40:06, Jeremy Linton wrote:
>>>>>> ACPI 6.3 adds a flag to the CPU node to indicate whether
>>>>>> the given PE is a thread. Add a function to return that
>>>>>> information for a given linux logical CPU.
>>>>>>
>>>>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>>>>> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
>>>>>> ---
>>>>>>  drivers/acpi/pptt.c  | 53
>>>>>> +++++++++++++++++++++++++++++++++++++++++++-
>>>>>>  include/linux/acpi.h |  5 +++++
>>>>>>  2 files changed, 57 insertions(+), 1 deletion(-)
>>>>>
>>>>> Reviewed-by: Robert Richter <rrichter@marvell.com>
>>>>
>>>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>>
>>>> and please push it through ARM64 along with the second patch.
>>>
>>> Thanks. I'll push these into -next shortly.
>>
>>
>> Hi Jeremy,
>>
>> We're considering requesting this support is backported to stable. We
>> have a platform which incorrectly sets the MT bit. To update our
>> firmware to PPTT v2, we need the kernel to support PPTT v2 also.
>>
>> Please let me know if you anticipate an issue in this.
>
> No I don't see any issues with that once it lands.
>
> I believe the ball is rolling in the case of some older distro kernel's
> as well.

Cool.

Cheers,
John

>
> Thanks,
>
> .
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-02 13:05   ` Robert Richter
@ 2019-08-02 15:36     ` Jeremy Linton
  0 siblings, 0 replies; 15+ messages in thread
From: Jeremy Linton @ 2019-08-02 15:36 UTC (permalink / raw)
  To: Robert Richter
  Cc: linux-arm-kernel, lorenzo.pieralisi, catalin.marinas, rjw,
	linux-acpi, sudeep.holla, will, lenb

Hi,

Thanks for taking a look at this.

On 8/2/19 8:05 AM, Robert Richter wrote:
> On 31.07.19 22:46:33, Jeremy Linton wrote:
> 
>> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
>> index 9426b9aaed86..9d0e20a2ac83 100644
>> --- a/include/linux/acpi.h
>> +++ b/include/linux/acpi.h
>> @@ -1302,11 +1302,16 @@ static inline int lpit_read_residency_count_address(u64 *address)
>>   #endif
>>   
>>   #ifdef CONFIG_ACPI_PPTT
>> +int acpi_pptt_cpu_is_thread(unsigned int cpu);
>>   int find_acpi_cpu_topology(unsigned int cpu, int level);
>>   int find_acpi_cpu_topology_package(unsigned int cpu);
>>   int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
>>   int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
> 
> All those functions (exept hetero_id) are used only in
> parse_acpi_topology(). So how about creating a struct with thread_id,
> core_id, and cache_id (and hetero_id (?)) and have a single pptt table
> parsing function that fills in all of this into that struct? This
> simplifies the api and also the code.
> 
> This also shows that hetid (see arm_pmu_acpi.c) better should be
> stored in cpu_topology[] too and thus being parsed with the other
> parameters as well and made accessible from there by a helper.


I think the idea here was to avoid an additional set of intermediate 
data structures between the PPTT table/structure and the final arch 
specific data structures (which themselves are used to feed other 
things, like the scheduler, note the llc parsing). Rather the attempt is 
to provide a set of tools to retrieve information and let the policy for 
how that information is used be dictated by the consumer.

In the future, if we can further unify the arch specific cpu_topology 
structures it would make sense to parse directly into them, but until 
that happens I don't think we should try. The existing code does parse 
directly into the cache structures, but the cpu topology is subtly arm64 
at the moment. If another arch decided to use this, i'm not sure they 
would want or need it parsed in exactly the same way.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-01  3:46 ` [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
  2019-08-01 15:57   ` Sudeep Holla
@ 2019-08-02 13:05   ` Robert Richter
  2019-08-02 15:36     ` Jeremy Linton
  1 sibling, 1 reply; 15+ messages in thread
From: Robert Richter @ 2019-08-02 13:05 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-arm-kernel, lorenzo.pieralisi, catalin.marinas, rjw,
	linux-acpi, sudeep.holla, will, lenb

On 31.07.19 22:46:33, Jeremy Linton wrote:

> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 9426b9aaed86..9d0e20a2ac83 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -1302,11 +1302,16 @@ static inline int lpit_read_residency_count_address(u64 *address)
>  #endif
>  
>  #ifdef CONFIG_ACPI_PPTT
> +int acpi_pptt_cpu_is_thread(unsigned int cpu);
>  int find_acpi_cpu_topology(unsigned int cpu, int level);
>  int find_acpi_cpu_topology_package(unsigned int cpu);
>  int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
>  int find_acpi_cpu_cache_topology(unsigned int cpu, int level);

All those functions (exept hetero_id) are used only in
parse_acpi_topology(). So how about creating a struct with thread_id,
core_id, and cache_id (and hetero_id (?)) and have a single pptt table
parsing function that fills in all of this into that struct? This
simplifies the api and also the code.

This also shows that hetid (see arm_pmu_acpi.c) better should be
stored in cpu_topology[] too and thus being parsed with the other
parameters as well and made accessible from there by a helper.

-Robert

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-01 15:57   ` Sudeep Holla
@ 2019-08-01 16:10     ` Jeremy Linton
  0 siblings, 0 replies; 15+ messages in thread
From: Jeremy Linton @ 2019-08-01 16:10 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: lorenzo.pieralisi, catalin.marinas, rjw, linux-acpi, will,
	linux-arm-kernel, lenb

Hi,


Thanks for looking at this.

On 8/1/19 10:57 AM, Sudeep Holla wrote:
> 
> Hi Jeremy,
> 
> On Wed, Jul 31, 2019 at 10:46:33PM -0500, Jeremy Linton wrote:
>> ACPI 6.3 adds a flag to the CPU node to indicate whether
>> the given PE is a thread. Add a function to return that
>> information for a given linux logical CPU.
>>
> 
> Apart from few minor nits,
> 
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> 
>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>> ---
>>   drivers/acpi/pptt.c  | 54 +++++++++++++++++++++++++++++++++++++++++++-
>>   include/linux/acpi.h |  5 ++++
>>   2 files changed, 58 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
>> index 1e7ac0bd0d3a..84718f6cb741 100644
>> --- a/drivers/acpi/pptt.c
>> +++ b/drivers/acpi/pptt.c
>> @@ -540,6 +540,44 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
>>   	return retval;
>>   }
>>
>> +/**
>> + * check_acpi_cpu_flag() - Determine if CPU node has a flag set
>> + * @cpu: Kernel logical CPU number
>> + * @rev: The PPTT revision defining the flag
> 
> [nit] I would rather put it as minimum PPTT revision that supports the
> flag. It aligns with the code too as we are not looking for exact match.

Ok, sure.


> 
>> + * @flag: The flag itself
>> + *
>> + * Check the node representing a CPU for a given flag.
>> + *
>> + * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
>> + *	   the table revision isn't new enough.
>> + *	   1, any passed flag set
>> + *	   0, flag unset
>> + */
>> +static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
>> +{
>> +	struct acpi_table_header *table;
>> +	acpi_status status;
>> +	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
>> +	struct acpi_pptt_processor *cpu_node = NULL;
>> +	int ret = -ENOENT;
>> +
>> +	status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
>> +	if (ACPI_FAILURE(status)) {
>> +		acpi_pptt_warn_missing();
>> +		return ret;
>> +	}
>> +
>> +	if (table->revision >= rev)
>> +		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
>> +
>> +	if (cpu_node)
>> +		ret = (cpu_node->flags & flag) != 0;
>> +
>> +	acpi_put_table(table);
>> +
>> +	return ret;
>> +}
>> +
>>   /**
>>    * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
>>    * @cpu: Kernel logical CPU number
>> @@ -604,6 +642,21 @@ int cache_setup_acpi(unsigned int cpu)
>>   	return status;
>>   }
>>
>> +/**
>> + * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread
>> + * @cpu: Kernel logical CPU number
>> + *
> 
> [nit] If you spin the patch again, you can drop extra line space here.

Sure..


> 
> --
> Regards,
> Sudeep
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-01  3:46 ` [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
@ 2019-08-01 15:57   ` Sudeep Holla
  2019-08-01 16:10     ` Jeremy Linton
  2019-08-02 13:05   ` Robert Richter
  1 sibling, 1 reply; 15+ messages in thread
From: Sudeep Holla @ 2019-08-01 15:57 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-arm-kernel, linux-acpi, catalin.marinas, will, rjw, lenb,
	lorenzo.pieralisi, Sudeep Holla


Hi Jeremy,

On Wed, Jul 31, 2019 at 10:46:33PM -0500, Jeremy Linton wrote:
> ACPI 6.3 adds a flag to the CPU node to indicate whether
> the given PE is a thread. Add a function to return that
> information for a given linux logical CPU.
>

Apart from few minor nits,

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

> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  drivers/acpi/pptt.c  | 54 +++++++++++++++++++++++++++++++++++++++++++-
>  include/linux/acpi.h |  5 ++++
>  2 files changed, 58 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
> index 1e7ac0bd0d3a..84718f6cb741 100644
> --- a/drivers/acpi/pptt.c
> +++ b/drivers/acpi/pptt.c
> @@ -540,6 +540,44 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
>  	return retval;
>  }
>
> +/**
> + * check_acpi_cpu_flag() - Determine if CPU node has a flag set
> + * @cpu: Kernel logical CPU number
> + * @rev: The PPTT revision defining the flag

[nit] I would rather put it as minimum PPTT revision that supports the
flag. It aligns with the code too as we are not looking for exact match.

> + * @flag: The flag itself
> + *
> + * Check the node representing a CPU for a given flag.
> + *
> + * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
> + *	   the table revision isn't new enough.
> + *	   1, any passed flag set
> + *	   0, flag unset
> + */
> +static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
> +{
> +	struct acpi_table_header *table;
> +	acpi_status status;
> +	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
> +	struct acpi_pptt_processor *cpu_node = NULL;
> +	int ret = -ENOENT;
> +
> +	status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
> +	if (ACPI_FAILURE(status)) {
> +		acpi_pptt_warn_missing();
> +		return ret;
> +	}
> +
> +	if (table->revision >= rev)
> +		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
> +
> +	if (cpu_node)
> +		ret = (cpu_node->flags & flag) != 0;
> +
> +	acpi_put_table(table);
> +
> +	return ret;
> +}
> +
>  /**
>   * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
>   * @cpu: Kernel logical CPU number
> @@ -604,6 +642,21 @@ int cache_setup_acpi(unsigned int cpu)
>  	return status;
>  }
>
> +/**
> + * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread
> + * @cpu: Kernel logical CPU number
> + *

[nit] If you spin the patch again, you can drop extra line space here.

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-08-01  3:46 [PATCH v4 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
@ 2019-08-01  3:46 ` Jeremy Linton
  2019-08-01 15:57   ` Sudeep Holla
  2019-08-02 13:05   ` Robert Richter
  0 siblings, 2 replies; 15+ messages in thread
From: Jeremy Linton @ 2019-08-01  3:46 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will, rjw, lenb, lorenzo.pieralisi,
	sudeep.holla, Jeremy Linton

ACPI 6.3 adds a flag to the CPU node to indicate whether
the given PE is a thread. Add a function to return that
information for a given linux logical CPU.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 drivers/acpi/pptt.c  | 54 +++++++++++++++++++++++++++++++++++++++++++-
 include/linux/acpi.h |  5 ++++
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index 1e7ac0bd0d3a..84718f6cb741 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -540,6 +540,44 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
 	return retval;
 }
 
+/**
+ * check_acpi_cpu_flag() - Determine if CPU node has a flag set
+ * @cpu: Kernel logical CPU number
+ * @rev: The PPTT revision defining the flag
+ * @flag: The flag itself
+ *
+ * Check the node representing a CPU for a given flag.
+ *
+ * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
+ *	   the table revision isn't new enough.
+ *	   1, any passed flag set
+ *	   0, flag unset
+ */
+static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
+{
+	struct acpi_table_header *table;
+	acpi_status status;
+	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
+	struct acpi_pptt_processor *cpu_node = NULL;
+	int ret = -ENOENT;
+
+	status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
+	if (ACPI_FAILURE(status)) {
+		acpi_pptt_warn_missing();
+		return ret;
+	}
+
+	if (table->revision >= rev)
+		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
+
+	if (cpu_node)
+		ret = (cpu_node->flags & flag) != 0;
+
+	acpi_put_table(table);
+
+	return ret;
+}
+
 /**
  * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
  * @cpu: Kernel logical CPU number
@@ -604,6 +642,21 @@ int cache_setup_acpi(unsigned int cpu)
 	return status;
 }
 
+/**
+ * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread
+ * @cpu: Kernel logical CPU number
+ *
+ *
+ * Return: 1, a thread
+ *         0, not a thread
+ *         -ENOENT ,if the PPTT doesn't exist, the CPU cannot be found or
+ *         the table revision isn't new enough.
+ */
+int acpi_pptt_cpu_is_thread(unsigned int cpu)
+{
+	return check_acpi_cpu_flag(cpu, 2, ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD);
+}
+
 /**
  * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU
  * @cpu: Kernel logical CPU number
@@ -664,7 +717,6 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
 	return ret;
 }
 
-
 /**
  * find_acpi_cpu_topology_package() - Determine a unique CPU package value
  * @cpu: Kernel logical CPU number
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 9426b9aaed86..9d0e20a2ac83 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1302,11 +1302,16 @@ static inline int lpit_read_residency_count_address(u64 *address)
 #endif
 
 #ifdef CONFIG_ACPI_PPTT
+int acpi_pptt_cpu_is_thread(unsigned int cpu);
 int find_acpi_cpu_topology(unsigned int cpu, int level);
 int find_acpi_cpu_topology_package(unsigned int cpu);
 int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
 int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
 #else
+static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
+{
+	return -EINVAL;
+}
 static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
 {
 	return -EINVAL;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-08-21 13:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 20:40 [PATCH v4 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
2019-08-08 20:40 ` [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
2019-08-08 22:25   ` Robert Richter
2019-08-12  9:06     ` Rafael J. Wysocki
2019-08-12 11:59       ` Will Deacon
2019-08-20  9:01         ` John Garry
2019-08-21 13:20           ` Jeremy Linton
2019-08-21 13:25             ` John Garry
2019-08-08 20:40 ` [PATCH v4 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
2019-08-08 22:23   ` Robert Richter
  -- strict thread matches above, loose matches on Subject: below --
2019-08-01  3:46 [PATCH v4 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
2019-08-01  3:46 ` [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
2019-08-01 15:57   ` Sudeep Holla
2019-08-01 16:10     ` Jeremy Linton
2019-08-02 13:05   ` Robert Richter
2019-08-02 15:36     ` Jeremy Linton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).