From: John Garry <john.garry@huawei•com>
To: <catalin.marinas@arm•com>, <will@kernel•org>, <rjw@rjwysocki•net>,
<lenb@kernel•org>, <robert.moore@intel•com>,
<erik.schmauss@intel•com>, <sudeep.holla@arm•com>,
<rrichter@marvell•com>, <jeremy.linton@arm•com>
Cc: gregkh@linuxfoundation•org, John Garry <john.garry@huawei•com>,
linux-kernel@vger•kernel.org, linuxarm@huawei•com,
linux-acpi@vger•kernel.org, wanghuiqiang@huawei•com,
guohanjun@huawei•com, linux-arm-kernel@lists•infradead.org
Subject: [RFC PATCH 2/3] ACPI/PPTT: Add support for ACPI 6.3 thread flag
Date: Thu, 10 Oct 2019 21:29:51 +0800 [thread overview]
Message-ID: <1570714192-236724-3-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1570714192-236724-1-git-send-email-john.garry@huawei.com>
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>
[jpg: backport for 4.19, replace acpi_pptt_warn_missing()]
Signed-off-by: John Garry <john.garry@huawei•com>
---
drivers/acpi/pptt.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
include/linux/acpi.h | 5 +++++
2 files changed, 57 insertions(+)
diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index da031b1df6f5..9dbf86a0c827 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -509,6 +509,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)) {
+ pr_warn_once("No PPTT table found, cpu topology may be inaccurate\n");
+ 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
@@ -573,6 +611,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 b4d23b3a2ef2..59a416dfcaaa 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1291,10 +1291,15 @@ 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_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.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-10 13:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 13:29 [RFC PATCH 0/3] ACPI, arm64: Backport for ACPI PPTT 6.3 thread flag for stable 4.19.x John Garry
2019-10-10 13:29 ` [RFC PATCH 1/3] ACPICA: ACPI 6.3: PPTT add additional fields in Processor Structure Flags John Garry
2019-10-10 14:22 ` Moore, Robert
2019-10-10 14:28 ` John Garry
2019-10-10 13:29 ` John Garry [this message]
2019-10-10 13:29 ` [RFC PATCH 3/3] arm64: topology: Use PPTT to determine if PE is a thread John Garry
2019-10-11 0:53 ` [RFC PATCH 0/3] ACPI, arm64: Backport for ACPI PPTT 6.3 thread flag for stable 4.19.x Hanjun Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1570714192-236724-3-git-send-email-john.garry@huawei.com \
--to=john.garry@huawei$(echo .)com \
--cc=catalin.marinas@arm$(echo .)com \
--cc=erik.schmauss@intel$(echo .)com \
--cc=gregkh@linuxfoundation$(echo .)org \
--cc=guohanjun@huawei$(echo .)com \
--cc=jeremy.linton@arm$(echo .)com \
--cc=lenb@kernel$(echo .)org \
--cc=linux-acpi@vger$(echo .)kernel.org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxarm@huawei$(echo .)com \
--cc=rjw@rjwysocki$(echo .)net \
--cc=robert.moore@intel$(echo .)com \
--cc=rrichter@marvell$(echo .)com \
--cc=sudeep.holla@arm$(echo .)com \
--cc=wanghuiqiang@huawei$(echo .)com \
--cc=will@kernel$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox