From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev
Cc: sshegde@linux.ibm.com, christophe.leroy@csgroup.eu,
ritesh.list@gmail.com, tim.c.chen@linux.intel.com,
yu.c.chen@intel.com, gregkh@linuxfoundation.org,
rafael@kernel.org, dakr@kernel.org, johan@kernel.org,
sudeep.holla@kernel.org, peterz@infradead.org, tglx@kernel.org,
kprateek.nayak@amd.com, srikar@linux.ibm.com
Subject: [PATCH v2 2/6] cacheinfo: Support unified caches described by d-cache properties
Date: Fri, 27 Nov 2026 20:52:38 +0530 [thread overview]
Message-ID: <20261127152242.306333-3-sshegde@linux.ibm.com> (raw)
In-Reply-To: <20261127152242.306333-1-sshegde@linux.ibm.com>
PowerPC device trees commonly describe a unified cache using d-cache-*
properties.
For example, Power11 L2 and L3 cache nodes have cache-unified together
with properties such as:
d-cache-size
d-cache-line-size
d-cache-sets
They do not provide the corresponding cache-size, cache-line-size and
cache-sets properties expected by generic cacheinfo for a unified cache.
When a unified cache node does not contain cache-size but contains
d-cache-size, select the data-cache property set. This only changes which
device-tree properties are read. The cache leaf remains
CACHE_TYPE_UNIFIED.
[Both draft changelog and code are written by LLM under guidance]
Assisted-by: LLM
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
A Subsequent optimization if the series is in an acceptable shape.
Cache the idx first and then use it in cache_size, cache_get_line_size
and cache_nr_sets.
drivers/base/cacheinfo.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index 10a9bbce899e..4a23377e9312 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -148,11 +148,21 @@ static const struct cache_type_info cache_type_info[] = {
},
};
-static inline int get_cacheinfo_idx(enum cache_type type)
+static inline int get_cacheinfo_idx(enum cache_type type, struct device_node *np)
{
- if (type == CACHE_TYPE_UNIFIED)
- return 0;
- return type;
+ if (type != CACHE_TYPE_UNIFIED)
+ return type;
+
+ /*
+ * Some device-tree bindings describe unified caches using
+ * d-cache-* properties. Select the data-cache property set
+ * without changing the cache leaf type.
+ */
+ if (!of_property_present(np, "cache-size") &&
+ of_property_present(np, "d-cache-size"))
+ return CACHE_TYPE_DATA;
+
+ return 0;
}
static void cache_size(struct cacheinfo *this_leaf, struct device_node *np)
@@ -160,7 +170,7 @@ static void cache_size(struct cacheinfo *this_leaf, struct device_node *np)
const char *propname;
int ct_idx;
- ct_idx = get_cacheinfo_idx(this_leaf->type);
+ ct_idx = get_cacheinfo_idx(this_leaf->type, np);
propname = cache_type_info[ct_idx].size_prop;
of_property_read_u32(np, propname, &this_leaf->size);
@@ -172,7 +182,7 @@ static void cache_get_line_size(struct cacheinfo *this_leaf,
{
int i, lim, ct_idx;
- ct_idx = get_cacheinfo_idx(this_leaf->type);
+ ct_idx = get_cacheinfo_idx(this_leaf->type, np);
lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props);
for (i = 0; i < lim; i++) {
@@ -194,7 +204,7 @@ static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np)
const char *propname;
int ct_idx;
- ct_idx = get_cacheinfo_idx(this_leaf->type);
+ ct_idx = get_cacheinfo_idx(this_leaf->type, np);
propname = cache_type_info[ct_idx].nr_sets_prop;
of_property_read_u32(np, propname, &this_leaf->number_of_sets);
--
2.52.0
next prev parent reply other threads:[~2026-11-27 15:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 15:22 [PATCH v2 0/6] cacheinfo, powerpc, sched: Move powerpc to generic cacheinfo Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 1/6] cacheinfo: Allow architectures to provide custom cache IDs Shrikanth Hegde
2026-11-27 15:22 ` Shrikanth Hegde [this message]
2026-11-27 15:22 ` [PATCH v2 3/6] cacheinfo: Add firmware topology replacement helpers Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 4/6] powerpc: Set CPU device OF node before generic cacheinfo setup Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 5/6] powerpc/cacheinfo: Move to generic cacheinfo Shrikanth Hegde
2026-12-01 10:50 ` Shrikanth Hegde
2026-11-27 15:22 ` [PATCH v2 6/6] sched/topology: Remove stale comment around llc_bytes on powerpc Shrikanth Hegde
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=20261127152242.306333-3-sshegde@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=ritesh.list@gmail.com \
--cc=srikar@linux.ibm.com \
--cc=sudeep.holla@kernel.org \
--cc=tglx@kernel.org \
--cc=tim.c.chen@linux.intel.com \
--cc=yu.c.chen@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.