From patchwork Fri Jun 28 18:14:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 168118 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4011197ilk; Fri, 28 Jun 2019 11:15:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7tnJxH2Apc5LyhjToz/DlwLRAuFPHTUcWN6S+wwYfv2sMWUwGp9sEInWLjcJQWAfDgUYd X-Received: by 2002:a17:902:22e:: with SMTP id 43mr6949589plc.272.1561745706525; Fri, 28 Jun 2019 11:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561745706; cv=none; d=google.com; s=arc-20160816; b=Vc2R5mjLs/AZqAWv2QCfOAbFIegJdom2C5geG+YbEY9nWaZYlm4hoiGXVvzQPtpLxI BiAsLNfMiZ34faDFVWyHed/sOEy4mel001FGqF2aAmq09PHMqauDxDaL1yBuhTGz6n4V /ZrBx53pD593pB/9aqZk5pu2uypzkCSdW7JCwi4dnYBrZNa2vqH+5olgpXr74/3UtlLq Yzi06kab1Y0a32kSp3tgOciZ45GqA0c9C0lnKfitkhvr7Za5zgeCDeT4yFbj2p04wwrq bfUYzMVQVb71XriQH2Evs14G443bxu6O326+OcfwTAslFSGEwSR62CSdD5wK6oue45pP nJIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=anezA1JmY0OKQcInjoS+nWeRU9ZZu5440WunqSA7LrM=; b=pOWVaeX6OVdJB/x/vDeztVxjDtw5ASZrXKkVrk2KRdBo6h0EHYu1pucZnQDxqxZSgv uhb+dbIPvWIdHCrCdVc+ZvantTQEQvUJwttWVuPPKHj10MraDy3yXfbaFm4Y/tJXL24X 9AwKRBupvcbjYRUh2CseIGgKpKEEh3CBKcTH1KL6jYGbrad8uDuoNDoCzVFftH13d/P8 IpUQiZZSv8SKZNFwl4i7Pd6yYzO9Bvh3cXBeh8tEl/Fw0zTr+JIgvBmknmTvIuDVO08d mrUErWXr2D4XqSWqtheAEShzNL0k3sByso2s/oFP/PDvQlYXpZV8FCvo70paQrl9Mt4b MwBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si3190201pfd.2.2019.06.28.11.15.06; Fri, 28 Jun 2019 11:15:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726672AbfF1SPG (ORCPT + 8 others); Fri, 28 Jun 2019 14:15:06 -0400 Received: from foss.arm.com ([217.140.110.172]:53260 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbfF1SPF (ORCPT ); Fri, 28 Jun 2019 14:15:05 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5D7812B; Fri, 28 Jun 2019 11:15:05 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.30.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 556403F718; Fri, 28 Jun 2019 11:15:05 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Jeremy Linton Subject: [PATCH v3 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Fri, 28 Jun 2019 13:14:56 -0500 Message-Id: <20190628181457.6609-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190628181457.6609-1-jeremy.linton@arm.com> References: <20190628181457.6609-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- drivers/acpi/pptt.c | 62 +++++++++++++++++++++++++++++++++++++++++++- include/linux/acpi.h | 5 ++++ 2 files changed, 66 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index b72e6afaa8fb..bb6196422fad 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -517,6 +517,52 @@ 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; + static int saved_pptt_rev = -1; + + /* Cache the PPTT revision to avoid repeat table get/put on failure */ + if (saved_pptt_rev > -1 && saved_pptt_rev < rev) + return -ENOENT; + + status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); + if (ACPI_FAILURE(status)) { + saved_pptt_rev = 0; + acpi_pptt_warn_missing(); + return ret; + } + + saved_pptt_rev = table->revision; + + if (saved_pptt_rev >= 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 @@ -581,6 +627,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 @@ -641,7 +702,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 d315d86844e4..3e339375e213 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1301,10 +1301,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; From patchwork Fri Jun 28 18:14:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 168119 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4011212ilk; Fri, 28 Jun 2019 11:15:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxox6GuPqw1CvGLSJT3gfbnHTx/JIaiSMfg+f6WK95l/jUEEy9PjXTTr3xz91JEtrJdto4S X-Received: by 2002:a17:90a:9b08:: with SMTP id f8mr14906373pjp.103.1561745707587; Fri, 28 Jun 2019 11:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561745707; cv=none; d=google.com; s=arc-20160816; b=KQEIRBGutddnbo9Z/nFjnMkqn731Fs1urDm6yhyceEL0SltEkXFKGBicLnWFV0f3rk pqHGH4i3JHcdQ+TAOPk5Jwqfn0Jd0rDhR3fQjDjztdLp+nRz/x1DpAVubGmWV1sS93Wd P/FXVkiBTnxRwFOnKMZV+hSkXQAEY4g2du++Hb3DffT+YpvI5EtF1hyC+aCrABvLBoKQ D+7JuBw91x9EhAKeSzMY78qU3NXr90UqtJqHD04Bd7dsv2VJBX9UB4ynB/MsXsp2jbPN Nr34pLaBmOpwg4JYF655dJ2vrTlvpfRxIlUNM4YClynUeJVZVsMReCFBO+wbnjScc6lx O48g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=o7YcmtidsCQoep7qv5xOU12ScfxzO8HXPxAmyprhlXw=; b=guo1chlOfaLIAYC8qjZjFJj+Ljn4tJT4UKn53G3XAZaZR66pH4283siZ9F+JuqTY+a oq/wAu27HLAwaLuyT6MMIhTnfnfd5QHxtIfCxL+1Xq3NBzRKib1dlemmrSXCllmLz8E0 kOT5AFPRsenObEWjXce5/XoLcQwRLf7HCbnM5vwLJYew2LOrGsAza/xpxgjj6+OrJ5P2 +tSWyaC9vLfW2yRAdeJUn2lyb6v3fjxhKYbC4hHNDoSOpcAZV5ihGP/5cScWhJCOfXg7 y9SQTTZmfQIyomznOKVM+2w3sFkKhR0uOLB6srDsgFYlTj9xPWplj5slpPvbPxPCauY5 5Wjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si3190201pfd.2.2019.06.28.11.15.07; Fri, 28 Jun 2019 11:15:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726408AbfF1SPH (ORCPT + 8 others); Fri, 28 Jun 2019 14:15:07 -0400 Received: from foss.arm.com ([217.140.110.172]:53272 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726056AbfF1SPG (ORCPT ); Fri, 28 Jun 2019 14:15:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 694ACEBD; Fri, 28 Jun 2019 11:15:06 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.30.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 593263F718; Fri, 28 Jun 2019 11:15:06 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Jeremy Linton Subject: [PATCH v3 2/2] arm64: topology: Use PPTT to determine if PE is a thread Date: Fri, 28 Jun 2019 13:14:57 -0500 Message-Id: <20190628181457.6609-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190628181457.6609-1-jeremy.linton@arm.com> References: <20190628181457.6609-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- arch/arm64/kernel/topology.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.21.0 diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 0825c4a856e3..cbbedb53cf06 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -346,11 +346,9 @@ void remove_cpu_topology(unsigned int cpu) */ static int __init parse_acpi_topology(void) { - bool is_threaded; + int is_threaded; int cpu, topology_id; - is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; - for_each_possible_cpu(cpu) { int i, cache_id; @@ -358,6 +356,10 @@ static int __init parse_acpi_topology(void) if (topology_id < 0) return topology_id; + is_threaded = acpi_pptt_cpu_is_thread(cpu); + if (is_threaded < 0) + is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; + if (is_threaded) { cpu_topology[cpu].thread_id = topology_id; topology_id = find_acpi_cpu_topology(cpu, 1);