diff mbox series

[for-stable-5.3,1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag

Message ID 1571054162-71090-2-git-send-email-john.garry@huawei.com (mailing list archive)
State New, archived
Headers show
Series ACPI, arm64: Backport for ACPI PPTT 6.3 thread flag | expand

Commit Message

John Garry Oct. 14, 2019, 11:56 a.m. UTC
From: Jeremy Linton <jeremy.linton@arm.com>

Commit bbd1b70639f785a970d998f35155c713f975e3ac upstream.

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>
Reviewed-by: Robert Richter <rrichter@marvell.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/acpi/pptt.c  | 52 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/acpi.h |  5 +++++
 2 files changed, 57 insertions(+)

Comments

Sasha Levin Oct. 14, 2019, 11:29 p.m. UTC | #1
On Mon, Oct 14, 2019 at 07:56:01PM +0800, John Garry wrote:
>From: Jeremy Linton <jeremy.linton@arm.com>
>
>Commit bbd1b70639f785a970d998f35155c713f975e3ac upstream.
>
>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>
>Reviewed-by: Robert Richter <rrichter@marvell.com>
>Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>Signed-off-by: Will Deacon <will@kernel.org>
>Signed-off-by: John Garry <john.garry@huawei.com>

How far back should these patches be backported?
John Garry Oct. 15, 2019, 8:16 a.m. UTC | #2
On 15/10/2019 00:29, Sasha Levin wrote:
> On Mon, Oct 14, 2019 at 07:56:01PM +0800, John Garry wrote:
>> From: Jeremy Linton <jeremy.linton@arm.com>
>>
>> Commit bbd1b70639f785a970d998f35155c713f975e3ac upstream.
>>
>> 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>
>> Reviewed-by: Robert Richter <rrichter@marvell.com>
>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> Signed-off-by: Will Deacon <will@kernel.org>
>> Signed-off-by: John Garry <john.garry@huawei.com>
>
> How far back should these patches be backported?
>

Hi Sasha,

This patchset is for 5.3, and I sent a separate patchset for 4.19, since 
the backport is a little different and required some hand modification - 
 
https://lore.kernel.org/linux-arm-kernel/1571046986-231263-1-git-send-email-john.garry@huawei.com/. 
4.19 is as far back as we want.

Please note that the patches in this 5.3 series are relevant for 5.2 
also, but since 5.2 is EOL, I didn't mention it. We did test 5.2, so you 
can add there also.

Please let me know if any more questions.

All the best,
John
Sasha Levin Oct. 15, 2019, 10:04 p.m. UTC | #3
On Tue, Oct 15, 2019 at 09:16:13AM +0100, John Garry wrote:
>On 15/10/2019 00:29, Sasha Levin wrote:
>>On Mon, Oct 14, 2019 at 07:56:01PM +0800, John Garry wrote:
>>>From: Jeremy Linton <jeremy.linton@arm.com>
>>>
>>>Commit bbd1b70639f785a970d998f35155c713f975e3ac upstream.
>>>
>>>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>
>>>Reviewed-by: Robert Richter <rrichter@marvell.com>
>>>Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>Signed-off-by: Will Deacon <will@kernel.org>
>>>Signed-off-by: John Garry <john.garry@huawei.com>
>>
>>How far back should these patches be backported?
>>
>
>Hi Sasha,
>
>This patchset is for 5.3, and I sent a separate patchset for 4.19, 
>since the backport is a little different and required some hand 
>modification -
>
>https://lore.kernel.org/linux-arm-kernel/1571046986-231263-1-git-send-email-john.garry@huawei.com/. 
>4.19 is as far back as we want.
>
>Please note that the patches in this 5.3 series are relevant for 5.2 
>also, but since 5.2 is EOL, I didn't mention it. We did test 5.2, so 
>you can add there also.
>
>Please let me know if any more questions.

I've queued this and the 4.19 patches, thanks!
diff mbox series

Patch

diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index 1e7ac0bd0d3a..9497298018a9 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
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;