]> git.itanic.dy.fi Git - linux-stable/commitdiff
cacheinfo: Move cache_leaves_are_shared out of CONFIG_OF
authorSudeep Holla <sudeep.holla@arm.com>
Mon, 4 Jul 2022 10:15:48 +0000 (11:15 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 4 Jul 2022 15:22:28 +0000 (16:22 +0100)
cache_leaves_are_shared is already used even with ACPI and PPTT. It
checks if the cache leaves are the shared based on fw_token pointer.
However it is defined conditionally only if CONFIG_OF is enabled which
is wrong.

Move the function cache_leaves_are_shared out of CONFIG_OF and keep it
generic. It also handles the case where both OF and ACPI is not defined.

Link: https://lore.kernel.org/r/20220704101605.1318280-5-sudeep.holla@arm.com
Tested-by: Ionela Voinescu <ionela.voinescu@arm.com>
Tested-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/base/cacheinfo.c

index e13ef41763e41d26180b25b16be86b7226c9a3fe..2cea9201f31c045229ce44b6a93b58f8e873434f 100644 (file)
@@ -33,13 +33,21 @@ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu)
        return ci_cacheinfo(cpu);
 }
 
-#ifdef CONFIG_OF
 static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf,
                                           struct cacheinfo *sib_leaf)
 {
+       /*
+        * 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
+        */
+       if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI)))
+               return !(this_leaf->level == 1);
+
        return sib_leaf->fw_token == this_leaf->fw_token;
 }
 
+#ifdef CONFIG_OF
 /* OF properties to query for a given cache type */
 struct cache_type_info {
        const char *size_prop;
@@ -193,16 +201,6 @@ static int cache_setup_of_node(unsigned int cpu)
 }
 #else
 static inline int cache_setup_of_node(unsigned int cpu) { return 0; }
-static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf,
-                                          struct cacheinfo *sib_leaf)
-{
-       /*
-        * 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
-        */
-       return !(this_leaf->level == 1);
-}
 #endif
 
 int __weak cache_setup_acpi(unsigned int cpu)