Skip to contentSkip to conversation

clk: tegra: Support unique names for multi-socket platforms

PATCH Superseded Jon Hunter 2 participants 3 messages May 22 – May 29

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jon Hunter

author maintainer
#0 lore raw

PATCH 1/1 clk: tegra: Support unique names for multi-socket platforms

On multi-socket platforms each socket has its own BPMP which exposes the same clock names. Fix this by appending the NUMA ID as suffix to the clock names for multi-socket platforms.

Use 'sizeof(info->name)' in the strscpy() and snprintf() functions to future proof against anyone changing the size of the 'name' array.

---
 drivers/clk/tegra/clk-bpmp.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/clk/tegra/clk-bpmp.c +9 -1
index f6d2b934228b..428e776561c5 100644
@@ -367,7 +367,15 @@ static int tegra_bpmp_clk_get_info(struct tegra_bpmp *bpmp, unsigned int id,
 	if (err < 0)
 		return err;
 
-	strscpy(info->name, response.name, MRQ_CLK_NAME_MAXLEN);
+	if (dev_to_node(bpmp->dev) == NUMA_NO_NODE) {
+		strscpy(info->name, response.name, sizeof(info->name));
+	} else {
+		err = snprintf(info->name, sizeof(info->name), "%s.%d",
+			       response.name, dev_to_node(bpmp->dev));
+		if (WARN_ON(err >= sizeof(info->name)))
+			return -E2BIG;
+	}
+
 	info->num_parents = response.num_parents;
 
 	for (i = 0; i < info->num_parents; i++)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jon Hunter

On multi-socket platforms each socket has its own BPMP which exposes the same clock names. Fix this by appending the NUMA ID as suffix to the clock names for multi-socket platforms.

Use 'sizeof(info->name)' in the strscpy() and snprintf() functions to future proof against anyone changing the size of the 'name' array.

author maintainer
#2 lore raw
In reply to Jon Hunter
Quoted 25 lines · Jon Hunter

On multi-socket platforms each socket has its own BPMP which exposes the same clock names. Fix this by appending the NUMA ID as suffix to the clock names for multi-socket platforms.

Use 'sizeof(info->name)' in the strscpy() and snprintf() functions to future proof against anyone changing the size of the 'name' array.

---
  drivers/clk/tegra/clk-bpmp.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)
drivers/clk/tegra/clk-bpmp.c +2 -1
index f6d2b934228b..428e776561c5 100644
@@ -367,7 +367,15 @@ static int tegra_bpmp_clk_get_info(struct tegra_bpmp *bpmp, unsigned int id,
  	if (err < 0)
  		return err;
 
-	strscpy(info->name, response.name, MRQ_CLK_NAME_MAXLEN);
+	if (dev_to_node(bpmp->dev) == NUMA_NO_NODE) {
+		strscpy(info->name, response.name, sizeof(info->name));

drivers/clk/tegra/clk-bpmp.c static int tegra_bpmp_clk_get_info(struct tegra_bpmp *bpmp, unsigned int id, · line 381

Quoted 10 lines
drivers/clk/tegra/clk-bpmp.c +7 -0
+	} else {
+		err = snprintf(info->name, sizeof(info->name), "%s.%d",
+			       response.name, dev_to_node(bpmp->dev));
+		if (WARN_ON(err >= sizeof(info->name)))
+			return -E2BIG;
+	}
+
  	info->num_parents = response.num_parents;
 
  	for (i = 0; i < info->num_parents; i++)

Thierry commented on a similar patch [0] that his preference is to prefix the NUMA ID rather than append because this is more hierarchical. We agreed that we should be consistent in our approach and do the same here. I will send a V2 with this change.

Jon

[0] https://lore.kernel.org/linux-tegra/ahmsDANt8D7RSYdK@orome/T/#t

Signature · 1 line
nvpublic