mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tan Xiaojun <tanxiaojun@huawei.com>
To: <gregkh@linuxfoundation.org>, <sudeep.holla@arm.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] drivers: base: cacheinfo: support DT overrides for cache type
Date: Thu, 16 Nov 2017 20:58:09 +0800	[thread overview]
Message-ID: <1510837089-5951-1-git-send-email-tanxiaojun@huawei.com> (raw)

Since commit dfea747d2aba ("drivers: base: cacheinfo: support DT
overrides for cache properties"), we can set the correct cacheinfo
via DT. But the cache type can't be set in the same way.

I found this may be a problem in recent tests. I tested L3 cache
node setting in DT in Hisilicon D03/D05 board. And I got cacheinfo
via sysfs below:

$ cat /sys/devices/system/cpu/cpu*/cache/index3/
allocation_policy      level                  power/
shared_cpu_map         uevent                 write_policy
coherency_line_size    number_of_sets         shared_cpu_list
size                   ways_of_associativity

This is incomplete, no type file to display type info. Because L3
cache is uncore, we can't get correct type info from system
register, and will get a default type "CACHE_TYPE_NOCACHE". Then
use "lscpu" will print an error like below:

$ lscpu
lscpu: cannot open /sys/devices/system/cpu/cpu0/cache/index3/type:
No such file or directory

So I think maybe we can set correct cache type via DT too.

Signed-off-by: Tan Xiaojun <tanxiaojun@huawei.com>
---
 drivers/base/cacheinfo.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index eb3af27..3e650dc 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -122,6 +122,15 @@ static inline int get_cacheinfo_idx(enum cache_type type)
 	return type;
 }
 
+static void cache_type(struct cacheinfo *this_leaf)
+{
+	const __be32 *cache_type;
+
+	cache_type = of_get_property(this_leaf->of_node, "type", NULL);
+	if (cache_type)
+		this_leaf->type = of_read_number(cache_type, 1);
+}
+
 static void cache_size(struct cacheinfo *this_leaf)
 {
 	const char *propname;
@@ -194,6 +203,7 @@ static void cache_of_override_properties(unsigned int cpu)
 
 	for (index = 0; index < cache_leaves(cpu); index++) {
 		this_leaf = this_cpu_ci->info_list + index;
+		cache_type(this_leaf);
 		cache_size(this_leaf);
 		cache_get_line_size(this_leaf);
 		cache_nr_sets(this_leaf);
-- 
2.7.4

             reply	other threads:[~2017-11-16 12:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 12:58 Tan Xiaojun [this message]
2017-11-16 15:23 ` Sudeep Holla
2017-11-17  2:13   ` Tan Xiaojun
2017-11-17  5:37     ` Tan Xiaojun
2017-11-17 11:16       ` Sudeep Holla
2017-11-17 11:13     ` Sudeep Holla
2017-11-20  1:18       ` Tan Xiaojun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510837089-5951-1-git-send-email-tanxiaojun@huawei.com \
    --to=tanxiaojun@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®