From patchwork Wed Feb 28 22:06:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130069 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp269856lja; Wed, 28 Feb 2018 14:07:20 -0800 (PST) X-Google-Smtp-Source: AH8x224ajmgNeArgtLVzAoeZYzJVoe5jgf9WoKESF3unDqhfu/EZQr7GyItBiqTcCuegMhdlMC9u X-Received: by 10.99.172.66 with SMTP id z2mr14997781pgn.273.1519855639946; Wed, 28 Feb 2018 14:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855639; cv=none; d=google.com; s=arc-20160816; b=GheHl9dJM+9hphufMBlSq5vy+lYjg1VWdDOw+Awuwmi00bqkpyILZUsYlhtLWN1Q6h VVmXDj6gOfw8XgtAWPAuxFaWoOXj7QIpnODOO2QJgTGUX/ogcNq5gZq5qL8gzQ74lZUW nNREmXDOizIq09cy8gya2HlwfmuHr5IU/IWm19dJNiUouor72EwZPIWe1V1i384fYg+u xwAN3XMkA1guR6J4HIGl6mM6C8MsWDCl0JRQpR1/ipNOK0qDTTDJQnR9QvwLQpS2szTM o+tyXs08ry+kZkQK7qKkAVVbV16BB/Dp0vYFBz/I+g+lvHPYhPYhFJnTFAApwnUsJkVP 3UMg== 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=RRkUghi/VYTokt7oDldjgKvni1G8OPv/dexXLnqGdSg=; b=ySNo9upWdZcoMWvp9/KVx6sKBFTcxBb0aS4+tma6Rjt4USqPpggSONuRydGdc219hf PnufnG6fUg4yCgxQYo6RfGelh9PS37dSLZMNJ9csRtcwJ6sGrC0vOaRKY0Ugs99bJPQv xtgwWAdzLXR9pUCCCbTX/qChJFSHVOAFjJPn3PJrRN6gkChHKKPwIw6vpBcg989zrhuL fKubDvDXtowYCuFPLtTe7k/C/ha05wF9vpxm4QtlAF2bxOPOnMXoN+4RKRL7MYWD/LQl 4jIdNubGkCtCaDq4OHUbIJ4Smih3y58SGm/yLF0bu3fr+rQBG4jg/Eje4wX+XiqxOdEN OQag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 h8si1537312pgv.699.2018.02.28.14.07.19; Wed, 28 Feb 2018 14:07:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935305AbeB1WHR (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:17 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57926 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935105AbeB1WHN (ORCPT ); Wed, 28 Feb 2018 17:07:13 -0500 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 DF9EA15BF; Wed, 28 Feb 2018 14:07:12 -0800 (PST) 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 E7C783F246; Wed, 28 Feb 2018 14:07:11 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 01/13] drivers: base: cacheinfo: move cache_setup_of_node() Date: Wed, 28 Feb 2018 16:06:07 -0600 Message-Id: <20180228220619.6992-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- drivers/base/cacheinfo.c | 80 ++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) -- 2.13.6 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 Feb 28 22:06: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: 130070 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp269946lja; Wed, 28 Feb 2018 14:07:24 -0800 (PST) X-Google-Smtp-Source: AH8x225BHnYzgXuBfrVShsXQLFYw9xNFYskMv3TZH4Dok5zHhSANc5HJMZp+XW22YZeXdJmaAhIT X-Received: by 10.98.210.70 with SMTP id c67mr19094145pfg.164.1519855644473; Wed, 28 Feb 2018 14:07:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855644; cv=none; d=google.com; s=arc-20160816; b=uz+EpJbNLKtn6WqbxB+Jm05xvBc8TGc/WcQ4lBy10RVM8LunPP0jRR3pMl3xuA/i9Y vWJRPgXz2GpKDGTeWn+QUMGhaTSlIBUG+/UWKlHaf0jGIS/U0ZjniEsd//BCkGskrOdQ 4wDO8Lqor8kMUWW4DoSYVDczJQDFAmxHvAkzy7IFi79nrCaROQ5xHrmiKWZ4IlI75B+n Ctv15SGjqcsZon35JLKLgFarr62Grtfac4u9d6GRL7J0drUGjXHoxGFH8bs6SiY+eq1f Qt27kRlxdD2MCO6LyLk1FgKc0IpY0rLKN4DL1eOPw5HIqFiJY4t54d69Ewpyenick0yZ VpBw== 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=8NWZ8sT0R53qLbfcNMAzCXLEEN7L0I/NJnUvlKJnrns=; b=Zew4cxVXPDfZSETL5sDFWXJclcURkma/ZtFiHKnuRUQAcEn1iGIGnUgJXWGd++o4/j mXndGszk3BtpZZiGr8WSNTwH/3EqfYj4mMqFAyJwKtPhBH+PfFpwvcx1cjhPG9rh7Tin 4KrEQNpMvblaDuH+y1Feg0GdlojMrNlzKkQrU3po7AUdR9X/ubGQtiqHAurH2EJiCmFa rUe7Ha/KpNejKZX5oar/RoNB/SuOV7NKbwZX2oRomlroXCg604ae2+WeUorvzvJvxysi J0PeUkriIo6iVppziZG/uzDjubh9L3syQn56UAMLotS1xFh4Kv8IOF3rHoh7o9JXcshG ND+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 h8si1537312pgv.699.2018.02.28.14.07.24; Wed, 28 Feb 2018 14:07:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935322AbeB1WHU (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:20 -0500 Received: from foss.arm.com ([217.140.101.70]:57970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935105AbeB1WHR (ORCPT ); Wed, 28 Feb 2018 17:07:17 -0500 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 8AFEA165C; Wed, 28 Feb 2018 14:07:17 -0800 (PST) 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 93CEF3F246; Wed, 28 Feb 2018 14:07:16 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 03/13] cacheinfo: rename of_node to fw_token Date: Wed, 28 Feb 2018 16:06:09 -0600 Message-Id: <20180228220619.6992-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename and change the type of of_node to indicate it is a generic pointer which is generally only used for comparison purposes. In a later patch we will put an ACPI/PPTT token pointer in fw_token so that the code which builds the shared cpu masks can be reused. Signed-off-by: Jeremy Linton --- drivers/base/cacheinfo.c | 16 +++++++++------- include/linux/cacheinfo.h | 8 +++----- 2 files changed, 12 insertions(+), 12 deletions(-) -- 2.13.6 diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index a872523e8951..597aacb233fc 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -35,7 +35,7 @@ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, struct cacheinfo *sib_leaf) { - return sib_leaf->of_node == this_leaf->of_node; + return sib_leaf->fw_token == this_leaf->fw_token; } /* OF properties to query for a given cache type */ @@ -167,9 +167,10 @@ static int cache_setup_of_node(unsigned int 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) + /* skip if fw_token is already populated */ + if (this_cpu_ci->info_list->fw_token) { return 0; + } if (!cpu_dev) { pr_err("No cpu device for CPU %d\n", cpu); @@ -190,7 +191,7 @@ static int cache_setup_of_node(unsigned int cpu) if (!np) break; cache_of_set_props(this_leaf, np); - this_leaf->of_node = np; + this_leaf->fw_token = np; index++; } @@ -278,7 +279,7 @@ static void cache_shared_cpu_map_remove(unsigned int cpu) cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map); cpumask_clear_cpu(sibling, &this_leaf->shared_cpu_map); } - of_node_put(this_leaf->of_node); + of_node_put(this_leaf->fw_token); } } @@ -323,8 +324,9 @@ static int detect_cache_attributes(unsigned int cpu) if (ret) goto free_ci; /* - * For systems using DT for cache hierarchy, of_node and shared_cpu_map - * will be set up here only if they are not populated already + * For systems using DT for cache hierarchy, fw_token + * and shared_cpu_map will be set up here only if they are + * not populated already */ ret = cache_shared_cpu_map_setup(cpu); if (ret) { diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index 3d9805297cda..0c6f658054d2 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -34,9 +34,8 @@ enum cache_type { * @shared_cpu_map: logical cpumask representing all the cpus sharing * this cache node * @attributes: bitfield representing various cache attributes - * @of_node: if devicetree is used, this represents either the cpu node in - * case there's no explicit cache node or the cache node itself in the - * device tree + * @fw_token: Unique value used to determine if different cacheinfo + * structures represent a single hardware cache instance. * @disable_sysfs: indicates whether this node is visible to the user via * sysfs or not * @priv: pointer to any private data structure specific to particular @@ -65,8 +64,7 @@ struct cacheinfo { #define CACHE_ALLOCATE_POLICY_MASK \ (CACHE_READ_ALLOCATE | CACHE_WRITE_ALLOCATE) #define CACHE_ID BIT(4) - - struct device_node *of_node; + void *fw_token; bool disable_sysfs; void *priv; }; From patchwork Wed Feb 28 22:06: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: 130080 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp272797lja; Wed, 28 Feb 2018 14:10:29 -0800 (PST) X-Google-Smtp-Source: AH8x227QAUSm3sopcC+ZnBftcCXoXm+r1RjqwvMkVbw2SM48EDBTRUfXelOd2cpBd6fYwt4ob+Jj X-Received: by 10.98.204.69 with SMTP id a66mr19221836pfg.33.1519855829020; Wed, 28 Feb 2018 14:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855829; cv=none; d=google.com; s=arc-20160816; b=P+Caz4eXUtiFEWF/x3dsWxZU+WMZgvzRo57Ze9t7sm95SrBFLs/oWoOl7HXITybpM7 d+ENfFUy4umop0gAgfw0CcK0j8MFIZ2kI6C+Y4rk/k+3E2t0MrJYLi94fe1a4Yln3FYH KRJ5NiDGYHGZ2XQdmcyq0YFvpykeEPPj5RAPMSdNY6XCoN7xk83WQvdkFzmLxt3yFtKQ nUnNx4wY7TliSnksryALPHvrbMVXZ55locvHvLhH69jCKFk3iTPc+p5D8oDgVbky1bkT 0JjcA/4yJbCGPLaIZiBX8HF2dfZR31g2ZyNGmNzNbVUNKWl55hqHAmUAUKPUn39O2K4r U0gg== 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=X8oIGhkK37WMHWcgEZvYNTfwfcW2tjL2fvwAWo6swsY=; b=GKgfnpoWS6HVN3X0xDQF6Agse4D+bC6ZHJ5kMVx9d2Ba9Crxfd2A+nol8hSjWta1oM NjNCapzGzmkgm9sQtN+dGWCXpn7M2Vp2xD66+RyPvAaNOau/X28GYBjBG93fuWTDr2Ej CLtgu6A8Yv39+dUb1GGdZNgP58EUC/bRXCwXnNSYk3FJAjF9sW3nTUrz2k9wgWtOspjs jb2Xpl1euUY+by4944YDODGplPh7HtHx4eI4ROK2TEmi0uW+PDnaCcbvReJRXHoEIuKC 6GqtWPUpPBhSZRSJNEEPUwDM6PUyMygiH/3f0Ur+Q25C6YIZ9VVPby8lbKCvKSq3DaXL 6MOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 g2-v6si1888521pll.556.2018.02.28.14.10.28; Wed, 28 Feb 2018 14:10:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935414AbeB1WKZ (ORCPT + 28 others); Wed, 28 Feb 2018 17:10:25 -0500 Received: from foss.arm.com ([217.140.101.70]:57998 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935307AbeB1WHT (ORCPT ); Wed, 28 Feb 2018 17:07:19 -0500 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 942A21682; Wed, 28 Feb 2018 14:07:19 -0800 (PST) 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 93CA83F246; Wed, 28 Feb 2018 14:07:18 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 04/13] arm64/acpi: Create arch specific cpu to acpi id helper Date: Wed, 28 Feb 2018 16:06:10 -0600 Message-Id: <20180228220619.6992-5-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Its helpful to be able to lookup the acpi_processor_id associated with a logical cpu. Provide an arm64 helper to do this. Signed-off-by: Jeremy Linton --- arch/arm64/include/asm/acpi.h | 4 ++++ 1 file changed, 4 insertions(+) -- 2.13.6 diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 32f465a80e4e..0db62a4cbce2 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -86,6 +86,10 @@ static inline bool acpi_has_cpu_in_madt(void) } struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu); +static inline u32 get_acpi_id_for_cpu(unsigned int cpu) +{ + return acpi_cpu_get_madt_gicc(cpu)->uid; +} static inline void arch_fix_phys_package_id(int num, u32 slot) { } void __init acpi_init_cpus(void); From patchwork Wed Feb 28 22:06:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130076 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp271258lja; Wed, 28 Feb 2018 14:08:50 -0800 (PST) X-Google-Smtp-Source: AH8x227EPRigqJiz9wTGBt4IhXBxAd0hgjLetXccGUVVforlP4PFTK4hXP6QyOhwXjXGLyGNSfRg X-Received: by 2002:a17:902:62:: with SMTP id 89-v6mr19538598pla.178.1519855729883; Wed, 28 Feb 2018 14:08:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855729; cv=none; d=google.com; s=arc-20160816; b=gazitTDm2z+HWnom1ItrlgnbkoNsFZYEZEq3K15tCigL2GwRBkK+ucEVCW9Rk5Wo3i OvZAqsCgq4n4FIPInE/M5d6p942PaVgtH80EAdliYVIZSRHf0gI/VPc1OIFD8LPQr0dU XJclHzOIYH1boKfCCnthwN+q5Vl+YwK9q5C7QWpuIo3m5G2ALQ/uHZAE7xaLFzWXKqeS hQYHqvcGHWmgz9C+Hqj+U6HpRG8jYNPXak9ugP9IrnQ0AwoPCp4fpZj4t/EZyC6+j/Jj I4Nw9ISFckJuCUCYa8xVAng+LiAnJgbilmShRXL+jAeGLkvrIs49ULFM10xQntYpIAvz Wv6w== 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=FrB7HgXlFWgsSuKF1xSmw8vLLH7A0luH2WsPNter7ng=; b=LIeOjPbJA0hlE+jgddEEYxyFJzdCtN6vtm7R5bm5bxP8xppaDP1efe19VJakhzqPvz f5U8NZqLXAGpapD6s8qTl+PRmiNixiB5KJWCnwhYtaEorkhVd3RpZ6vC3G/TTeNunPab c8XBCkGyvM8aBSKrwgGGymgx1mo/7eWiu2xxbZdhXvbRZ0U22TFMSk4+mCQV2oTEeHi3 SNwTAhP6satLMR+XpVwPTP7Eclmhxn5hVSS03+aUT5eJnPxPNkEIosIpMVFTCoGb2Xig znj84z+nlyN0olaApAWps34rvp4dNxFQMd0Ro0+A8cSpLK5AWKxc7xeI94dYrK2/Ixle Gbwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 v10-v6si2036475plo.61.2018.02.28.14.08.47; Wed, 28 Feb 2018 14:08:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935359AbeB1WHa (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:30 -0500 Received: from foss.arm.com ([217.140.101.70]:58046 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935324AbeB1WHX (ORCPT ); Wed, 28 Feb 2018 17:07:23 -0500 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 D1FAF15AD; Wed, 28 Feb 2018 14:07:22 -0800 (PST) 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 DA4413F246; Wed, 28 Feb 2018 14:07:21 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 06/13] ACPI: Enable PPTT support on ARM64 Date: Wed, 28 Feb 2018 16:06:12 -0600 Message-Id: <20180228220619.6992-7-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have a PPTT parser, in preparation for its use on arm64, lets build it. Signed-off-by: Jeremy Linton --- arch/arm64/Kconfig | 1 + drivers/acpi/Kconfig | 3 +++ drivers/acpi/Makefile | 1 + 3 files changed, 5 insertions(+) -- 2.13.6 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7381eeb7ef8e..439684a71e18 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -7,6 +7,7 @@ config ARM64 select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ACPI_MCFG if ACPI select ACPI_SPCR_TABLE if ACPI + select ACPI_PPTT if ACPI select ARCH_CLOCKSOURCE_DATA select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEVMEM_IS_ALLOWED diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index f505e9a01b2d..55aa9789d474 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -534,6 +534,9 @@ config ACPI_CONFIGFS if ARM64 source "drivers/acpi/arm64/Kconfig" + +config ACPI_PPTT + bool endif config TPS68470_PMIC_OPREGION diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 41954a601989..b6056b566df4 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -87,6 +87,7 @@ obj-$(CONFIG_ACPI_BGRT) += bgrt.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o +obj-$(CONFIG_ACPI_PPTT) += pptt.o # processor has its own "processor." module_param namespace processor-y := processor_driver.o From patchwork Wed Feb 28 22:06:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130075 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp271056lja; Wed, 28 Feb 2018 14:08:36 -0800 (PST) X-Google-Smtp-Source: AG47ELvchv620lMWncXNSbQRJRb9UFuA8bAejgVo3iNjCFDCWOBya0Qvr1sVXYMO4doLfCHF3HYm X-Received: by 2002:a17:902:6d0f:: with SMTP id s15-v6mr12421519plk.375.1519855716700; Wed, 28 Feb 2018 14:08:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855716; cv=none; d=google.com; s=arc-20160816; b=FtTjGGbl23lGZIoUaCkMfv/zsRt3/OJqkewVR6qjMBfXsYkmaKFaTTzmnI6Fcn+Iba aItEMY5VCH5CXHgHThwpyLtW65MBl6u5aatEl9zm3R+9GEND+EN6CfvRvrM2hGty5vrS ntBW1v0GWw45fH33cGaM4JAwfJM9XZJj+xnWy4NXnH0qmku1ngQzuqxyOW4WqqN/Qcjh YNtkrUXYNNk/BfMglGxMMYJjfLHHUgjTViXQawxGhUv4AnDkaTrgWdpFvtr386Rr1633 FEZlnEKr7o731r0OPROjwaHPq9g3JuYEo36YWZiMnH/SUm4PkkFRTARJL4qspvfBJvQ3 Qy+g== 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=g48U7T9obHvyujG/MgRlNwxncW7fdznKGiUwChjx5Gc=; b=RnPvZ3g1cENmsNfc4r1nnuNGZkCIPqXsCB8DMt7YaO/pZWPUz8D83jKC9V/b2Te+Gx 6B4Ul5dhE0ydSuPt7gaQNWwkOdQPgGnLlBBor+b9B+yKCv9l9Xch9BQktxKwh3JXyncY 3ARutPZ6TpQFcmPuUDguSuAnNIKvgb66oEdUdRd1Rx+kRW8di6G/STPfv88Mq+pgtvA0 Zlj++LryVszCahQjlvBj6reoZqt9aL89cxmH5S4HNGExhz2Qt7BCdJbhNLIGTVTtNgKh ETKerezzQ3DjOCp4jC6bGj8l6XENOlol40suGVTr1+4ONX2U2rok7lS9wgwDYQXaODPI uDqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 v10-v6si2036475plo.61.2018.02.28.14.08.36; Wed, 28 Feb 2018 14:08:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935374AbeB1WHb (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:31 -0500 Received: from foss.arm.com ([217.140.101.70]:58058 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935325AbeB1WHY (ORCPT ); Wed, 28 Feb 2018 17:07:24 -0500 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 4501C15BF; Wed, 28 Feb 2018 14:07:24 -0800 (PST) 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 4D8F03F246; Wed, 28 Feb 2018 14:07:23 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 07/13] drivers: base cacheinfo: Add support for ACPI based firmware tables Date: Wed, 28 Feb 2018 16:06:13 -0600 Message-Id: <20180228220619.6992-8-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call ACPI cache parsing routines from base cacheinfo code if ACPI is enable. Also stub out cache_setup_acpi() so that individual architectures can enable ACPI topology parsing. Signed-off-by: Jeremy Linton --- drivers/acpi/pptt.c | 1 + drivers/base/cacheinfo.c | 14 ++++++++++---- include/linux/cacheinfo.h | 9 +++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) -- 2.13.6 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 883e4318c6cd..c98f94ebd272 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -343,6 +343,7 @@ static void update_cache_properties(struct cacheinfo *this_leaf, { int valid_flags = 0; + this_leaf->fw_token = cpu_node; if (found_cache->flags & ACPI_PPTT_SIZE_PROPERTY_VALID) { this_leaf->size = found_cache->size; valid_flags++; diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 597aacb233fc..2880e2ab01f5 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -206,7 +206,7 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, struct cacheinfo *sib_leaf) { /* - * For non-DT systems, assume unique level 1 cache, system-wide + * For non-DT/ACPI systems, assume unique level 1 caches, system-wide * shared caches for all other levels. This will be used only if * arch specific code has not populated shared_cpu_map */ @@ -214,6 +214,11 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, } #endif +int __weak cache_setup_acpi(unsigned int cpu) +{ + return -ENOTSUPP; +} + static int cache_shared_cpu_map_setup(unsigned int cpu) { struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); @@ -227,8 +232,8 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) if (of_have_populated_dt()) ret = cache_setup_of_node(cpu); else if (!acpi_disabled) - /* No cache property/hierarchy support yet in ACPI */ - ret = -ENOTSUPP; + ret = cache_setup_acpi(cpu); + if (ret) return ret; @@ -279,7 +284,8 @@ static void cache_shared_cpu_map_remove(unsigned int cpu) cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map); cpumask_clear_cpu(sibling, &this_leaf->shared_cpu_map); } - of_node_put(this_leaf->fw_token); + if (of_have_populated_dt()) + of_node_put(this_leaf->fw_token); } } diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index 0c6f658054d2..1446d3f053a2 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -97,6 +97,15 @@ int func(unsigned int cpu) \ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu); int init_cache_level(unsigned int cpu); int populate_cache_leaves(unsigned int cpu); +int cache_setup_acpi(unsigned int cpu); +int acpi_find_last_cache_level(unsigned int cpu); +#ifndef CONFIG_ACPI +int acpi_find_last_cache_level(unsigned int cpu) +{ + /* ACPI kernels should be built with PPTT support */ + return 0; +} +#endif const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf); From patchwork Wed Feb 28 22:06:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130079 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp272082lja; Wed, 28 Feb 2018 14:09:47 -0800 (PST) X-Google-Smtp-Source: AH8x227GrerUmQoExKn7dWVTpJaJph6cg8urUkgnHG/bbXZ+owrKTvd+rFcs6cb288zyL+kuM0IU X-Received: by 2002:a17:902:968b:: with SMTP id n11-v6mr19414953plp.168.1519855787467; Wed, 28 Feb 2018 14:09:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855787; cv=none; d=google.com; s=arc-20160816; b=QrTpOv4ZrFUYjTMlGLBEhVjf9grLtdBkgSf9N3wWUh8s7oBiM/9xszmcXzsVnrTYxX d66iQ+NUL7cQ0k6WqbNdgsUfdg+HtbLPqQsEek65G6goMcpmF4Kx4WmS3RaZKhqzyXlf i0AIJDdkQMiQE0rRTwQQW/KO3hDeiFP9rbJhnaMzYbzwSRzuIMZFHVzrh/ssP0krIsU0 STzxLd0RmLsoQnoCDwBC0szfwoh7j0AmW3NmN1sYEvWmBMoTCR68Qjqs4UBKjs7R1Y9A 2FKG6dy/Q9LTGLASEvjXZ3UkGzFvMzRFq0TdgQlN5aqQiP8yL4C1qakiuopRG7eO8nCe C+ug== 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=gYJcPau5DwzOr52kAGNEYhGRTTtgDf9MaGTWv2DO+Go=; b=pc+1E7Egex+sVD9OXYUhG0UaM0C4LQZh8gGd2EwuIvRye8dRNo2tf2t5nUlXDuRmES Qw/L+Zb7/iANhAfe/FUOMGTzKsJsqpz+jebzex9l1kBIQuVSAZxLejvy+JUz3P3ZPLuW U3aAOuagJhcyAa9pN6dvJPbtNryj9/uqUNnkyY8cvv9soFjo/VlvfgL2k0wdcPA+nrxc mg8iOJRMz91oWzR+ZDIsGtFcc+raOVe9uSuxAgE0n6l6yUa8SfSpIOZdDGx9XH15hNNX 9ZB3M8NhH7gMKiCNOOykvxnqTRWEDCseC3V28u7pSZOtMrIbApgB8eqj+j3PJd3UGYzQ qLBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 q14-v6si1957649plk.632.2018.02.28.14.09.47; Wed, 28 Feb 2018 14:09:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935475AbeB1WJn (ORCPT + 28 others); Wed, 28 Feb 2018 17:09:43 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58080 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935105AbeB1WH0 (ORCPT ); Wed, 28 Feb 2018 17:07:26 -0500 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 83AC31610; Wed, 28 Feb 2018 14:07:26 -0800 (PST) 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 8C4133F246; Wed, 28 Feb 2018 14:07:25 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 08/13] arm64: Add support for ACPI based firmware tables Date: Wed, 28 Feb 2018 16:06:14 -0600 Message-Id: <20180228220619.6992-9-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- arch/arm64/kernel/cacheinfo.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.13.6 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 Feb 28 22:06:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130078 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp271814lja; Wed, 28 Feb 2018 14:09:28 -0800 (PST) X-Google-Smtp-Source: AH8x227NnkGMp+iSIiJWJ+M1rUE09dHKYc3XHST0xukxE6+ICTjYnbkON4Y6wUZRxKxkg3EiVrHg X-Received: by 10.98.216.137 with SMTP id e131mr19400427pfg.17.1519855768695; Wed, 28 Feb 2018 14:09:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855768; cv=none; d=google.com; s=arc-20160816; b=PDcARWwcfg0t7nSgrBBnqp8p5m4P18Oi1C+XeQ0jjAXA/+4yj/E3OhCv6I8gRNqz6k Hm+xR/w6PzH+35cClI0UisJ10V8+Larsfz819GYRSPq2AOEf8wEwgQW/V4bDpZ0/QLpG IseR+rVCLEGHnZfatEFcRCPwXXl9HJw+Zji7DnZbL70e7fG4WHQnnitixJquhb8TYiFC m+b4TkNqpa71YPbcHHNEu/jYCpQdnbPDjIabTGpVCVFZzUMa72gOqBFJ4qoTr2r+5UUU o8WKUq54eh1I5ttF/TF6FryjIam18hkx8QMJt7Xkw+R5FtfjTIGhPxTayNWApKxr2oP8 xbIA== 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=QJLztZ2g/MRSiA6xzxg+u6RJFe94U/bV8XHyRQyuNd0=; b=Lb2HOfXXtUPiEmvvb0UjI51BrkQl5v4+UXkCt/nLvOLZ6gx3qcht9XDiLNJE9wuU27 UfE5PocyhfjSYWhQn35wg+oXYbaJThvqEjJxwS1sYQp1aX7P7Anej52KLfj2/+lHmrja xf7Ts8QA3k04cjs6LFmXqKCbfkXIGjYyISbGy18FZU18nn4z7LDFHkNVWN712uw4USG3 EiUFcRBQL7yl9/mhvuOtD28UgIjpeUP5gCC6e2Nuck0i9icNN+i0r2zP4Ksw+k0KP5yj KNM23EvSf67EyrT5wdGs8SHj4xGHR8filQftV47jWMSyAixq5f2omyO+oTDsD2l8evYI HAtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 c18si1861457pfe.335.2018.02.28.14.09.28; Wed, 28 Feb 2018 14:09:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935467AbeB1WJY (ORCPT + 28 others); Wed, 28 Feb 2018 17:09:24 -0500 Received: from foss.arm.com ([217.140.101.70]:58102 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935352AbeB1WH2 (ORCPT ); Wed, 28 Feb 2018 17:07:28 -0500 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 F394C165C; Wed, 28 Feb 2018 14:07:27 -0800 (PST) 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 07D453F246; Wed, 28 Feb 2018 14:07:26 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 09/13] ACPI/PPTT: Add topology parsing code Date: Wed, 28 Feb 2018 16:06:15 -0600 Message-Id: <20180228220619.6992-10-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The PPTT can be used to determine the groupings of CPU's at given levels in the system. Lets add a few routines to the PPTT parsing code to return a unique id for each unique level in the processor hierarchy. This can then be matched to build thread/core/cluster/die/package/etc mappings for each processing element in the system. Signed-off-by: Jeremy Linton --- drivers/acpi/pptt.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 4 ++ 2 files changed, 157 insertions(+) -- 2.13.6 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index c98f94ebd272..d66342c2eb29 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -424,6 +424,79 @@ static void cache_setup_acpi_cpu(struct acpi_table_header *table, } } +/* Passing level values greater than this will result in search termination */ +#define PPTT_ABORT_PACKAGE 0xFF + +/* + * Given an acpi_pptt_processor node, walk up until we identify the + * package that the node is associated with, or we run out of levels + * to request or the search is terminated with a flag match + * The level parameter also serves to limit possible loops within the tree. + */ +static struct acpi_pptt_processor *acpi_find_processor_package_id( + struct acpi_table_header *table_hdr, + struct acpi_pptt_processor *cpu, + int level, int flag) +{ + struct acpi_pptt_processor *prev_node; + + while (cpu && level) { + if (cpu->flags & flag) + break; + pr_debug("level %d\n", level); + prev_node = fetch_pptt_node(table_hdr, cpu->parent); + if (prev_node == NULL) + break; + cpu = prev_node; + level--; + } + return cpu; +} + +/* + * Get a unique value given a cpu, and a topology level, that can be + * matched to determine which cpus share common topological features + * at that level. + */ +static int topology_get_acpi_cpu_tag(struct acpi_table_header *table, + unsigned int cpu, int level, int flag) +{ + struct acpi_pptt_processor *cpu_node; + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); + + cpu_node = acpi_find_processor_node(table, acpi_cpu_id); + if (cpu_node) { + cpu_node = acpi_find_processor_package_id(table, cpu_node, + level, flag); + /* Only the first level has a guaranteed id */ + if (level == 0) + return cpu_node->acpi_processor_id; + return ACPI_PTR_DIFF(cpu_node, table); + } + pr_err_once("PPTT table found, but unable to locate core for %d\n", + cpu); + return -ENOENT; +} + +static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) +{ + struct acpi_table_header *table; + acpi_status status; + int retval; + + status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); + if (ACPI_FAILURE(status)) { + pr_err_once("No PPTT table found, cpu topology may be inaccurate\n"); + return -ENOENT; + } + retval = topology_get_acpi_cpu_tag(table, cpu, level, flag); + pr_debug("Topology Setup ACPI cpu %d, level %d ret = %d\n", + cpu, level, retval); + acpi_put_table(table); + + return retval; +} + /** * acpi_find_last_cache_level() - Determines the number of cache levels for a PE * @cpu: Kernel logical cpu number @@ -487,3 +560,83 @@ int cache_setup_acpi(unsigned int cpu) return status; } + +/** + * find_acpi_cpu_topology() - Determine a unique topology value for a given cpu + * @cpu: Kernel logical cpu number + * @level: The topological level for which we would like a unique ID + * + * Determine a topology unique ID for each thread/core/cluster/mc_grouping + * /socket/etc. This ID can then be used to group peers, which will have + * matching ids. + * + * The search terminates when either the requested level is found or + * we reach a root node. Levels beyond the termination point will return the + * same unique ID. The unique id for level 0 is the acpi processor id. All + * other levels beyond this use a generated value to uniquely identify + * a topological feature. + * + * Return: -ENOENT if the PPTT doesn't exist, or the cpu cannot be found. + * Otherwise returns a value which represents a unique topological feature. + */ +int find_acpi_cpu_topology(unsigned int cpu, int level) +{ + return find_acpi_cpu_topology_tag(cpu, level, 0); +} + +/** + * find_acpi_cpu_cache_topology() - Determine a unique cache topology value + * @cpu: Kernel logical cpu number + * @level: The cache level for which we would like a unique ID + * + * Determine a unique ID for each unified cache in the system + * + * Return: -ENOENT if the PPTT doesn't exist, or the cpu cannot be found. + * Otherwise returns a value which represents a unique topological feature. + */ +int find_acpi_cpu_cache_topology(unsigned int cpu, int level) +{ + struct acpi_table_header *table; + struct acpi_pptt_cache *found_cache; + acpi_status status; + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); + struct acpi_pptt_processor *cpu_node = NULL; + int ret = -1; + + status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); + if (ACPI_FAILURE(status)) { + pr_err_once("No PPTT table found, topology may be inaccurate\n"); + return -ENOENT; + } + + found_cache = acpi_find_cache_node(table, acpi_cpu_id, + CACHE_TYPE_UNIFIED, + level, + &cpu_node); + if (found_cache) + ret = ACPI_PTR_DIFF(cpu_node, table); + + acpi_put_table(table); + + return ret; +} + + +/** + * find_acpi_cpu_topology_package() - Determine a unique cpu package value + * @cpu: Kernel logical cpu number + * + * Determine a topology unique package ID for the given cpu. + * This ID can then be used to group peers, which will have matching ids. + * + * The search terminates when either a level is found with the PHYSICAL_PACKAGE + * flag set or we reach a root node. + * + * Return: -ENOENT if the PPTT doesn't exist, or the cpu cannot be found. + * Otherwise returns a value which represents the package for this cpu. + */ +int find_acpi_cpu_topology_package(unsigned int cpu) +{ + return find_acpi_cpu_topology_tag(cpu, PPTT_ABORT_PACKAGE, + ACPI_PPTT_PHYSICAL_PACKAGE); +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 968173ec2726..2c9b6a000ea7 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1290,4 +1290,8 @@ static inline int lpit_read_residency_count_address(u64 *address) } #endif +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); + #endif /*_LINUX_ACPI_H*/ From patchwork Wed Feb 28 22:06: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: 130077 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp271325lja; Wed, 28 Feb 2018 14:08:53 -0800 (PST) X-Google-Smtp-Source: AG47ELvB+VpKHdYT8IAY56CEE0+YkKXUUfA73yiFZbtFIELVacsKraHLvXES6mcB1sR3ktY7SU67 X-Received: by 2002:a17:902:c03:: with SMTP id 3-v6mr4641214pls.407.1519855733687; Wed, 28 Feb 2018 14:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855733; cv=none; d=google.com; s=arc-20160816; b=yru7EjATH1jCcPmKgIwuZDihYYcE3eKYQ2wwckZgmEiSqmRExB33epwdG3dn1XNIN0 Ue1AQEELP4RkL6H5ZWWRyApkfYKzIaGyGFvNPAjDdI3O2zdAsxiugl0vHPtH/eqV9pq7 kfYoeZFhohQ2O3FmuvwFFarBgZQqaHmG+t2hnJFbbYoGrSBNd5U+mxJe9clUCeENIwF6 jAp8PWomq7lDbSd16ksIrq3Xsz18tN+2CJXZcH1sKV+WownWz2kd6cWi3d9WURYePpHm w687t6QcxopY89BRXvvCSEN7uxdE/SwLOXWG19j0/YQUlwOBrFo6euAT6mqvWNqf4wBx Mpag== 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=rPUi0LT3mxRy7rs8cVc7X4T5aAX2XWfQDXmDyIBHd/A=; b=Fs3iYfQgO3GwDzCzfVBmWillkI5oOIdaFuXLu91iGT/ffqb+lxShgIMAp8rZrD6Yh0 YocUVoVEs5jwUpq+fmP9hZ6G1Xv3oh8yMmtMmS5iYkawWl5GUfUlpgyfjBV0TVb0kngw HQoV9ElIaTEmYiVNPmWuV0/QUH6X8SzASsi1iu55nC9S9t09oAmgo0i+ePEPGzaBIoPV PXpvE5LwUKccFioKmjqMkSrHfTxtRxaqxPePy3py+k6Y52c+f98fFXFTqALG299l9cEt Swk5ZiQxuaK7vqa5N+eVL+P91aRS1aoiQUa1hqp72JPNM1iS6JHQXiOO7tq9r6ru2FkC Vi7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 u8-v6si1933941plh.219.2018.02.28.14.08.53; Wed, 28 Feb 2018 14:08:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935449AbeB1WIu (ORCPT + 28 others); Wed, 28 Feb 2018 17:08:50 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58142 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935354AbeB1WH3 (ORCPT ); Wed, 28 Feb 2018 17:07:29 -0500 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 744D41688; Wed, 28 Feb 2018 14:07:29 -0800 (PST) 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 7C6CA3F246; Wed, 28 Feb 2018 14:07:28 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 10/13] arm64: topology: rename cluster_id Date: Wed, 28 Feb 2018 16:06:16 -0600 Message-Id: <20180228220619.6992-11-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lets match the name of the arm64 topology field to the kernel macro that uses it. Signed-off-by: Jeremy Linton --- arch/arm64/include/asm/topology.h | 4 ++-- arch/arm64/kernel/topology.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) -- 2.13.6 diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/topology.h index c4f2d50491eb..6b10459e6905 100644 --- a/arch/arm64/include/asm/topology.h +++ b/arch/arm64/include/asm/topology.h @@ -7,14 +7,14 @@ struct cpu_topology { int thread_id; int core_id; - int cluster_id; + int package_id; cpumask_t thread_sibling; cpumask_t core_sibling; }; extern struct cpu_topology cpu_topology[NR_CPUS]; -#define topology_physical_package_id(cpu) (cpu_topology[cpu].cluster_id) +#define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id) #define topology_core_id(cpu) (cpu_topology[cpu].core_id) #define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling) #define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 21868530018e..dc18b1e53194 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -47,7 +47,7 @@ static int __init get_cpu_for_node(struct device_node *node) return cpu; } -static int __init parse_core(struct device_node *core, int cluster_id, +static int __init parse_core(struct device_node *core, int package_id, int core_id) { char name[10]; @@ -63,7 +63,7 @@ static int __init parse_core(struct device_node *core, int cluster_id, leaf = false; cpu = get_cpu_for_node(t); if (cpu >= 0) { - cpu_topology[cpu].cluster_id = cluster_id; + cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].core_id = core_id; cpu_topology[cpu].thread_id = i; } else { @@ -85,7 +85,7 @@ static int __init parse_core(struct device_node *core, int cluster_id, return -EINVAL; } - cpu_topology[cpu].cluster_id = cluster_id; + cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].core_id = core_id; } else if (leaf) { pr_err("%pOF: Can't get CPU for leaf core\n", core); @@ -101,7 +101,7 @@ static int __init parse_cluster(struct device_node *cluster, int depth) bool leaf = true; bool has_cores = false; struct device_node *c; - static int cluster_id __initdata; + static int package_id __initdata; int core_id = 0; int i, ret; @@ -140,7 +140,7 @@ static int __init parse_cluster(struct device_node *cluster, int depth) } if (leaf) { - ret = parse_core(c, cluster_id, core_id++); + ret = parse_core(c, package_id, core_id++); } else { pr_err("%pOF: Non-leaf cluster with core %s\n", cluster, name); @@ -158,7 +158,7 @@ static int __init parse_cluster(struct device_node *cluster, int depth) pr_warn("%pOF: empty cluster\n", cluster); if (leaf) - cluster_id++; + package_id++; return 0; } @@ -194,7 +194,7 @@ static int __init parse_dt_topology(void) * only mark cores described in the DT as possible. */ for_each_possible_cpu(cpu) - if (cpu_topology[cpu].cluster_id == -1) + if (cpu_topology[cpu].package_id == -1) ret = -EINVAL; out_map: @@ -224,7 +224,7 @@ static void update_siblings_masks(unsigned int cpuid) for_each_possible_cpu(cpu) { cpu_topo = &cpu_topology[cpu]; - if (cpuid_topo->cluster_id != cpu_topo->cluster_id) + if (cpuid_topo->package_id != cpu_topo->package_id) continue; cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); @@ -245,7 +245,7 @@ void store_cpu_topology(unsigned int cpuid) struct cpu_topology *cpuid_topo = &cpu_topology[cpuid]; u64 mpidr; - if (cpuid_topo->cluster_id != -1) + if (cpuid_topo->package_id != -1) goto topology_populated; mpidr = read_cpuid_mpidr(); @@ -259,19 +259,19 @@ void store_cpu_topology(unsigned int cpuid) /* Multiprocessor system : Multi-threads per core */ cpuid_topo->thread_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); cpuid_topo->core_id = MPIDR_AFFINITY_LEVEL(mpidr, 1); - cpuid_topo->cluster_id = MPIDR_AFFINITY_LEVEL(mpidr, 2) | + cpuid_topo->package_id = MPIDR_AFFINITY_LEVEL(mpidr, 2) | MPIDR_AFFINITY_LEVEL(mpidr, 3) << 8; } else { /* Multiprocessor system : Single-thread per core */ cpuid_topo->thread_id = -1; cpuid_topo->core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); - cpuid_topo->cluster_id = MPIDR_AFFINITY_LEVEL(mpidr, 1) | + cpuid_topo->package_id = MPIDR_AFFINITY_LEVEL(mpidr, 1) | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 8 | MPIDR_AFFINITY_LEVEL(mpidr, 3) << 16; } pr_debug("CPU%u: cluster %d core %d thread %d mpidr %#016llx\n", - cpuid, cpuid_topo->cluster_id, cpuid_topo->core_id, + cpuid, cpuid_topo->package_id, cpuid_topo->core_id, cpuid_topo->thread_id, mpidr); topology_populated: @@ -287,7 +287,7 @@ static void __init reset_cpu_topology(void) cpu_topo->thread_id = -1; cpu_topo->core_id = 0; - cpu_topo->cluster_id = -1; + cpu_topo->package_id = -1; cpumask_clear(&cpu_topo->core_sibling); cpumask_set_cpu(cpu, &cpu_topo->core_sibling); From patchwork Wed Feb 28 22:06:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130072 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp270184lja; Wed, 28 Feb 2018 14:07:38 -0800 (PST) X-Google-Smtp-Source: AG47ELspqT6yCOYJfC0EFYo5AjAqablfJ4DV/kH/6uiuTycDybZsyaO5Tr89kHQGv3nHma+vw8JP X-Received: by 10.101.75.18 with SMTP id r18mr9318851pgq.36.1519855657988; Wed, 28 Feb 2018 14:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855657; cv=none; d=google.com; s=arc-20160816; b=Lz9Fy6Sf7D/irtGEq9eTig6uflwhF2jtjRAllWSXMt78+7fSF5a0dJBJuXvf04XAtD 5grA0KjZjT0ASBzHIVkcQc4Y4ImG/hg+kUFsKpOv163ZlBAYQoBpsTQsP3Aw1LRELf1v I27Hr2PhPi+LpG9t9zWWG+/xrqptVCb/kEaqsEKPVvVW5eY6/OvZkQorR/hf5q0oWlhI 3UFUz6Stv2/fiH9YggkLhNbYgTwaOJ4fw5+OAmmadiOk6YErqSrNFrtoViQ5O4FaRNEX emAZCaW77z6waEKI5wBiIAc3fy6w61TccIfrlnkHdY6b7kjYZ1q60OW6ivLpJinrg3s2 rgsA== 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=67hBQw3N45mpT2AFRrevGfvDZ7Szd+8j6rHJTDYfm7A=; b=IVFOaZLypixU3hSo45ntHY6nC4hDnOTiDMz4DSJaKM+bCe8R626D3pFdMq7qK8/USD UaHqPxld5m6Z+IW/CqsJPacPDge9kslfa0PEU4L7xsW136BMzdZg61XnmolxlazeV09g SZPo5kpyVmPkHZZnJNDhVzSzjTeZ96jSieh688Q9ugsz2uiZYkU5EjYBoTV4LjZhpF50 mVkumRJjoN+uIdstGN/MbDVNtmOTANnRrEBNiNDuN2JSdXd/e+XOT55FbkA3ca/YCblO Dq6lsGlhBi3Apv+1d06OBeU2Vp6I74s9D9pSEIbhdRn6VePLGFH7eqH93xzTRumcsoTJ PfIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 k9-v6si1953161plt.293.2018.02.28.14.07.37; Wed, 28 Feb 2018 14:07:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935390AbeB1WHd (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:33 -0500 Received: from foss.arm.com ([217.140.101.70]:58166 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935365AbeB1WHb (ORCPT ); Wed, 28 Feb 2018 17:07:31 -0500 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 D2644169F; Wed, 28 Feb 2018 14:07:30 -0800 (PST) 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 DA1113F246; Wed, 28 Feb 2018 14:07:29 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 11/13] arm64: topology: enable ACPI/PPTT based CPU topology Date: Wed, 28 Feb 2018 16:06:17 -0600 Message-Id: <20180228220619.6992-12-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Propagate the topology information from the PPTT tree to the cpu_topology array. We can get the thread id, core_id and cluster_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 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 Feb 28 22:06:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130074 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp270513lja; Wed, 28 Feb 2018 14:08:00 -0800 (PST) X-Google-Smtp-Source: AH8x226Ox1ZEcxzPTkFrMJLaT2WrFwfIDwVR5ro4y3X0S3ozYNoSUlsKRNC9CT2FRtVOBG/bhFmB X-Received: by 2002:a17:902:858c:: with SMTP id e12-v6mr19666249plo.39.1519855679862; Wed, 28 Feb 2018 14:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855679; cv=none; d=google.com; s=arc-20160816; b=g1rObCLDJcTGveXfPnyoGpggl//umkbJkwDDptIx7CoxoSnAgcgyzB50chfGZOI3l8 iO1nE9fyifo9nxTAVKFb0Ksd65v/3gZjQ4k+RXv8AZZFLQi1Kgd3ZMLb1Gj10c4m8tiV fpaFuslo+YpvCnCPzRume8ZyFGvModFrEhWuGg6U8JRl2BYsavMB0UfJ0ISk371TS9oE a4nT+IaNoGUfSG3cew2jVwJdk8O1rGGPYBpSiv/aCKco4vxe+aE1bRysGd5zB8jqQYYC NAh5zD2Bkxwdny6rPlCoXuoygRZDOEKzvr/3xpQuZVEizJ1CVu5UGuQc01OpV44bJjRW kMJA== 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=rN3giRi+Nev6a16TArNPeUyHIXQID4ZWZP7BqTgawvg=; b=dQC9kzWEGtlzhsGfi2UN5yt9+cgx4Aef4IR+lIaudlqqx3sH8knwpiN1DRaLK6JDl+ Y18j9YRdD0RkBgz0ycCMYuJFrhDZNoo6yr3fDxOjuJB4B7K/2vebMQiIx4ecWRu0JOPn hhw1PYUh2zgTaaoJagipaRR4Qdz/e9+VGGdZXDpVWqRwCM4n70QmXtKKW+Ccvq6IMTkN ZMfzRcC9G+CNQoFFXoEvK02GFYeDG084Yxf6T7dkAIFkOr+m8guQL9gecPD31b3/zSm+ MmZuaIejeM6mVKUj+GJmLQJkD9kndCGr5h0U/USfxUdirwRR94EFKsYEZl4V9ZvpSQIM R+XQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 l85si1894145pfg.104.2018.02.28.14.07.59; Wed, 28 Feb 2018 14:07:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935418AbeB1WHz (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:55 -0500 Received: from foss.arm.com ([217.140.101.70]:58186 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935379AbeB1WHc (ORCPT ); Wed, 28 Feb 2018 17:07:32 -0500 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 4AF7216A3; Wed, 28 Feb 2018 14:07:32 -0800 (PST) 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 41DEE3F246; Wed, 28 Feb 2018 14:07:31 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton , Geoffrey Blake Subject: [PATCH v7 12/13] ACPI: Add PPTT to injectable table list Date: Wed, 28 Feb 2018 16:06:18 -0600 Message-Id: <20180228220619.6992-13-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 7bcb66ccccf3..b2efaa503c34 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, - NULL }; + ACPI_SIG_PPTT, NULL }; #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) From patchwork Wed Feb 28 22:06: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: 130073 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp270217lja; Wed, 28 Feb 2018 14:07:39 -0800 (PST) X-Google-Smtp-Source: AH8x227jKQpbHwv/5R2oeJW+cMexCdXcy4dZoX5rfmZQN6tsidkw5fR4DhPiw5jKRAhYeLzDYGLd X-Received: by 2002:a17:902:b109:: with SMTP id q9-v6mr19803918plr.340.1519855659800; Wed, 28 Feb 2018 14:07:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855659; cv=none; d=google.com; s=arc-20160816; b=b+1lE4Zafll6/zRCc+xH721CgscJMQiLhQs26jdsC1w2HMtELQUU57QMSMxOZkZ6s/ o/EdtE7QJcoCiwGgHXbGOc6oYf382Ls9sSyi6RbDdgB6rUQ/CE9dM1xr/x0GoydLU5hV i8j4S4Txr7ymvGr1boGwAhZQsP4b20008e/LzspYUzBvZKtnkkFUf1wVQ2XoXNU/5ObL xE5y3UlCCDjTcb6CoNU48ZO3tJaZic62fgIH2/NGwIvAWTgxcULeRfHP9Q+PKuFPd+E6 bBsDwFi4SuvTmybXf1EN2Qs1HTDHERsn3aBlOD7FT9TxiwEJX8prSAsYcCt2GyauZli7 VcOg== 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=m0LYSuwtP8U45Z7etrtHPtxdE00Z7mP4oopiGZ57PWA=; b=dAaR9oOO1F9rnWfh3+HvfTxTaf/kmAqfcyQad6PUcHgK760v2q9VJwsVho6ZrfLqR8 pu2ZizpV/5Xt8xSmwR5jfe2UcTXm0hi5i/HIrPE9Nq6U8oyYtkMKSYanbx6YHlqBxTjX UVwZ0hAW4Cxcgspw79gCQr8W86pn5gF2rYX8k8Ww7Jzz5EpV0MNSLR63NYV9KEemcuES MEzIU/E6k27MX9D2bphL5yhM2RMPmuUKpmXbkYH+42Ce43glpv3SSwHFa+55OiLosfhC 3Qy/OLRHzgrpLQyVGeoCSTf4HVTZ+uk9MUoMgb66R6N4jBCRQUGGaXqqOJNNapzWtfCh kxLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 k9-v6si1953161plt.293.2018.02.28.14.07.39; Wed, 28 Feb 2018 14:07:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935407AbeB1WHf (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:35 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58196 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935365AbeB1WHd (ORCPT ); Wed, 28 Feb 2018 17:07:33 -0500 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 A0C2216BA; Wed, 28 Feb 2018 14:07:33 -0800 (PST) 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 A961D3F246; Wed, 28 Feb 2018 14:07:32 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, 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, Jeremy Linton Subject: [PATCH v7 13/13] arm64: topology: divorce MC scheduling domain from core_siblings Date: Wed, 28 Feb 2018 16:06:19 -0600 Message-Id: <20180228220619.6992-14-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have an accurate view of the physical topology we need to represent it correctly to the scheduler. In the case of NUMA in socket, we need to assure that the sched domain we build for the MC layer isn't larger than the DIE above it. To do this correctly, we should really base that on the cache topology immediately below the NUMA node (for NUMA in socket) or below the physical package for normal NUMA configurations. This patch creates a set of early cache_siblings masks, then when the scheduler requests the coregroup mask we pick the smaller of the physical package siblings, or the numa siblings and locate the largest cache which is an entire subset of those siblings. If we are unable to find a proper subset of cores then we retain the original behavior and return the core_sibling list. Signed-off-by: Jeremy Linton --- arch/arm64/include/asm/topology.h | 5 +++ arch/arm64/kernel/topology.c | 64 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) -- 2.13.6 diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/topology.h index 6b10459e6905..08db3e4e44e1 100644 --- a/arch/arm64/include/asm/topology.h +++ b/arch/arm64/include/asm/topology.h @@ -4,12 +4,17 @@ #include +#define MAX_CACHE_CHECKS 4 + struct cpu_topology { int thread_id; int core_id; int package_id; + int cache_id[MAX_CACHE_CHECKS]; cpumask_t thread_sibling; cpumask_t core_sibling; + cpumask_t cache_siblings[MAX_CACHE_CHECKS]; + int cache_level; }; extern struct cpu_topology cpu_topology[NR_CPUS]; diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index bd1aae438a31..1809dc9d347c 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -212,8 +212,42 @@ static int __init parse_dt_topology(void) struct cpu_topology cpu_topology[NR_CPUS]; EXPORT_SYMBOL_GPL(cpu_topology); +static void find_llc_topology_for_cpu(int cpu) +{ + /* first determine if we are a NUMA in package */ + const cpumask_t *node_mask = cpumask_of_node(cpu_to_node(cpu)); + int indx; + + if (!cpumask_subset(node_mask, &cpu_topology[cpu].core_sibling)) { + /* not numa in package, lets use the package siblings */ + node_mask = &cpu_topology[cpu].core_sibling; + } + + /* + * node_mask should represent the smallest package/numa grouping + * lets search for the largest cache smaller than the node_mask. + */ + for (indx = 0; indx < MAX_CACHE_CHECKS; indx++) { + cpumask_t *cache_sibs = &cpu_topology[cpu].cache_siblings[indx]; + + if (cpu_topology[cpu].cache_id[indx] < 0) + continue; + + if (cpumask_subset(cache_sibs, node_mask)) + cpu_topology[cpu].cache_level = indx; + } +} + const struct cpumask *cpu_coregroup_mask(int cpu) { + int *llc = &cpu_topology[cpu].cache_level; + + if (*llc == -1) + find_llc_topology_for_cpu(cpu); + + if (*llc != -1) + return &cpu_topology[cpu].cache_siblings[*llc]; + return &cpu_topology[cpu].core_sibling; } @@ -221,6 +255,7 @@ static void update_siblings_masks(unsigned int cpuid) { struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; int cpu; + int idx; /* update core and thread sibling masks */ for_each_possible_cpu(cpu) { @@ -229,6 +264,16 @@ static void update_siblings_masks(unsigned int cpuid) if (cpuid_topo->package_id != cpu_topo->package_id) continue; + for (idx = 0; idx < MAX_CACHE_CHECKS; idx++) { + cpumask_t *lsib; + int cput_id = cpuid_topo->cache_id[idx]; + + if (cput_id == cpu_topo->cache_id[idx]) { + lsib = &cpuid_topo->cache_siblings[idx]; + cpumask_set_cpu(cpu, lsib); + } + } + cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); if (cpu != cpuid) cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); @@ -286,10 +331,18 @@ static void __init reset_cpu_topology(void) for_each_possible_cpu(cpu) { struct cpu_topology *cpu_topo = &cpu_topology[cpu]; + int idx; cpu_topo->thread_id = -1; cpu_topo->core_id = 0; cpu_topo->package_id = -1; + cpu_topo->cache_level = -1; + + for (idx = 0; idx < MAX_CACHE_CHECKS; idx++) { + cpu_topo->cache_id[idx] = -1; + cpumask_clear(&cpu_topo->cache_siblings[idx]); + cpumask_set_cpu(cpu, &cpu_topo->cache_siblings[idx]); + } cpumask_clear(&cpu_topo->core_sibling); cpumask_set_cpu(cpu, &cpu_topo->core_sibling); @@ -311,6 +364,9 @@ static int __init parse_acpi_topology(void) is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; for_each_possible_cpu(cpu) { + int tidx = 0; + int i; + topology_id = find_acpi_cpu_topology(cpu, 0); if (topology_id < 0) return topology_id; @@ -325,6 +381,14 @@ static int __init parse_acpi_topology(void) } topology_id = find_acpi_cpu_topology_package(cpu); cpu_topology[cpu].package_id = topology_id; + + for (i = 0; i < MAX_CACHE_CHECKS; i++) { + topology_id = find_acpi_cpu_cache_topology(cpu, i + 1); + if (topology_id > 0) { + cpu_topology[cpu].cache_id[tidx] = topology_id; + tidx++; + } + } } return 0;