Skip to content

Commit dea8c0b

Browse files
committed
arch_topology: Add support for parsing sockets in /cpu-map
Finally let us add support for socket nodes in /cpu-map in the device tree. Since this may not be present in all the old platforms and even most of the existing platforms, we need to assume absence of the socket node indicates that it is a single socket system and handle appropriately. Also it is likely that most single socket systems skip to as the node since it is optional. 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 556c967 commit dea8c0b

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

drivers/base/arch_topology.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ static int __init parse_core(struct device_node *core, int package_id,
545545
return 0;
546546
}
547547

548-
static int __init
549-
parse_cluster(struct device_node *cluster, int cluster_id, int depth)
548+
static int __init parse_cluster(struct device_node *cluster, int package_id,
549+
int cluster_id, int depth)
550550
{
551551
char name[20];
552552
bool leaf = true;
@@ -566,7 +566,7 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth)
566566
c = of_get_child_by_name(cluster, name);
567567
if (c) {
568568
leaf = false;
569-
ret = parse_cluster(c, i, depth + 1);
569+
ret = parse_cluster(c, package_id, i, depth + 1);
570570
of_node_put(c);
571571
if (ret != 0)
572572
return ret;
@@ -590,7 +590,8 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth)
590590
}
591591

592592
if (leaf) {
593-
ret = parse_core(c, 0, cluster_id, core_id++);
593+
ret = parse_core(c, package_id, cluster_id,
594+
core_id++);
594595
} else {
595596
pr_err("%pOF: Non-leaf cluster with core %s\n",
596597
cluster, name);
@@ -610,6 +611,32 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth)
610611
return 0;
611612
}
612613

614+
static int __init parse_socket(struct device_node *socket)
615+
{
616+
char name[20];
617+
struct device_node *c;
618+
bool has_socket = false;
619+
int package_id = 0, ret;
620+
621+
do {
622+
snprintf(name, sizeof(name), "socket%d", package_id);
623+
c = of_get_child_by_name(socket, name);
624+
if (c) {
625+
has_socket = true;
626+
ret = parse_cluster(c, package_id, -1, 0);
627+
of_node_put(c);
628+
if (ret != 0)
629+
return ret;
630+
}
631+
package_id++;
632+
} while (c);
633+
634+
if (!has_socket)
635+
ret = parse_cluster(socket, 0, -1, 0);
636+
637+
return ret;
638+
}
639+
613640
static int __init parse_dt_topology(void)
614641
{
615642
struct device_node *cn, *map;
@@ -630,7 +657,7 @@ static int __init parse_dt_topology(void)
630657
if (!map)
631658
goto out;
632659

633-
ret = parse_cluster(map, -1, 0);
660+
ret = parse_socket(map);
634661
if (ret != 0)
635662
goto out_map;
636663

0 commit comments

Comments
 (0)