Re: [PATCH V10 2/7] interconnect: core: Add dynamic id allocation support

From: Georgi Djakov
Date: Mon Apr 14 2025 - 05:57:42 EST


On 24.03.25 20:31, Raviteja Laggyshetty wrote:
The current interconnect framework relies on static IDs for node
creation and registration, which limits topologies with multiple
instances of the same interconnect provider. To address this,
introduce icc_node_create_dyn() and icc_link_nodes() APIs to
dynamically allocate IDs for interconnect nodes during creation
and link. This change removes the dependency on static IDs,
allowing multiple instances of the same hardware, such as EPSS L3.


Hi Raviteja,

Thank you for working on this!

Signed-off-by: Raviteja Laggyshetty <quic_rlaggysh@xxxxxxxxxxx>
---
drivers/interconnect/core.c | 83 ++++++++++++++++++++++++++-
include/linux/interconnect-provider.h | 12 ++++
include/linux/interconnect.h | 3 +
3 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index 9d5404a07e8a..d4c40c2b3ec1 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -20,6 +20,8 @@
#include "internal.h"
+#define ICC_DYN_ID_START 10000
+
#define CREATE_TRACE_POINTS
#include "trace.h"
@@ -826,7 +828,12 @@ static struct icc_node *icc_node_create_nolock(int id)
if (!node)
return ERR_PTR(-ENOMEM);
- id = idr_alloc(&icc_idr, node, id, id + 1, GFP_KERNEL);
+ /* dynamic id allocation */
+ if (id == ICC_ALLOC_DYN_ID)
+ id = idr_alloc(&icc_idr, node, ICC_DYN_ID_START, 0, GFP_KERNEL);
+ else
+ id = idr_alloc(&icc_idr, node, id, id + 1, GFP_KERNEL);
+
if (id < 0) {
WARN(1, "%s: couldn't get idr\n", __func__);
kfree(node);
@@ -838,6 +845,26 @@ static struct icc_node *icc_node_create_nolock(int id)
return node;
}
+/**
+ * icc_node_create_dyn() - create a node with dynamic id
+ * @id: node id

This function does not take any arguments. Please remove.

+ *
+ * Return: icc_node pointer on success, or ERR_PTR() on error
+ */
+struct icc_node *icc_node_create_dyn(void)
+{
+ struct icc_node *node;
+
+ mutex_lock(&icc_lock);
+
+ node = icc_node_create_nolock(ICC_ALLOC_DYN_ID);
+
+ mutex_unlock(&icc_lock);
+
+ return node;
+}
+EXPORT_SYMBOL_GPL(icc_node_create_dyn);

BR,
Georgi