diff mbox series

[v4,1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag

Message ID 20190808204007.30110-2-jeremy.linton@arm.com
State Accepted
Commit bbd1b70639f785a970d998f35155c713f975e3ac
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 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(-)

-- 
2.21.0

Comments

Robert Richter Aug. 8, 2019, 10:25 p.m. UTC | #1
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>
Rafael J. Wysocki Aug. 12, 2019, 9:06 a.m. UTC | #2
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.
Will Deacon Aug. 12, 2019, 11:59 a.m. UTC | #3
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
John Garry Aug. 20, 2019, 9:01 a.m. UTC | #4
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

>

>
Jeremy Linton Aug. 21, 2019, 1:20 p.m. UTC | #5
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,
John Garry Aug. 21, 2019, 1:25 p.m. UTC | #6
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,

>

> .

>
diff mbox series

Patch

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;