From patchwork Wed Apr 25 23:31:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 134397 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1534831lji; Wed, 25 Apr 2018 17:29:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx49onUwpPfJUheUTAFZkdVsr6T+W7PUHraB6ASBSQRdewq+fpNC1HIQS2+nsmROHkRf6B9+1 X-Received: by 2002:a17:902:41:: with SMTP id 59-v6mr31589939pla.345.1524702543673; Wed, 25 Apr 2018 17:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702543; cv=none; d=google.com; s=arc-20160816; b=nY8eXI7OWwdicuXeZq0xU9l65mRxfH4nC2T1rS9CmDGg/eDgqsjH7ZYOYk7JMI89Tw F5lX6BmLy7UUb79LmgCrUj+VgY/TX+HO9A6vFGIQEWh8EI+UE//3p3Pcm90+L38mpk55 QYAN+5kHyEbzsaMhx9PkdmkM+5tn5gEm3vJGPvz3ZGJzozsIxs3FHqtN2woDipVF9/rc oKOPNeFptO5cX7V2JRMN2VO+FdCcp6xw6aYxmB1ZzaqvSh7pKJRdHSo6zZ1jTmBDsbVk T8KHVqQO+norMzzmm5HG4H40sz8bBTGhO1iBYaxqUaAqp78AFmqoKaWa70lOOrtJ1FFE rGmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=QfvjFF+qDr64GIH2Y+rBZ0l2OScW6o++BReMvLKvZnU=; b=mH35seynDTeQ5pLZ7oCn3QxdKlqfu8fHRyQ4Uu3J+gZHCIulroc8ILQS5pqc2VfpBU cgOHkIBXiNBmn6wBpYVU2C8Y1kVuB6Dtf0B0qGZxhc+U8YFjtnpOWDXR20JYzGs3jTjl S67P0JaQx0c5XWlVG8tpm7k3wdPQGTRbcQM45PYNVWuXf+tCLkbtWdrFeJDbWszLfF1k Rd2ZrZUqbK5kwBYLsgZuJHVE3nsGzd4WS4tHQeqUIBCK7nWaZeBxNyaehCPoE8gANlVE f90pCq/l86kawnMEZyGX9A2OPVqmQbYX4T0coFToroiHsZ13vQvg19F4FiYhw/eZBZQ0 dmrg== 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 p66si1943118pga.180.2018.04.25.17.29.03; Wed, 25 Apr 2018 17:29:03 -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 S1752845AbeDZA3C (ORCPT + 8 others); Wed, 25 Apr 2018 20:29:02 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45592 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbeDZA0I (ORCPT ); Wed, 25 Apr 2018 20:26:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3F1FF15AD; Wed, 25 Apr 2018 17:26:08 -0700 (PDT) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2CBD13F590; Wed, 25 Apr 2018 17:26:07 -0700 (PDT) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: Sudeep.Holla@arm.com, linux-arm-kernel@lists.infradead.org, Lorenzo.Pieralisi@arm.com, hanjun.guo@linaro.org, rjw@rjwysocki.net, Will.Deacon@arm.com, Catalin.Marinas@arm.com, gregkh@linuxfoundation.org, Mark.Rutland@arm.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, wangxiongfeng2@huawei.com, vkilari@codeaurora.org, ahs3@redhat.com, Dietmar.Eggemann@arm.com, Morten.Rasmussen@arm.com, palmer@sifive.com, lenb@kernel.org, john.garry@huawei.com, austinwc@codeaurora.org, tnowicki@caviumnetworks.com, jhugo@qti.qualcomm.com, timur@qti.qualcomm.com, ard.biesheuvel@linaro.org, Jeremy Linton Subject: [PATCH v8 01/13] drivers: base: cacheinfo: move cache_setup_of_node() Date: Wed, 25 Apr 2018 18:31:09 -0500 Message-Id: <20180425233121.13270-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180425233121.13270-1-jeremy.linton@arm.com> References: <20180425233121.13270-1-jeremy.linton@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In preparation for the next patch, and to aid in review of that patch, lets move cache_setup_of_node further down in the module without any changes. Signed-off-by: Jeremy Linton Reviewed-by: Sudeep Holla --- drivers/base/cacheinfo.c | 80 ++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index edf726267282..09ccef7ddc99 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -32,46 +32,6 @@ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) } #ifdef CONFIG_OF -static int cache_setup_of_node(unsigned int cpu) -{ - struct device_node *np; - struct cacheinfo *this_leaf; - struct device *cpu_dev = get_cpu_device(cpu); - struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); - unsigned int index = 0; - - /* skip if of_node is already populated */ - if (this_cpu_ci->info_list->of_node) - return 0; - - if (!cpu_dev) { - pr_err("No cpu device for CPU %d\n", cpu); - return -ENODEV; - } - np = cpu_dev->of_node; - if (!np) { - pr_err("Failed to find cpu%d device node\n", cpu); - return -ENOENT; - } - - while (index < cache_leaves(cpu)) { - this_leaf = this_cpu_ci->info_list + index; - if (this_leaf->level != 1) - np = of_find_next_cache_node(np); - else - np = of_node_get(np);/* cpu node itself */ - if (!np) - break; - this_leaf->of_node = np; - index++; - } - - if (index != cache_leaves(cpu)) /* not all OF nodes populated */ - return -ENOENT; - - return 0; -} - static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, struct cacheinfo *sib_leaf) { @@ -202,6 +162,46 @@ static void cache_of_override_properties(unsigned int cpu) cache_associativity(this_leaf); } } + +static int cache_setup_of_node(unsigned int cpu) +{ + struct device_node *np; + struct cacheinfo *this_leaf; + struct device *cpu_dev = get_cpu_device(cpu); + struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); + unsigned int index = 0; + + /* skip if of_node is already populated */ + if (this_cpu_ci->info_list->of_node) + return 0; + + if (!cpu_dev) { + pr_err("No cpu device for CPU %d\n", cpu); + return -ENODEV; + } + np = cpu_dev->of_node; + if (!np) { + pr_err("Failed to find cpu%d device node\n", cpu); + return -ENOENT; + } + + while (index < cache_leaves(cpu)) { + this_leaf = this_cpu_ci->info_list + index; + if (this_leaf->level != 1) + np = of_find_next_cache_node(np); + else + np = of_node_get(np);/* cpu node itself */ + if (!np) + break; + this_leaf->of_node = np; + index++; + } + + if (index != cache_leaves(cpu)) /* not all OF nodes populated */ + return -ENOENT; + + return 0; +} #else static void cache_of_override_properties(unsigned int cpu) { } static inline int cache_setup_of_node(unsigned int cpu) { return 0; } From patchwork Wed Apr 25 23:31:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 134385 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1532549lji; Wed, 25 Apr 2018 17:26:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx49CTomU810ASg+dx6hhFQ4T9hFbekR5A3P0/+T03WyBvpbRuZghKWwoK+oK4pdLNnY7Y3Bs X-Received: by 2002:a17:902:968d:: with SMTP id n13-v6mr30252951plp.168.1524702376935; Wed, 25 Apr 2018 17:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702376; cv=none; d=google.com; s=arc-20160816; b=NZ/4oMlubfYXQwdxK+bcFiVCJQrOjlJFOznG3wEeUCRvaTtHalb1uWpvmdGjsVtvbT v6xQbtjfkw9KBzFo2t5MQlrQdyARh0+Blj0natvqa4gIoRiia25BKWgwfWwcNAxAkD+6 8pbXLtsF5C1Iddi4noXONwe3XpYXsOYr21JKkul1YS2V0kmhBfaUamBImS4b200sDjZT pse1YuwhX4lhqE+OJLdzl54+itEj7GdAKJwOkHDFdMwETRI0LHNJgzZ/cNu2/KU8b+5U ntkfrP0b1gTcd1wmneKVDGkfdmiV1ugUAKFMpqaL/Rn2tT0aHR1vV4gSZYi5EJpr3/db +RfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=EZMPUAhdLK0nqq6spLNSHkKz57vnQLNEzXCDevMfLfQ=; b=utbq8M7zWQ0AVPzyZVPF+JS5R+qIvJiuYCbLK9IlCfYbif8tJEY7T6elrw2rOkINHc jh4TVkBu6VPc5e5AXAd6Bf/P7LUaShaW6xq8wKqsCS2+T1UWUUwOCB81jUAqpGyCNui8 U9Ch3NNH1y2bVqBVIGVkZ0r0ochyqEIR1G11EbiK/KNGD5zf2urW+UG48ubD2uTYSGhU sH5VTaBGUrfEkKoFEGdyTa0lfHigkKDgrTMLw2nx7f62L87cYDmakBpNXQs9xpxKnUu7 CGxIU6d9PBx7EBj9nH7t/XFJAywVH5dpgmWnCtrMrPaZS0gpIVEIDV1rE4xhMWF8qUW2 AmzA== 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 126si17229757pfg.40.2018.04.25.17.26.16; Wed, 25 Apr 2018 17:26:16 -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 S1751651AbeDZA0N (ORCPT + 8 others); Wed, 25 Apr 2018 20:26:13 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45602 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949AbeDZA0K (ORCPT ); Wed, 25 Apr 2018 20:26:10 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE811165D; Wed, 25 Apr 2018 17:26:09 -0700 (PDT) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CC1A03F590; Wed, 25 Apr 2018 17:26:08 -0700 (PDT) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: Sudeep.Holla@arm.com, linux-arm-kernel@lists.infradead.org, Lorenzo.Pieralisi@arm.com, hanjun.guo@linaro.org, rjw@rjwysocki.net, Will.Deacon@arm.com, Catalin.Marinas@arm.com, gregkh@linuxfoundation.org, Mark.Rutland@arm.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, wangxiongfeng2@huawei.com, vkilari@codeaurora.org, ahs3@redhat.com, Dietmar.Eggemann@arm.com, Morten.Rasmussen@arm.com, palmer@sifive.com, lenb@kernel.org, john.garry@huawei.com, austinwc@codeaurora.org, tnowicki@caviumnetworks.com, jhugo@qti.qualcomm.com, timur@qti.qualcomm.com, ard.biesheuvel@linaro.org, Jeremy Linton Subject: [PATCH v8 02/13] drivers: base: cacheinfo: setup DT cache properties early Date: Wed, 25 Apr 2018 18:31:10 -0500 Message-Id: <20180425233121.13270-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180425233121.13270-1-jeremy.linton@arm.com> References: <20180425233121.13270-1-jeremy.linton@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The original intent in cacheinfo was that an architecture specific populate_cache_leaves() would probe the hardware and then cache_shared_cpu_map_setup() and cache_override_properties() would provide firmware help to extend/expand upon what was probed. Arm64 was really the only architecture that was working this way, and with the removal of most of the hardware probing logic it became clear that it was possible to simplify the logic a bit. This patch combines the walk of the DT nodes with the code updating the cache size/line_size and nr_sets. cache_override_properties() (which was DT specific) is then removed. The result is that cacheinfo.of_node is no longer used as a temporary place to hold DT references for future calls that update cache properties. That change helps to clarify its one remaining use (matching cacheinfo nodes that represent shared caches) which will be used by the ACPI/PPTT code in the following patches. Signed-off-by: Jeremy Linton Acked-by: Sudeep Holla --- arch/riscv/kernel/cacheinfo.c | 1 - drivers/base/cacheinfo.c | 65 +++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 37 deletions(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c index 10ed2749e246..0bc86e5f8f3f 100644 --- a/arch/riscv/kernel/cacheinfo.c +++ b/arch/riscv/kernel/cacheinfo.c @@ -20,7 +20,6 @@ static void ci_leaf_init(struct cacheinfo *this_leaf, struct device_node *node, enum cache_type type, unsigned int level) { - this_leaf->of_node = node; this_leaf->level = level; this_leaf->type = type; /* not a sector cache */ diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 09ccef7ddc99..a872523e8951 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -71,7 +71,7 @@ static inline int get_cacheinfo_idx(enum cache_type type) return type; } -static void cache_size(struct cacheinfo *this_leaf) +static void cache_size(struct cacheinfo *this_leaf, struct device_node *np) { const char *propname; const __be32 *cache_size; @@ -80,13 +80,14 @@ static void cache_size(struct cacheinfo *this_leaf) ct_idx = get_cacheinfo_idx(this_leaf->type); propname = cache_type_info[ct_idx].size_prop; - cache_size = of_get_property(this_leaf->of_node, propname, NULL); + cache_size = of_get_property(np, propname, NULL); if (cache_size) this_leaf->size = of_read_number(cache_size, 1); } /* not cache_line_size() because that's a macro in include/linux/cache.h */ -static void cache_get_line_size(struct cacheinfo *this_leaf) +static void cache_get_line_size(struct cacheinfo *this_leaf, + struct device_node *np) { const __be32 *line_size; int i, lim, ct_idx; @@ -98,7 +99,7 @@ static void cache_get_line_size(struct cacheinfo *this_leaf) const char *propname; propname = cache_type_info[ct_idx].line_size_props[i]; - line_size = of_get_property(this_leaf->of_node, propname, NULL); + line_size = of_get_property(np, propname, NULL); if (line_size) break; } @@ -107,7 +108,7 @@ static void cache_get_line_size(struct cacheinfo *this_leaf) this_leaf->coherency_line_size = of_read_number(line_size, 1); } -static void cache_nr_sets(struct cacheinfo *this_leaf) +static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np) { const char *propname; const __be32 *nr_sets; @@ -116,7 +117,7 @@ static void cache_nr_sets(struct cacheinfo *this_leaf) ct_idx = get_cacheinfo_idx(this_leaf->type); propname = cache_type_info[ct_idx].nr_sets_prop; - nr_sets = of_get_property(this_leaf->of_node, propname, NULL); + nr_sets = of_get_property(np, propname, NULL); if (nr_sets) this_leaf->number_of_sets = of_read_number(nr_sets, 1); } @@ -135,32 +136,27 @@ static void cache_associativity(struct cacheinfo *this_leaf) this_leaf->ways_of_associativity = (size / nr_sets) / line_size; } -static bool cache_node_is_unified(struct cacheinfo *this_leaf) +static bool cache_node_is_unified(struct cacheinfo *this_leaf, + struct device_node *np) { - return of_property_read_bool(this_leaf->of_node, "cache-unified"); + return of_property_read_bool(np, "cache-unified"); } -static void cache_of_override_properties(unsigned int cpu) +static void cache_of_set_props(struct cacheinfo *this_leaf, + struct device_node *np) { - int index; - struct cacheinfo *this_leaf; - struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); - - for (index = 0; index < cache_leaves(cpu); index++) { - this_leaf = this_cpu_ci->info_list + index; - /* - * init_cache_level must setup the cache level correctly - * overriding the architecturally specified levels, so - * if type is NONE at this stage, it should be unified - */ - if (this_leaf->type == CACHE_TYPE_NOCACHE && - cache_node_is_unified(this_leaf)) - this_leaf->type = CACHE_TYPE_UNIFIED; - cache_size(this_leaf); - cache_get_line_size(this_leaf); - cache_nr_sets(this_leaf); - cache_associativity(this_leaf); - } + /* + * init_cache_level must setup the cache level correctly + * overriding the architecturally specified levels, so + * if type is NONE at this stage, it should be unified + */ + if (this_leaf->type == CACHE_TYPE_NOCACHE && + cache_node_is_unified(this_leaf, np)) + this_leaf->type = CACHE_TYPE_UNIFIED; + cache_size(this_leaf, np); + cache_get_line_size(this_leaf, np); + cache_nr_sets(this_leaf, np); + cache_associativity(this_leaf); } static int cache_setup_of_node(unsigned int cpu) @@ -193,6 +189,7 @@ static int cache_setup_of_node(unsigned int cpu) np = of_node_get(np);/* cpu node itself */ if (!np) break; + cache_of_set_props(this_leaf, np); this_leaf->of_node = np; index++; } @@ -203,7 +200,6 @@ static int cache_setup_of_node(unsigned int cpu) return 0; } #else -static void cache_of_override_properties(unsigned int cpu) { } static inline int cache_setup_of_node(unsigned int cpu) { return 0; } static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, struct cacheinfo *sib_leaf) @@ -286,12 +282,6 @@ static void cache_shared_cpu_map_remove(unsigned int cpu) } } -static void cache_override_properties(unsigned int cpu) -{ - if (of_have_populated_dt()) - return cache_of_override_properties(cpu); -} - static void free_cache_attributes(unsigned int cpu) { if (!per_cpu_cacheinfo(cpu)) @@ -325,6 +315,10 @@ static int detect_cache_attributes(unsigned int cpu) if (per_cpu_cacheinfo(cpu) == NULL) return -ENOMEM; + /* + * populate_cache_leaves() may completely setup the cache leaves and + * shared_cpu_map or it may leave it partially setup. + */ ret = populate_cache_leaves(cpu); if (ret) goto free_ci; @@ -338,7 +332,6 @@ static int detect_cache_attributes(unsigned int cpu) goto free_ci; } - cache_override_properties(cpu); return 0; free_ci: From patchwork Wed Apr 25 23:31:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 134392 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1533738lji; Wed, 25 Apr 2018 17:27:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx48LYnaUgEUp+XqqMDRIIiAFDJnoWj+6+vCeXBkpA9gJTrpCC6ZZ2ygzecH7hLxfw0+971Ei X-Received: by 10.99.112.82 with SMTP id a18mr16099429pgn.148.1524702464067; Wed, 25 Apr 2018 17:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702464; cv=none; d=google.com; s=arc-20160816; b=EtH5GHOlLt6qYClnLxoLU+6w8INSY4tSGftfXzm9Xv3cpFbtqdN959Le/pWlPS3RLJ 7oXw3PBtP+WPJ1Nh6sTKtazoCX63VRTuwKseiU0SNteZ/asmf+dC3eW1P/jr2SERICvf N6DGk17NmmYPpHbOhAcM+FPNQNBzf5wjhExrJZ0NVhbzDkJYh4E+lx/LU7nfa8Gf7hUq teH0/6zUX+WP2Dz11lbjY0vMf954/spZTGVW8xxlsGNc8Ue1mfvyBbVZeQRQdcfIKwaU VI9QK0gQ2NITs24SJ9Ghgv4VnR4cYFkPQ0+dO4DTXkRXziVXYfD2HOIXYam50x2ccIjG Xqtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=hRCH07Tia6cSKL/uBOGB2Bx/SQECD88z/H8KGgvwwC8=; b=IuQuLWACcclTixLKvS8d7lwWUFfUh+9ZgLlT3j5cWPBJkNhMtnT22v0cVHGrVE0g6H jzkQVwdLAf5hqwKOklhxHGWgHBeuEp2ndQ3I+1Tpq0T9m3jkqvkIYrmC+pN7IrELWHLE 33SYjv7qCOm4tanKL+cnVIX9rbflqp8hjqfNauauAXfNHrtTnXD12JJNgeP0hDnn/1rH Fmthk53LEhoXpiF6fMHZemHSjEfK1nZePBnTbuWo8+5gLpylSX6UP0Vycz9S2hjlNebs 7+0KHHLq/P+oXCa+Suyi6VhRNdsroVuaSROSUHLgGtwnR6NeNDupqrqOeEN0hCGI1vKy xT8A== 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 87si13171051pfo.137.2018.04.25.17.27.43; Wed, 25 Apr 2018 17:27:44 -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 S1751574AbeDZA1m (ORCPT + 8 others); Wed, 25 Apr 2018 20:27:42 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45750 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751913AbeDZA0U (ORCPT ); Wed, 25 Apr 2018 20:26:20 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A001D16EA; Wed, 25 Apr 2018 17:26:19 -0700 (PDT) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8D97F3F590; Wed, 25 Apr 2018 17:26:18 -0700 (PDT) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: Sudeep.Holla@arm.com, linux-arm-kernel@lists.infradead.org, Lorenzo.Pieralisi@arm.com, hanjun.guo@linaro.org, rjw@rjwysocki.net, Will.Deacon@arm.com, Catalin.Marinas@arm.com, gregkh@linuxfoundation.org, Mark.Rutland@arm.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, wangxiongfeng2@huawei.com, vkilari@codeaurora.org, ahs3@redhat.com, Dietmar.Eggemann@arm.com, Morten.Rasmussen@arm.com, palmer@sifive.com, lenb@kernel.org, john.garry@huawei.com, austinwc@codeaurora.org, tnowicki@caviumnetworks.com, jhugo@qti.qualcomm.com, timur@qti.qualcomm.com, ard.biesheuvel@linaro.org, Jeremy Linton Subject: [PATCH v8 08/13] arm64: Add support for ACPI based firmware tables Date: Wed, 25 Apr 2018 18:31:16 -0500 Message-Id: <20180425233121.13270-9-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180425233121.13270-1-jeremy.linton@arm.com> References: <20180425233121.13270-1-jeremy.linton@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The /sys cache entries should support ACPI/PPTT generated cache topology information. Lets detect ACPI systems and call an arch specific cache_setup_acpi() routine to update the hardware probed cache topology. For arm64, if ACPI is enabled, determine the max number of cache levels and populate them using the PPTT table if one is available. Signed-off-by: Jeremy Linton Reviewed-by: Sudeep Holla --- arch/arm64/kernel/cacheinfo.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c index 380f2e2fbed5..0bf0a835122f 100644 --- a/arch/arm64/kernel/cacheinfo.c +++ b/arch/arm64/kernel/cacheinfo.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -46,7 +47,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf, static int __init_cache_level(unsigned int cpu) { - unsigned int ctype, level, leaves, of_level; + unsigned int ctype, level, leaves, fw_level; struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) { @@ -59,15 +60,19 @@ static int __init_cache_level(unsigned int cpu) leaves += (ctype == CACHE_TYPE_SEPARATE) ? 2 : 1; } - of_level = of_find_last_cache_level(cpu); - if (level < of_level) { + if (acpi_disabled) + fw_level = of_find_last_cache_level(cpu); + else + fw_level = acpi_find_last_cache_level(cpu); + + if (level < fw_level) { /* * some external caches not specified in CLIDR_EL1 * the information may be available in the device tree * only unified external caches are considered here */ - leaves += (of_level - level); - level = of_level; + leaves += (fw_level - level); + level = fw_level; } this_cpu_ci->num_levels = level; From patchwork Wed Apr 25 23:31:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 134387 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1532759lji; Wed, 25 Apr 2018 17:26:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx49M0VVNp/Agrxtzn29JeLvwYFpeG6jSd/lL8854m+eqwaofqSWZ47RWbNo6QS7X97An0hoJ X-Received: by 2002:a17:902:3281:: with SMTP id z1-v6mr30841219plb.226.1524702389960; Wed, 25 Apr 2018 17:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702389; cv=none; d=google.com; s=arc-20160816; b=lU3vse/+0CUJ0SE23LBv9TkPmdrujgBvJ+GsOofseou4HAOF/DjfpkSA3F7D646TaA M8/QOQOpLAPh5+2zHrZfH7iPswEFrvmKGMuF54+4wZiA/+cTK3UOCoqptoNF4t7BYodQ d0cFBEx7Al4nAbXC+bRkpVyXmMGF/oX2OcAhMq9FKIHq5YnhoB4UXobQDxvh2tavMSho t93VaBFzKeOv28qZeb0oitIuBnHuHCn3OJE7o8t/ywBF74CwSlxvl2OSZQUqcYTnVMcL Ja1eCDV+lhH6f+LaOFAr1gQ1YqtkPKyO7NWBYamqeYb5flC9AECcPi+VJcassjdINEyn hlCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=we+DCSIkVL77lYGBkGOHtvjuADfLSoWVmu8RepQwgzc=; b=jz+/nB0Jc/AW/cZ7LkYzUT5yW6I6lvcplPTJIrDFCbAsREhODLrJwRKDJdStkm7ncf E12kqZPcL3TAGwgOHemQ+LDD7DMSgM0HlDsvT+qFNqwc8bPaGjbHD1J7mWrhVb5Qu4ny URDUHBU1RLtx3Z23MKn7IkYWW36G4LRb15qp8aC8TYnpths/5Np3mkVuKu9ydxk0YYoT J9FweLG3eGbLbFekMzP1R5EjhdIC5K4ceIaWOgAY8ZdVZB8n9eSByWjMYkbGlfwzh6tE WX8fyPQ7e0jHPPNPjTc65aZloBdAc5c1TDOQF0BUh/eWb8VBycbYzBS36Wh4eIFUqcdA a0eg== 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 l4si13233937pgn.54.2018.04.25.17.26.29; Wed, 25 Apr 2018 17:26:29 -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 S1752135AbeDZA02 (ORCPT + 8 others); Wed, 25 Apr 2018 20:26:28 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45836 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752079AbeDZA0Y (ORCPT ); Wed, 25 Apr 2018 20:26:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 757F880D; Wed, 25 Apr 2018 17:26:24 -0700 (PDT) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 624D63F590; Wed, 25 Apr 2018 17:26:23 -0700 (PDT) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: Sudeep.Holla@arm.com, linux-arm-kernel@lists.infradead.org, Lorenzo.Pieralisi@arm.com, hanjun.guo@linaro.org, rjw@rjwysocki.net, Will.Deacon@arm.com, Catalin.Marinas@arm.com, gregkh@linuxfoundation.org, Mark.Rutland@arm.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, wangxiongfeng2@huawei.com, vkilari@codeaurora.org, ahs3@redhat.com, Dietmar.Eggemann@arm.com, Morten.Rasmussen@arm.com, palmer@sifive.com, lenb@kernel.org, john.garry@huawei.com, austinwc@codeaurora.org, tnowicki@caviumnetworks.com, jhugo@qti.qualcomm.com, timur@qti.qualcomm.com, ard.biesheuvel@linaro.org, Jeremy Linton Subject: [PATCH v8 11/13] arm64: topology: enable ACPI/PPTT based CPU topology Date: Wed, 25 Apr 2018 18:31:19 -0500 Message-Id: <20180425233121.13270-12-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180425233121.13270-1-jeremy.linton@arm.com> References: <20180425233121.13270-1-jeremy.linton@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Propagate the topology information from the PPTT tree to the cpu_topology array. We can get the thread id and core_id by assuming certain levels of the PPTT tree correspond to those concepts. The package_id is flagged in the tree and can be found by calling find_acpi_cpu_topology_package() which terminates its search when it finds an ACPI node flagged as the physical package. If the tree doesn't contain enough levels to represent all of the requested levels then the root node will be returned for all subsequent levels. Signed-off-by: Jeremy Linton --- arch/arm64/kernel/topology.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Morten Rasmussen diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index dc18b1e53194..bd1aae438a31 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -11,6 +11,7 @@ * for more details. */ +#include #include #include #include @@ -22,6 +23,7 @@ #include #include #include +#include #include #include @@ -296,6 +298,45 @@ static void __init reset_cpu_topology(void) } } +#ifdef CONFIG_ACPI +/* + * 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) { + topology_id = find_acpi_cpu_topology(cpu, 0); + if (topology_id < 0) + return topology_id; + + if (is_threaded) { + cpu_topology[cpu].thread_id = topology_id; + topology_id = find_acpi_cpu_topology(cpu, 1); + cpu_topology[cpu].core_id = topology_id; + } else { + cpu_topology[cpu].thread_id = -1; + cpu_topology[cpu].core_id = topology_id; + } + topology_id = find_acpi_cpu_topology_package(cpu); + cpu_topology[cpu].package_id = topology_id; + } + + return 0; +} + +#else +static inline int __init parse_acpi_topology(void) +{ + return -EINVAL; +} +#endif + void __init init_cpu_topology(void) { reset_cpu_topology(); @@ -304,6 +345,8 @@ void __init init_cpu_topology(void) * Discard anything that was parsed if we hit an error so we * don't use partial information. */ - if (of_have_populated_dt() && parse_dt_topology()) + if ((!acpi_disabled) && parse_acpi_topology()) + reset_cpu_topology(); + else if (of_have_populated_dt() && parse_dt_topology()) reset_cpu_topology(); } From patchwork Wed Apr 25 23:31:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 134391 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1533491lji; Wed, 25 Apr 2018 17:27:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZocE6agMegGeSqvatWHZbFUVZg0A5FII5kVgVO6gjmjqS8di1gURf0tHMPz3Nr1bbbFfdEy X-Received: by 2002:a17:902:3e5:: with SMTP id d92-v6mr6957859pld.104.1524702444514; Wed, 25 Apr 2018 17:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702444; cv=none; d=google.com; s=arc-20160816; b=VHrw3j9sECsPI1V2dRQBT9YTTFRdMo6SsRt1DyZR9KZi2s6gMXGcb2GZB05PQX42O9 W6EahCh384cPavZv54YXd+WHmmL64ngiH2PZWmfbRMJOAlzNH9++xuhGxQtb1JeDxNxo k5FfqTWPwzzQwbEq/9f7K3+MScnQpLkzjZC0+hZkUE+ub0dRHnWFpI9uCcXoIgUJT1Zk jzalZXnKN7t2m8CWuCg6Etz1F5N/3qU8Yama+Xe6u2MYRStiIJQ9I4sjyX3T05m+DIOV sbNd7RzmxmiD8ITensiPHXx7KFfoxGUX4AJpN0YywMyUldbHma4U8KZlZcf2Em7i1i6k 5NnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=YmvQC69gN2GPVBNzpv2dpEQtHx6aTlxTNvaV4NJHn/w=; b=L2b+6H2lepDmeUXsUD1qkCO6KJyso3OHyDac6CvQ/mU72acrKEXfYkhIEGWv+vA2pJ B/3vqe19pXj60dbMmyuOWDFera2q9/oe0+Q1VBqdW6FR3zVc1/oQLK/95P1OmuDYsyMN Pv35REWkDC4fX7+VV+HtZfYLj3ld92BcKRYNNGYgzdvvja6hS0Brpr79upGFjn32IA6s WXrNhIryCXeE6Uol1m8OSnAhZ+GqxYmc76EbhOTlr9oLBVCgW7A7yEtPhITaJiBsx3qZ nhK+zyvBG24J6+tyS4Yo0v4FRK5BHkTTXhrIPRykLtGCmKti18N/QYHVFkStZ7LEuF7A Udug== 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 o24si9764413pgn.36.2018.04.25.17.27.24; Wed, 25 Apr 2018 17:27:24 -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 S1753255AbeDZA1W (ORCPT + 8 others); Wed, 25 Apr 2018 20:27:22 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45858 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbeDZA00 (ORCPT ); Wed, 25 Apr 2018 20:26:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A25E15AD; Wed, 25 Apr 2018 17:26:26 -0700 (PDT) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 052383F590; Wed, 25 Apr 2018 17:26:24 -0700 (PDT) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: Sudeep.Holla@arm.com, linux-arm-kernel@lists.infradead.org, Lorenzo.Pieralisi@arm.com, hanjun.guo@linaro.org, rjw@rjwysocki.net, Will.Deacon@arm.com, Catalin.Marinas@arm.com, gregkh@linuxfoundation.org, Mark.Rutland@arm.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, wangxiongfeng2@huawei.com, vkilari@codeaurora.org, ahs3@redhat.com, Dietmar.Eggemann@arm.com, Morten.Rasmussen@arm.com, palmer@sifive.com, lenb@kernel.org, john.garry@huawei.com, austinwc@codeaurora.org, tnowicki@caviumnetworks.com, jhugo@qti.qualcomm.com, timur@qti.qualcomm.com, ard.biesheuvel@linaro.org, Jeremy Linton , Geoffrey Blake Subject: [PATCH v8 12/13] ACPI: Add PPTT to injectable table list Date: Wed, 25 Apr 2018 18:31:20 -0500 Message-Id: <20180425233121.13270-13-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180425233121.13270-1-jeremy.linton@arm.com> References: <20180425233121.13270-1-jeremy.linton@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add ACPI_SIG_PPTT to the table so initrd's can override the system topology. Signed-off-by: Geoffrey Blake Signed-off-by: Jeremy Linton --- drivers/acpi/tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 849c4fb19b03..30d93bf7c6a2 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -457,7 +457,7 @@ static const char * const table_sigs[] = { ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, ACPI_SIG_IORT, - ACPI_SIG_NFIT, ACPI_SIG_HMAT, NULL }; + ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT, NULL }; #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)