Skip to content

Commit 556c967

Browse files
committed
arch_topology: Set cluster identifier in each core/thread from /cpu-map
Let us set the cluster identifier as parsed from the device tree cluster nodes within /cpu-map. We don't support nesting of clusters yet as there are no real hardware to support clusters of clusters. Link: https://lore.kernel.org/r/[email protected] Tested-by: Ionela Voinescu <[email protected]> Tested-by: Conor Dooley <[email protected]> Reviewed-by: Ionela Voinescu <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent bfcc439 commit 556c967

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/base/arch_topology.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static int __init get_cpu_for_node(struct device_node *node)
497497
}
498498

499499
static int __init parse_core(struct device_node *core, int package_id,
500-
int core_id)
500+
int cluster_id, int core_id)
501501
{
502502
char name[20];
503503
bool leaf = true;
@@ -513,6 +513,7 @@ static int __init parse_core(struct device_node *core, int package_id,
513513
cpu = get_cpu_for_node(t);
514514
if (cpu >= 0) {
515515
cpu_topology[cpu].package_id = package_id;
516+
cpu_topology[cpu].cluster_id = cluster_id;
516517
cpu_topology[cpu].core_id = core_id;
517518
cpu_topology[cpu].thread_id = i;
518519
} else if (cpu != -ENODEV) {
@@ -534,6 +535,7 @@ static int __init parse_core(struct device_node *core, int package_id,
534535
}
535536

536537
cpu_topology[cpu].package_id = package_id;
538+
cpu_topology[cpu].cluster_id = cluster_id;
537539
cpu_topology[cpu].core_id = core_id;
538540
} else if (leaf && cpu != -ENODEV) {
539541
pr_err("%pOF: Can't get CPU for leaf core\n", core);
@@ -543,7 +545,8 @@ static int __init parse_core(struct device_node *core, int package_id,
543545
return 0;
544546
}
545547

546-
static int __init parse_cluster(struct device_node *cluster, int depth)
548+
static int __init
549+
parse_cluster(struct device_node *cluster, int cluster_id, int depth)
547550
{
548551
char name[20];
549552
bool leaf = true;
@@ -563,7 +566,7 @@ static int __init parse_cluster(struct device_node *cluster, int depth)
563566
c = of_get_child_by_name(cluster, name);
564567
if (c) {
565568
leaf = false;
566-
ret = parse_cluster(c, depth + 1);
569+
ret = parse_cluster(c, i, depth + 1);
567570
of_node_put(c);
568571
if (ret != 0)
569572
return ret;
@@ -587,7 +590,7 @@ static int __init parse_cluster(struct device_node *cluster, int depth)
587590
}
588591

589592
if (leaf) {
590-
ret = parse_core(c, 0, core_id++);
593+
ret = parse_core(c, 0, cluster_id, core_id++);
591594
} else {
592595
pr_err("%pOF: Non-leaf cluster with core %s\n",
593596
cluster, name);
@@ -627,7 +630,7 @@ static int __init parse_dt_topology(void)
627630
if (!map)
628631
goto out;
629632

630-
ret = parse_cluster(map, 0);
633+
ret = parse_cluster(map, -1, 0);
631634
if (ret != 0)
632635
goto out_map;
633636

0 commit comments

Comments
 (0)