From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751349AbdAMJIm (ORCPT ); Fri, 13 Jan 2017 04:08:42 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:7582 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751284AbdAMJIk (ORCPT ); Fri, 13 Jan 2017 04:08:40 -0500 Subject: Re: [PATCH v2 2/2] arm64: cacheinfo: add support to override cache levels via device tree To: Sudeep Holla , References: <1484245772-31511-1-git-send-email-sudeep.holla@arm.com> <1484245772-31511-2-git-send-email-sudeep.holla@arm.com> CC: Rob Herring , Catalin Marinas , Will Deacon , , , Mark Rutland From: Tan Xiaojun Message-ID: <58789899.3080909@huawei.com> Date: Fri, 13 Jan 2017 17:06:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1484245772-31511-2-git-send-email-sudeep.holla@arm.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.21.79] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.587898A6.0026,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b09b545743073e75ac62ea13f4deaccf Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/1/13 2:29, Sudeep Holla wrote: > The cache hierarchy can be identified through Cache Level ID(CLIDR) > architected system register. However in some cases it will provide > only the number of cache levels that are integrated into the processor > itself. In other words, it can't provide any information about the > caches that are external and/or transparent. > > Some platforms require to export the information about all such external > caches to the userspace applications via the sysfs interface. > > This patch adds support to override the cache levels using device tree > to take such external non-architected caches into account. > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Signed-off-by: Sudeep Holla Tested-by: Tan Xiaojun > --- > arch/arm64/kernel/cacheinfo.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c > index 9617301f76b5..3f2250fc391b 100644 > --- a/arch/arm64/kernel/cacheinfo.c > +++ b/arch/arm64/kernel/cacheinfo.c > @@ -84,7 +84,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf, > > static int __init_cache_level(unsigned int cpu) > { > - unsigned int ctype, level, leaves; > + unsigned int ctype, level, leaves, of_level; > struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); > > for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) { > @@ -97,6 +97,17 @@ 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) { > + /* > + * 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; > + } > + > this_cpu_ci->num_levels = level; > this_cpu_ci->num_leaves = leaves; > return 0; > -- > 2.7.4 > > > . >