lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 31 Dec 2023 19:30:57 +0200
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 "Rafael J. Wysocki" <rafael@...nel.org>, 
 Thomas Gleixner <tglx@...utronix.de>, Peter Zijlstra <peterz@...radead.org>, 
 Rob Herring <robh@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org, 
 Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
Subject: [PATCH 2/2] cacheinfo: pass of_node to cpu_device_create()

Pass the DT node correponsing to caches to the cpu_device_create() in
order to let platform-specific cache drivers to bind to the
corresponding cache devices. For example, on Qualcomm Krait platforms
the L2 cache frequency should be scaled following the CPU frequencies.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
---
 drivers/base/cacheinfo.c  | 12 +++++++++++-
 include/linux/cacheinfo.h |  2 ++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index a72c69e70fa3..63bc94cf2c59 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -230,6 +230,7 @@ static int cache_setup_of_node(unsigned int cpu)
 		}
 		cache_of_set_props(this_leaf, np);
 		this_leaf->fw_token = np;
+		this_leaf->of_node = of_node_get(np);
 		index++;
 	}
 
@@ -457,10 +458,19 @@ static void cache_shared_cpu_map_remove(unsigned int cpu)
 
 static void free_cache_attributes(unsigned int cpu)
 {
+	struct cacheinfo *this_leaf;
+	unsigned int index;
+
 	if (!per_cpu_cacheinfo(cpu))
 		return;
 
 	cache_shared_cpu_map_remove(cpu);
+
+	for (index = 0; index < cache_leaves(cpu); index++) {
+		this_leaf = per_cpu_cacheinfo_idx(cpu, index);
+		of_node_put(this_leaf->of_node);
+		this_leaf->of_node = NULL;
+	}
 }
 
 int __weak early_cache_level(unsigned int cpu)
@@ -883,7 +893,7 @@ static int cache_add_dev(unsigned int cpu)
 			break;
 		cache_groups = cache_get_attribute_groups(this_leaf);
 		ci_dev = cpu_device_create(parent, this_leaf,
-					   NULL,
+					   this_leaf->of_node,
 					   cache_groups,
 					   "index%1u", i);
 		if (IS_ERR(ci_dev)) {
diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
index d504eb4b49ab..543d1410e56a 100644
--- a/include/linux/cacheinfo.h
+++ b/include/linux/cacheinfo.h
@@ -38,6 +38,7 @@ extern unsigned int coherency_max_size;
  * @attributes: bitfield representing various cache attributes
  * @fw_token: Unique value used to determine if different cacheinfo
  *	structures represent a single hardware cache instance.
+ * @of_node: Corresponding DT node
  * @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
@@ -67,6 +68,7 @@ struct cacheinfo {
 	(CACHE_READ_ALLOCATE | CACHE_WRITE_ALLOCATE)
 #define CACHE_ID		BIT(4)
 	void *fw_token;
+	struct device_node *of_node;
 	bool disable_sysfs;
 	void *priv;
 };

-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ