Skip to contentSkip to conversation

Introduce the Interconnect Subsystem

PATCH Superseded Neil Armstrong 2 participants 17 messages Oct 8, 2025 – Oct 10, 2025

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce the Interconnect Subsystem

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route betweeen those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed

DM Testsuite is provided, testing all the API and nodes lifetime.

Qcom implementation depends on:
- https://lore.kernel.org/all/[email protected]/

---
Changes in v2:
- Simplified nodes linking, looking for nodes at traversal instead of complexe debice reparent
- Populates nodes at bind time, only probinf nodes and providers when a path if found
- With proper refcounting the node lifetime is safe
- DM test is added, testing with a small graph that calculations are good
- Fixed plenty of typo and errors, and dropped useless code
- Dropped RFC since DM test is available, and code works as expected
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Neil Armstrong (7):
Introduce the Interconnect Subsystem
interconnect: add DM test suite
MAINTAINERS: add myself as Maintainer of Interconnect
interconnect: add support for the Qualcomm RPMh helpers
interconnect: add support for the SM8650 SoC
ufs: qcom: vote for interconnect bandwidth on probe
qcom_defconfig: enable interconnect for SM8650

 MAINTAINERS                                      |   10 +
 arch/sandbox/dts/test.dts                        |   36 +
 arch/sandbox/include/asm/interconnect.h          |   19 +
 configs/qcom_defconfig                           |    3 +
 configs/sandbox64_defconfig                      |    2 +
 configs/sandbox_defconfig                        |    2 +
 drivers/Kconfig                                  |    2 +
 drivers/Makefile                                 |    1 +
 drivers/interconnect/Kconfig                     |   22 +
 drivers/interconnect/Makefile                    |    8 +
 drivers/interconnect/interconnect-uclass.c       |  548 +++++++
 drivers/interconnect/qcom/Kconfig                |   12 +
 drivers/interconnect/qcom/Makefile               |    7 +
 drivers/interconnect/qcom/bcm-voter.c            |  340 +++++
 drivers/interconnect/qcom/bcm-voter.h            |   19 +
 drivers/interconnect/qcom/icc-rpmh.c             |  222 +++
 drivers/interconnect/qcom/icc-rpmh.h             |  129 ++
 drivers/interconnect/qcom/sm8650.c               | 1664 ++++++++++++++++++++++
 drivers/interconnect/qcom/sm8650.h               |  144 ++
 drivers/interconnect/sandbox-interconnect-test.c |   89 ++
 drivers/interconnect/sandbox-interconnect.c      |  338 +++++
 drivers/ufs/ufs-qcom.c                           |   13 +
 include/dm/uclass-id.h                           |    2 +
 include/interconnect-uclass.h                    |   74 +
 include/interconnect.h                           |   81 ++
 test/dm/Makefile                                 |    1 +
 test/dm/interconnect.c                           |  148 ++
 27 files changed, 3936 insertions(+)

---
base-commit: b8cea886d50e6c09985256e546904d640f600e4d
change-id: 20251003-topic-interconnect-next-4ed75aecc01c

Best regards,

Signature · 1 line
Neil Armstrong <[email protected]>
#1 lore raw

PATCH v2 1/7 Introduce the Interconnect Subsystem

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
 drivers/Kconfig                            |   2 +
 drivers/Makefile                           |   1 +
 drivers/interconnect/Kconfig               |  10 +
 drivers/interconnect/Makefile              |   6 +
 drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
 include/dm/uclass-id.h                     |   2 +
 include/interconnect-uclass.h              |  74 ++++
 include/interconnect.h                     |  81 +++++
 8 files changed, 724 insertions(+)
drivers/Kconfig +2 -0
index 9e744c27d7ddf786e4c001be3d94ed7323fd5fe3..ab9e689d4d60952d6e495d7919828a700eb25e50 100644
@@ -60,6 +60,8 @@ source "drivers/i3c/Kconfig"
 
 source "drivers/input/Kconfig"
 
+source "drivers/interconnect/Kconfig"
+
 source "drivers/iommu/Kconfig"
 
 source "drivers/led/Kconfig"
drivers/Makefile +1 -0
index 79eabec965f0019cdcf463bd53e02db32bd9bc41..3a3da83771cb5a78232475f3f3d2be9f367b1c2a 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_$(PHASE_)FIRMWARE) +=firmware/
 obj-$(CONFIG_$(PHASE_)I2C) += i2c/
 obj-$(CONFIG_$(PHASE_)I3C) += i3c/
 obj-$(CONFIG_$(PHASE_)INPUT) += input/
+obj-$(CONFIG_$(PHASE_)INTERCONNECT) += interconnect/
 obj-$(CONFIG_$(PHASE_)LED) += led/
 obj-$(CONFIG_$(PHASE_)MMC) += mmc/
 obj-y += mtd/
drivers/interconnect/Kconfig new file +10 -0
new file mode 100644
index 0000000000000000000000000000000000000000..38d39651ab56d441070d3e19a4af60e44fc926d4
@@ -0,0 +1,10 @@
+menu "Interconnect Support"
+
+config INTERCONNECT
+	bool "Enable interconnect support using Driver Model"
+	depends on DM && OF_CONTROL
+	help
+	  Enable support for the interconnect driver class. Many SoCs allow
+	  bandwidth to be tuned on busses within the SoC.
+
+endmenu
drivers/interconnect/Makefile new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1f276e980510e015e56465a48751b07e54d84f1a
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2025 Linaro Limited
+#
+
+obj-$(CONFIG_$(PHASE_)INTERCONNECT) += interconnect-uclass.o
drivers/interconnect/interconnect-uclass.c new file +548 -0

548 lines not on this page · raw message

include/dm/uclass-id.h +2 -0
index 0bd4e64544afd0681c991b1077df1874e08ec32a..d4df46f09229ac309e066903d4ded5e760a73763 100644
@@ -82,6 +82,8 @@ enum uclass_id {
 	UCLASS_I3C,		/* I3C bus */
 	UCLASS_IDE,		/* IDE device */
 	UCLASS_IOMMU,		/* IOMMU */
+	UCLASS_INTERCONNECT,	/* Interconnect */
+	UCLASS_ICC_NODE,	/* Interconnect Node */
 	UCLASS_IRQ,		/* Interrupt controller */
 	UCLASS_KEYBOARD,	/* Keyboard input device */
 	UCLASS_LED,		/* Light-emitting diode (LED) */
include/interconnect-uclass.h new file +74 -0

74 lines not on this page · raw message

include/interconnect.h new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Hi Neil,

Quoted 23 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

Quoted 10 lines
---
 drivers/Kconfig                            |   2 +
 drivers/Makefile                           |   1 +
 drivers/interconnect/Kconfig               |  10 +
 drivers/interconnect/Makefile              |   6 +
 drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
 include/dm/uclass-id.h                     |   2 +
 include/interconnect-uclass.h              |  74 ++++
 include/interconnect.h                     |  81 +++++
 8 files changed, 724 insertions(+)

'interconnect' is such a long and vague word :-)

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Also, please can you add:

- comments to the header file, at least
- something in doc/
- a command to list things / provide information

Great to see the automated tests!

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/driver-model/design.html#removal-stage

#3 lore raw

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 23 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

Quoted 10 lines
---
  drivers/Kconfig                            |   2 +
  drivers/Makefile                           |   1 +
  drivers/interconnect/Kconfig               |  10 +
  drivers/interconnect/Makefile              |   6 +
  drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
  include/dm/uclass-id.h                     |   2 +
  include/interconnect-uclass.h              |  74 ++++
  include/interconnect.h                     |  81 +++++
  8 files changed, 724 insertions(+)
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Quoted 7 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API
- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.
This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

Note I won't re-invent a new API here, the api in interconnect.h is fine and works well, I made sure to use all U-Boot driver model offers to avoir allocating random objects myself, and keep the interconnect core functions strictly identical to the kernel, making it:
- well integrated in DM (on-demand probe, nodes as DM devices)
- resulting with the same results as in Linux
- using the same API
- easy to sync back from Linux
- easy to port a driver from Linux

Quoted 6 lines

Also, please can you add:

- comments to the header file, at least
- something in doc/
- a command to list things / provide information

Yep, I'll add those.

Thanks,
Neil

Quoted 7 lines

Great to see the automated tests!

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/driver-model/design.html#removal-stage

#4 lore raw

Hi Neil,

Quoted 41 lines · Neil Armstrong

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 33 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
  drivers/Kconfig                            |   2 +
  drivers/Makefile                           |   1 +
  drivers/interconnect/Kconfig               |  10 +
  drivers/interconnect/Makefile              |   6 +
  drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
  include/dm/uclass-id.h                     |   2 +
  include/interconnect-uclass.h              |  74 ++++
  include/interconnect.h                     |  81 +++++
  8 files changed, 724 insertions(+)
Quoted 8 lines
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Yes, we should use the same name. Docs can help.

Quoted 15 lines
Quoted 8 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Quoted 7 lines

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API

OK, I missed that.

Quoted 3 lines

- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

We do a similar think with clk, although the function signature is different in U-Boot from Linux.

I assume the caller would be a driver? If so, passing in a struct icc_path * might be more efficient than using malloc() each time.

Quoted 10 lines

Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.

OK

Quoted 3 lines

This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

The specific code is this:

+ device_foreach_child(pos, dev) {

+               debug("%s(pos=%s)\n", __func__, pos->name);
+               ret = device_remove(pos, DM_REMOVE_NORMAL);
+               if (ret)

+ return ret;
+ }

This is in the pre_remove() method. But if you just remove that code, doesn't driver model remove the children anyway?

Quoted 10 lines

Note I won't re-invent a new API here, the api in interconnect.h is fine and works well, I made sure to use all U-Boot driver model offers to avoir allocating random objects myself, and keep the interconnect core functions strictly identical to the kernel, making it:
- well integrated in DM (on-demand probe, nodes as DM devices)
- resulting with the same results as in Linux
- using the same API
- easy to sync back from Linux
- easy to port a driver from Linux

Yes that sounds good.

Quoted 9 lines
Quoted 7 lines

Also, please can you add:

- comments to the header file, at least
- something in doc/
- a command to list things / provide information

Yep, I'll add those.

OK thanks.

Quoted 12 lines

Thanks,
Neil

Quoted 7 lines

Great to see the automated tests!

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/driver-model/design.html#removal-stage

Regards,
Simon

#5 lore raw
Quoted 84 lines · Simon Glass

Hi Neil,

Quoted 41 lines · Neil Armstrong

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 33 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
   drivers/Kconfig                            |   2 +
   drivers/Makefile                           |   1 +
   drivers/interconnect/Kconfig               |  10 +
   drivers/interconnect/Makefile              |   6 +
   drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
   include/dm/uclass-id.h                     |   2 +
   include/interconnect-uclass.h              |  74 ++++
   include/interconnect.h                     |  81 +++++
   8 files changed, 724 insertions(+)
Quoted 8 lines
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Yes, we should use the same name. Docs can help.

Quoted 15 lines
Quoted 8 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Quoted 7 lines

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API

OK, I missed that.

Quoted 3 lines

- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

Quoted 5 lines

We do a similar think with clk, although the function signature is different in U-Boot from Linux.

I assume the caller would be a driver? If so, passing in a struct icc_path * might be more efficient than using malloc() each time.

I'm not against that but the size of icc_path depends on it's size:

+struct icc_path {
+ size_t num_nodes;
+ struct icc_req reqs[];
+};

So we would still need to alloc the reqs anyway and expose the internals with no benefits.

Quoted 27 lines
Quoted 11 lines

Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.

OK

Quoted 3 lines

This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

The specific code is this:

drivers/interconnect/interconnect-uclass.c new file +6 -0
+       device_foreach_child(pos, dev) {
+               debug("%s(pos=%s)\n", __func__, pos->name);
+               ret = device_remove(pos, DM_REMOVE_NORMAL);
+               if (ret)
+                       return ret;
+       }
Quoted 2 lines

This is in the pre_remove() method. But if you just remove that code, doesn't driver model remove the children anyway?

No it only removes the children from the same driver:
=============><=====================
int device_chld_remove(struct udevice *dev, struct driver *drv,
uint flags)
{

<snip>

	device_foreach_child_safe(pos, n, dev) {
		int ret;

		if (drv && (pos->driver != drv))
			continue;

=============><=====================
Same for unbind.

Added in https://lists.denx.de/pipermail/u-boot/2018-June/332597.html with the bind/unbind command.

So perhaps I'm doing something unintended here, I was also expecting removing/unbinding a device would remove all the childs whatever the uclass.

Neil

Quoted 41 lines
Quoted 11 lines

Note I won't re-invent a new API here, the api in interconnect.h is fine and works well, I made sure to use all U-Boot driver model offers to avoir allocating random objects myself, and keep the interconnect core functions strictly identical to the kernel, making it:
- well integrated in DM (on-demand probe, nodes as DM devices)
- resulting with the same results as in Linux
- using the same API
- easy to sync back from Linux
- easy to port a driver from Linux

Yes that sounds good.

Quoted 9 lines
Quoted 7 lines

Also, please can you add:

- comments to the header file, at least
- something in doc/
- a command to list things / provide information

Yep, I'll add those.

OK thanks.

Quoted 12 lines

Thanks,
Neil

Quoted 7 lines

Great to see the automated tests!

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/driver-model/design.html#removal-stage

Regards,
Simon

#6 lore raw

Hi Neil,

Quoted 99 lines · Neil Armstrong
Quoted 84 lines · Simon Glass

Hi Neil,

Quoted 41 lines · Neil Armstrong

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 33 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
   drivers/Kconfig                            |   2 +
   drivers/Makefile                           |   1 +
   drivers/interconnect/Kconfig               |  10 +
   drivers/interconnect/Makefile              |   6 +
   drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
   include/dm/uclass-id.h                     |   2 +
   include/interconnect-uclass.h              |  74 ++++
   include/interconnect.h                     |  81 +++++
   8 files changed, 724 insertions(+)
Quoted 8 lines
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Yes, we should use the same name. Docs can help.

Quoted 15 lines
Quoted 8 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Quoted 7 lines

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API

OK, I missed that.

Quoted 3 lines

- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

Quoted 5 lines

We do a similar think with clk, although the function signature is different in U-Boot from Linux.

I assume the caller would be a driver? If so, passing in a struct icc_path * might be more efficient than using malloc() each time.

I'm not against that but the size of icc_path depends on it's size:

include/interconnect-uclass.h new file +4 -0
+struct icc_path {
+       size_t num_nodes;
+       struct icc_req reqs[];
+};
Quoted 2 lines

So we would still need to alloc the reqs anyway and expose the internals with no benefits.

Indeed. Sometimes in U-Boot we use fixed sizes to avoid realloc(), but I'm not sure if it makes sense here.

Quoted 44 lines
Quoted 28 lines
Quoted 7 lines

Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

Quoted 5 lines

The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.

OK

Quoted 3 lines

This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

The specific code is this:

drivers/interconnect/interconnect-uclass.c new file +6 -0
+       device_foreach_child(pos, dev) {
+               debug("%s(pos=%s)\n", __func__, pos->name);
+               ret = device_remove(pos, DM_REMOVE_NORMAL);
+               if (ret)
+                       return ret;
+       }
Quoted 2 lines

This is in the pre_remove() method. But if you just remove that code, doesn't driver model remove the children anyway?

No it only removes the children from the same driver:
=============><=====================
int device_chld_remove(struct udevice *dev, struct driver *drv,
uint flags)
{

<snip>

        device_foreach_child_safe(pos, n, dev) {
                int ret;

                if (drv && (pos->driver != drv))
                        continue;
Quoted 4 lines

=============><=====================
Same for unbind.

Added in https://lists.denx.de/pipermail/u-boot/2018-June/332597.html with the bind/unbind command.

Ick, that is a bug.

Quoted 4 lines

So perhaps I'm doing something unintended here, I was also expecting removing/unbinding a device would remove all the childs whatever the uclass.

Yes, it should be fixed.

Regards,
Simon

Quoted 45 lines

Neil

Quoted 41 lines
Quoted 11 lines

Note I won't re-invent a new API here, the api in interconnect.h is fine and works well, I made sure to use all U-Boot driver model offers to avoir allocating random objects myself, and keep the interconnect core functions strictly identical to the kernel, making it:
- well integrated in DM (on-demand probe, nodes as DM devices)
- resulting with the same results as in Linux
- using the same API
- easy to sync back from Linux
- easy to port a driver from Linux

Yes that sounds good.

Quoted 9 lines
Quoted 7 lines

Also, please can you add:

- comments to the header file, at least
- something in doc/
- a command to list things / provide information

Yep, I'll add those.

OK thanks.

Quoted 12 lines

Thanks,
Neil

Quoted 7 lines

Great to see the automated tests!

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/driver-model/design.html#removal-stage

Regards,
Simon

#7 lore raw
Quoted 157 lines · Simon Glass

Hi Neil,

Quoted 99 lines · Neil Armstrong
Quoted 84 lines · Simon Glass

Hi Neil,

Quoted 41 lines · Neil Armstrong

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 33 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
    drivers/Kconfig                            |   2 +
    drivers/Makefile                           |   1 +
    drivers/interconnect/Kconfig               |  10 +
    drivers/interconnect/Makefile              |   6 +
    drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
    include/dm/uclass-id.h                     |   2 +
    include/interconnect-uclass.h              |  74 ++++
    include/interconnect.h                     |  81 +++++
    8 files changed, 724 insertions(+)
Quoted 8 lines
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Yes, we should use the same name. Docs can help.

Quoted 15 lines
Quoted 8 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Quoted 7 lines

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API

OK, I missed that.

Quoted 3 lines

- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

Quoted 5 lines

We do a similar think with clk, although the function signature is different in U-Boot from Linux.

I assume the caller would be a driver? If so, passing in a struct icc_path * might be more efficient than using malloc() each time.

I'm not against that but the size of icc_path depends on it's size:

include/interconnect-uclass.h new file +4 -0
+struct icc_path {
+       size_t num_nodes;
+       struct icc_req reqs[];
+};
Quoted 2 lines

So we would still need to alloc the reqs anyway and expose the internals with no benefits.

Indeed. Sometimes in U-Boot we use fixed sizes to avoid realloc(), but I'm not sure if it makes sense here.

Quoted 44 lines
Quoted 28 lines
Quoted 7 lines

Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

Quoted 5 lines

The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.

OK

Quoted 3 lines

This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

The specific code is this:

drivers/interconnect/interconnect-uclass.c new file +6 -0
+       device_foreach_child(pos, dev) {
+               debug("%s(pos=%s)\n", __func__, pos->name);
+               ret = device_remove(pos, DM_REMOVE_NORMAL);
+               if (ret)
+                       return ret;
+       }
Quoted 2 lines

This is in the pre_remove() method. But if you just remove that code, doesn't driver model remove the children anyway?

No it only removes the children from the same driver:
=============><=====================
int device_chld_remove(struct udevice *dev, struct driver *drv,
uint flags)
{

<snip>

         device_foreach_child_safe(pos, n, dev) {
                 int ret;

                 if (drv && (pos->driver != drv))
                         continue;
Quoted 4 lines

=============><=====================
Same for unbind.

Added in https://lists.denx.de/pipermail/u-boot/2018-June/332597.html with the bind/unbind command.

Quoted 8 lines

Ick, that is a bug.

Quoted 4 lines

So perhaps I'm doing something unintended here, I was also expecting removing/unbinding a device would remove all the childs whatever the uclass.

Yes, it should be fixed.

I guess it should be fixed and a test case added.

Should I handle this ?

Neil

Quoted 49 lines

Regards,
Simon

Quoted 45 lines

Neil

Quoted 41 lines
Quoted 11 lines

Note I won't re-invent a new API here, the api in interconnect.h is fine and works well, I made sure to use all U-Boot driver model offers to avoir allocating random objects myself, and keep the interconnect core functions strictly identical to the kernel, making it:
- well integrated in DM (on-demand probe, nodes as DM devices)
- resulting with the same results as in Linux
- using the same API
- easy to sync back from Linux
- easy to port a driver from Linux

Yes that sounds good.

Quoted 9 lines
Quoted 7 lines

Also, please can you add:

- comments to the header file, at least
- something in doc/
- a command to list things / provide information

Yep, I'll add those.

OK thanks.

Quoted 12 lines

Thanks,
Neil

Quoted 7 lines

Great to see the automated tests!

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/driver-model/design.html#removal-stage

Regards,
Simon

#8 lore raw
Quoted 165 lines · Neil Armstrong
Quoted 164 lines · Simon Glass

Hi Neil,

Quoted 99 lines · Neil Armstrong
Quoted 84 lines · Simon Glass

Hi Neil,

Quoted 41 lines · Neil Armstrong

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 33 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
    drivers/Kconfig                            |   2 + drivers/Makefile                           |   1 + drivers/interconnect/Kconfig               |  10 + drivers/interconnect/Makefile              |   6 + drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++ include/dm/uclass-id.h                     |   2 + include/interconnect-uclass.h              |  74 ++++ include/interconnect.h                     |  81 +++++

    8 files changed, 724 insertions(+)
Quoted 8 lines
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Yes, we should use the same name. Docs can help.

Quoted 15 lines
Quoted 8 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Quoted 7 lines

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API

OK, I missed that.

Quoted 3 lines

- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

Quoted 5 lines

We do a similar think with clk, although the function signature is different in U-Boot from Linux.

I assume the caller would be a driver? If so, passing in a struct icc_path * might be more efficient than using malloc() each time.

I'm not against that but the size of icc_path depends on it's size:

(quoted diff) +4 -0
+struct icc_path {
+       size_t num_nodes;
+       struct icc_req reqs[];
+};
Quoted 2 lines

So we would still need to alloc the reqs anyway and expose the internals with no benefits.

Indeed. Sometimes in U-Boot we use fixed sizes to avoid realloc(), but I'm not sure if it makes sense here.

Quoted 42 lines
Quoted 28 lines
Quoted 7 lines

     Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

Quoted 5 lines

     The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

     I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.

OK

Quoted 3 lines

     This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

The specific code is this:

+       device_foreach_child(pos, dev) {
+               debug("%s(pos=%s)\n", __func__, pos->name); +               ret = device_remove(pos, DM_REMOVE_NORMAL); +               if (ret)
+                       return ret;
+       }

Quoted 2 lines

This is in the pre_remove() method. But if you just remove that code, doesn't driver model remove the children anyway?

No it only removes the children from the same driver:
=============><=====================
int device_chld_remove(struct udevice *dev, struct driver *drv, uint flags)
{

<snip>

         device_foreach_child_safe(pos, n, dev) {
                 int ret;

Quoted 6 lines

                 if (drv && (pos->driver != drv))
                         continue;
=============><=====================
Same for unbind.

Added in https://lists.denx.de/pipermail/u-boot/2018-June/332597.html with the bind/unbind command.

Ick, that is a bug.

Quoted 4 lines

So perhaps I'm doing something unintended here, I was also expecting removing/unbinding a device would remove all the childs whatever the uclass.

Quoted 5 lines
Quoted 1 line

Yes, it should be fixed.

I guess it should be fixed and a test case added.

Should I handle this ?

Wait the code is right, but still it doesn't work properly.

I'll investigate further to understand.

Neil

Quoted 53 lines

Neil

Quoted 49 lines

Regards,
Simon

Quoted 45 lines

Neil

Quoted 41 lines
Quoted 11 lines

Note I won't re-invent a new API here, the api in interconnect.h is fine and works well, I made sure to use all U-Boot driver model offers to avoir allocating random objects myself, and keep the interconnect core functions strictly identical to the kernel, making it:
- well integrated in DM (on-demand probe, nodes as DM devices)
- resulting with the same results as in Linux
- using the same API
- easy to sync back from Linux
- easy to port a driver from Linux

Yes that sounds good.

Quoted 9 lines
Quoted 7 lines

Also, please can you add:

- comments to the header file, at least
- something in doc/
- a command to list things / provide information

Yep, I'll add those.

OK thanks.

Quoted 12 lines

Thanks,
Neil

Quoted 7 lines

Great to see the automated tests!

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/driver-model/design.html#removal-stage

Regards,
Simon

#9 lore raw

Hi Neil,

Quoted 169 lines · Neil Armstrong
Quoted 167 lines · Neil Armstrong
Quoted 165 lines · Simon Glass

Hi Neil,

Quoted 99 lines · Neil Armstrong
Quoted 84 lines · Simon Glass

Hi Neil,

Quoted 41 lines · Neil Armstrong

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 33 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
    drivers/Kconfig                            |   2 +
    drivers/Makefile                           |   1 +
    drivers/interconnect/Kconfig               |  10 +
    drivers/interconnect/Makefile              |   6 +
    drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
    include/dm/uclass-id.h                     |   2 +
    include/interconnect-uclass.h              |  74 ++++
    include/interconnect.h                     |  81 +++++
    8 files changed, 724 insertions(+)
Quoted 8 lines
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Yes, we should use the same name. Docs can help.

Quoted 15 lines
Quoted 8 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Quoted 7 lines

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API

OK, I missed that.

Quoted 3 lines

- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

Quoted 5 lines

We do a similar think with clk, although the function signature is different in U-Boot from Linux.

I assume the caller would be a driver? If so, passing in a struct icc_path * might be more efficient than using malloc() each time.

I'm not against that but the size of icc_path depends on it's size:

(quoted diff) +4 -0
+struct icc_path {
+       size_t num_nodes;
+       struct icc_req reqs[];
+};
Quoted 2 lines

So we would still need to alloc the reqs anyway and expose the internals with no benefits.

Indeed. Sometimes in U-Boot we use fixed sizes to avoid realloc(), but I'm not sure if it makes sense here.

Quoted 44 lines
Quoted 28 lines
Quoted 7 lines

Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

Quoted 5 lines

The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.

OK

Quoted 3 lines

This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

The specific code is this:

(quoted diff) +6 -0
+       device_foreach_child(pos, dev) {
+               debug("%s(pos=%s)\n", __func__, pos->name);
+               ret = device_remove(pos, DM_REMOVE_NORMAL);
+               if (ret)
+                       return ret;
+       }
Quoted 2 lines

This is in the pre_remove() method. But if you just remove that code, doesn't driver model remove the children anyway?

No it only removes the children from the same driver:
=============><=====================
int device_chld_remove(struct udevice *dev, struct driver *drv,
uint flags)
{

<snip>

         device_foreach_child_safe(pos, n, dev) {
                 int ret;

                 if (drv && (pos->driver != drv))
                         continue;
Quoted 4 lines

=============><=====================
Same for unbind.

Added in https://lists.denx.de/pipermail/u-boot/2018-June/332597.html with the bind/unbind command.

Ick, that is a bug.

Quoted 4 lines

So perhaps I'm doing something unintended here, I was also expecting removing/unbinding a device would remove all the childs whatever the uclass.

Yes, it should be fixed.

Quoted 7 lines
Quoted 3 lines

I guess it should be fixed and a test case added.

Should I handle this ?

Wait the code is right, but still it doesn't work properly.

I'll investigate further to understand.

OK...I'm not sure what that patch was about, but if the command needs to work that way you could create a new function, e.g. device_remove_by_drv() which only removes things for particular drivers?

Regards,
Simon

#10 lore raw
Quoted 176 lines · Simon Glass

Hi Neil,

Quoted 173 lines · Neil Armstrong
Quoted 170 lines · Neil Armstrong
Quoted 157 lines · Simon Glass

Hi Neil,

Quoted 99 lines · Neil Armstrong
Quoted 84 lines · Simon Glass

Hi Neil,

Quoted 41 lines · Neil Armstrong

Hi,

Quoted 37 lines · Simon Glass

Hi Neil,

Quoted 33 lines · Neil Armstrong

Let's introduce the Interconnect subsystem based on the Linux framework which is used to vote for bandwidth across multiple SoC busses.

Each bus endpoints are materialised as "nodes" which are linked together, and the DT will specify a pair of nodes to enable and set a bandwidth on the route between those endpoints.

The hardware resources that provide those nodes and provides the way to vote for the bandwidth are called "providers".

The Interconnect uclass code is heavily based on the Linux one, with some small differences:
- nodes are allocated as udevices instead of Linux idr_alloc()
- tag management is minimal, only normal xlate is supported
- dynamic IDs is not implemented
- getting nodes states at probe is not implemented
- providers are probed on demand while the nodes links are traversed
- nodes are populated on bind

Fully tested with associated DM test suite.

---
     drivers/Kconfig                            |   2 +
     drivers/Makefile                           |   1 +
     drivers/interconnect/Kconfig               |  10 +
     drivers/interconnect/Makefile              |   6 +
     drivers/interconnect/interconnect-uclass.c | 548 +++++++++++++++++++++++++++++
     include/dm/uclass-id.h                     |   2 +
     include/interconnect-uclass.h              |  74 ++++
     include/interconnect.h                     |  81 +++++
     8 files changed, 724 insertions(+)
Quoted 8 lines
Quoted 1 line

'interconnect' is such a long and vague word :-)

I didn't chose the name => https://docs.kernel.org/driver-api/interconnect.html

I don't see why we should take a different name in U-Boot.

But I can definitely use "Generic System Interconnect" in the documentation and commit messages if it's clearer.

Yes, we should use the same name. Docs can help.

Quoted 15 lines
Quoted 8 lines

There seems to be a piece missing here. The uclass should have operations, so that it makes sense for different drivers to implement the methods. I see some there, but also a lot of direct calls from the test to sandbox. I see quite a few functions which lack a struct udevice * - I suspect I am missing something?

Quoted 6 lines

We normally have a ..._get_ops() macro in the uclass header. Also we normally have stub functions which get the ops and call the function.

I see code to remove children, but driver model does this automatically[1]. Same with bind(). If there is a bug in this, can you give a few details, or ideally a test case?

Quoted 7 lines

All of this is present and well thought, I went into multiple designs:
- interconnect uclass provides ops -> interconnect_ops, icc_node doesn't provide any ops since they are just internal objects
- there's only a single direct call to the sandbox driver to get the setting resulting of the aggregate() & set() op calls, this is purely for validation of the calculations, the sandbox-interconnect-test only uses the public inteconnect.h API

OK, I missed that.

Quoted 3 lines

- For the lack of udevice, it's because I did use the same interconnect API which return a "icc_path" private structure which contains a set of interconnect nodes which forms path across the different providers.

Quoted 5 lines

We do a similar think with clk, although the function signature is different in U-Boot from Linux.

I assume the caller would be a driver? If so, passing in a struct icc_path * might be more efficient than using malloc() each time.

I'm not against that but the size of icc_path depends on it's size:

(quoted diff) +4 -0
+struct icc_path {
+       size_t num_nodes;
+       struct icc_req reqs[];
+};
Quoted 2 lines

So we would still need to alloc the reqs anyway and expose the internals with no benefits.

Indeed. Sometimes in U-Boot we use fixed sizes to avoid realloc(), but I'm not sure if it makes sense here.

Quoted 44 lines
Quoted 28 lines
Quoted 7 lines

Setting a bandwidth on a node is meaningless, same for interconnect providers, this is why we set a bandwidth on a set of nodes, which get aggregated with the other path votes from other devices.

Quoted 5 lines

The key here is the "nodes" which are subdevices of interconnect providers created at bind time, and gets referenced in icc_path objects.

I made sure we can't remove either interconnect devices or icc_node devices if they are still referenced in an active icc_path.

OK

Quoted 3 lines

This is the reason of the device_remove() & device_unbind() calls in the test to make sure we're not left with dangling pointers to non-existent icc_node and providers devices.

The specific code is this:

(quoted diff) +6 -0
+       device_foreach_child(pos, dev) {
+               debug("%s(pos=%s)\n", __func__, pos->name);
+               ret = device_remove(pos, DM_REMOVE_NORMAL);
+               if (ret)
+                       return ret;
+       }
Quoted 2 lines

This is in the pre_remove() method. But if you just remove that code, doesn't driver model remove the children anyway?

No it only removes the children from the same driver:
=============><=====================
int device_chld_remove(struct udevice *dev, struct driver *drv,
uint flags)
{

<snip>

          device_foreach_child_safe(pos, n, dev) {
                  int ret;

                  if (drv && (pos->driver != drv))
                          continue;
Quoted 4 lines

=============><=====================
Same for unbind.

Added in https://lists.denx.de/pipermail/u-boot/2018-June/332597.html with the bind/unbind command.

Quoted 8 lines

Ick, that is a bug.

Quoted 4 lines

So perhaps I'm doing something unintended here, I was also expecting removing/unbinding a device would remove all the childs whatever the uclass.

Yes, it should be fixed.

I guess it should be fixed and a test case added.

Should I handle this ?

Quoted 8 lines
Quoted 3 lines

Wait the code is right, but still it doesn't work properly.

I'll investigate further to understand.

OK...I'm not sure what that patch was about, but if the command needs to work that way you could create a new function, e.g. device_remove_by_drv() which only removes things for particular drivers?

Yeah my bad, it works as intended, I did a bad iteration where the parent was wrong and it didn't work, I can remove everything and it works fine.

Neil

Quoted 3 lines

Regards,
Simon

#11 lore raw

PATCH v2 2/7 interconnect: add DM test suite

In reply to Neil Armstrong

Add a test suite exercising the whole lifetime and callbacks of interconnect with a fake 5 providers with a split node graph.

The test suite checks the calculus are right and goes to the correct nodes, and the lifetime of the node is correct.

---
 arch/sandbox/dts/test.dts                        |  36 +++
 arch/sandbox/include/asm/interconnect.h          |  19 ++
 configs/sandbox64_defconfig                      |   2 +
 configs/sandbox_defconfig                        |   2 +
 drivers/interconnect/Kconfig                     |  10 +
 drivers/interconnect/Makefile                    |   1 +
 drivers/interconnect/sandbox-interconnect-test.c |  89 ++++++
 drivers/interconnect/sandbox-interconnect.c      | 338 +++++++++++++++++++++++
 test/dm/Makefile                                 |   1 +
 test/dm/interconnect.c                           | 148 ++++++++++
 10 files changed, 646 insertions(+)
arch/sandbox/dts/test.dts +36 -0
index c9a05cd625613e2f8b2cae771403ce36e5d06f42..1c34f4a8fdc6e25fa66debd11ff4d0119d9373c8 100644
@@ -862,6 +862,42 @@
 		};
 	};
 
+	icc0: interconnect-0 {
+		compatible = "sandbox,interconnect0";
+		#interconnect-cells = <1>;
+	};
+
+	icc1: interconnect-1 {
+		compatible = "sandbox,interconnect1";
+		#interconnect-cells = <1>;
+	};
+
+	icc2: interconnect-2 {
+		compatible = "sandbox,interconnect2";
+		#interconnect-cells = <1>;
+	};
+
+	icc3: interconnect-3 {
+		compatible = "sandbox,interconnect3";
+		#interconnect-cells = <1>;
+	};
+
+	icc4: interconnect-4 {
+		compatible = "sandbox,interconnect4";
+		#interconnect-cells = <1>;
+	};
+
+	interconnect-test-0 {
+		compatible = "sandbox,interconnect-test";
+		interconnects = <&icc0 0 &icc3 0>;
+	};
+
+	interconnect-test-1 {
+		compatible = "sandbox,interconnect-test";
+		interconnects = <&icc1 0 &icc4 0>;
+		interconnect-names = "icc-path";
+	};
+
 	i2c@0 {
 		#address-cells = <1>;
 		#size-cells = <0>;
arch/sandbox/include/asm/interconnect.h new file +19 -0
new file mode 100644
index 0000000000000000000000000000000000000000..17065bf6a11d7b0e62c937df593535a4664b7c14
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2025 Linaro Limited
+ */
+
+#ifndef __SANDBOX_INTERCONNECT_H
+#define __SANDBOX_INTERCONNECT_H
+
+struct udevice;
+
+int sandbox_interconnect_get_bw(struct udevice *dev, u64 *avg, u64 *peak);
+int sandbox_interconnect_test_get(struct udevice *dev, char *name);
+int sandbox_interconnect_test_get_index(struct udevice *dev, int index);
+int sandbox_interconnect_test_enable(struct udevice *dev);
+int sandbox_interconnect_test_disable(struct udevice *dev);
+int sandbox_interconnect_test_set_bw(struct udevice *dev, u32 avg_bw, u32 peak_bw);
+int sandbox_interconnect_test_put(struct udevice *dev);
+
+#endif
configs/sandbox64_defconfig +2 -0
index 4ff82426a365fdf5c18a2c1292626c58fe172c40..0ea4166b1b2a4ca1cfa21150f6c41a1c158d9945 100644
@@ -202,6 +202,8 @@ CONFIG_PINCTRL_SANDBOX=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_SANDBOX_POWER_DOMAIN=y
+CONFIG_INTERCONNECT=y
+CONFIG_INTERCONNECT_SANDBOX=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_ACT8846=y
 CONFIG_DM_PMIC_PFUZE100=y
configs/sandbox_defconfig +2 -0
index 39ef596b8e330aed3c52b494534ebbdc3d3378dd..dbe51691d0a30d6c9b60f9f1a3db1c4c83dc5e6e 100644
@@ -283,6 +283,8 @@ CONFIG_PINCTRL_SANDBOX=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_SANDBOX_POWER_DOMAIN=y
+CONFIG_INTERCONNECT=y
+CONFIG_INTERCONNECT_SANDBOX=y
 CONFIG_SCMI_POWER_DOMAIN=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_ACT8846=y
drivers/interconnect/Kconfig +10 -0
index 38d39651ab56d441070d3e19a4af60e44fc926d4..e9f4cc662aec40f5d0053186cfeaa96b22fd6b3c 100644
@@ -7,4 +7,14 @@ config INTERCONNECT
 	  Enable support for the interconnect driver class. Many SoCs allow
 	  bandwidth to be tuned on busses within the SoC.
 
+if INTERCONNECT
+
+config INTERCONNECT_SANDBOX
+	bool "Enable interconnect sandbox driver"
+	depends on SANDBOX
+	help
+	  Enable support for the interconnect sandbox drivers.
+
+endif
+
 endmenu
drivers/interconnect/Makefile +1 -0
index 1f276e980510e015e56465a48751b07e54d84f1a..04b18589b7ff7eef9f8b5fcf47c36bd82a48e802 100644
@@ -4,3 +4,4 @@
 #
 
 obj-$(CONFIG_$(PHASE_)INTERCONNECT) += interconnect-uclass.o
+obj-$(CONFIG_$(PHASE_)INTERCONNECT_SANDBOX) += sandbox-interconnect.o sandbox-interconnect-test.o
drivers/interconnect/sandbox-interconnect-test.c new file +89 -0

89 lines not on this page · raw message

drivers/interconnect/sandbox-interconnect.c new file +338 -0

338 lines not on this page · raw message

test/dm/Makefile +1 -0
index 9ffe0faee75e82be7b91579181fdc22406bfd7c3..0ddf47885239e737f04b931f6d2da4b92ec09f33 100644
@@ -57,6 +57,7 @@ obj-$(CONFIG_DM_FPGA) += fpga.o
 obj-$(CONFIG_FWU_MDATA_GPT_BLK) += fwu_mdata.o
 obj-$(CONFIG_SANDBOX) += host.o
 obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o
+obj-$(CONFIG_INTERCONNECT) += interconnect.o
 obj-$(CONFIG_DM_I2C) += i2c.o
 obj-$(CONFIG_I3C) += i3c.o
 obj-$(CONFIG_SOUND) += i2s.o
test/dm/interconnect.c new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 3/7 MAINTAINERS: add myself as Maintainer of Interconnect

In reply to Neil Armstrong

I'll maintain the Interconnect subsystem.

---
 MAINTAINERS | 10 ++++++++++
 1 file changed, 10 insertions(+)
MAINTAINERS +10 -0
index 3fb163aa1db1dba249e60b40ab3e785db4fde5d3..fc48ffe99884137eb407d4ed52a70ce51ba15e04 100644
@@ -1244,6 +1244,16 @@ S:	Maintained
 F:	drivers/misc/gsc.c
 F:	include/gsc.h
 
+INTERCONNECT:
+M:	Neil Armstrong <[email protected]>
+S:	Maintained
+T:	git https://source.denx.de/u-boot/u-boot.git
+F:	arch/sandbox/include/asm/interconnect.h
+F:	drivers/interconnect/
+F:	include/interconnect-uclass.h
+F:	include/interconnect.h
+F:	test/dm/interconnect.c
+
 I2C
 M:	Heiko Schocher <[email protected]>
 S:	Maintained
Signature · 1 line
2.34.1
#13 lore raw

PATCH v2 4/7 interconnect: add support for the Qualcomm RPMh helpers

In reply to Neil Armstrong

The Qualcomm SoCs votes for common resources via the RPMh subsystem.

Implement the necessary helpers for Interconnect providers to add the nodes and vote via the RPPh "BCM" voters, which are vote endpoints for each SoC subsystems. The APPS (ARM subsystem) has a dedicated endpoint.

The BCM voter will aggregate all the bandwidth for all the nodes associated with a BCM voter, and internally the RPMh with also aggregate all the votes from all the SoC subsystems for the same BCM voter.

---
 drivers/interconnect/Kconfig          |   2 +
 drivers/interconnect/Makefile         |   1 +
 drivers/interconnect/qcom/Kconfig     |   6 +
 drivers/interconnect/qcom/Makefile    |   6 +
 drivers/interconnect/qcom/bcm-voter.c | 340 ++++++++++++++++++++++++++++++++++
 drivers/interconnect/qcom/bcm-voter.h |  19 ++
 drivers/interconnect/qcom/icc-rpmh.c  | 222 ++++++++++++++++++++++
 drivers/interconnect/qcom/icc-rpmh.h  | 129 +++++++++++++
 8 files changed, 725 insertions(+)
drivers/interconnect/Kconfig +2 -0
index e9f4cc662aec40f5d0053186cfeaa96b22fd6b3c..de868b9ad3804a3ac4416354d3d2ef6a1cd81f65 100644
@@ -15,6 +15,8 @@ config INTERCONNECT_SANDBOX
 	help
 	  Enable support for the interconnect sandbox drivers.
 
+source "drivers/interconnect/qcom/Kconfig"
+
 endif
 
 endmenu
drivers/interconnect/Makefile +1 -0
index 04b18589b7ff7eef9f8b5fcf47c36bd82a48e802..c9e8077b0f12da5225d4efa1ad371958ceeaf570 100644
@@ -5,3 +5,4 @@
 
 obj-$(CONFIG_$(PHASE_)INTERCONNECT) += interconnect-uclass.o
 obj-$(CONFIG_$(PHASE_)INTERCONNECT_SANDBOX) += sandbox-interconnect.o sandbox-interconnect-test.o
+obj-y += qcom/
drivers/interconnect/qcom/Kconfig new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ab5b19567ec783a8d3dd11776fa7015fd9e59462
@@ -0,0 +1,6 @@
+config INTERCONNECT_QCOM_RPMH
+	bool "Enable interconnect support for SoCs with RPMh"
+	depends on QCOM_RPMH
+	help
+	  Enable support for the interconnect helpers to vote with
+	  the RPMh subsystems in Qualcomm SoCs
drivers/interconnect/qcom/Makefile new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4369ca07f611f9a61103f6aa893841e137e68aea
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2025 Linaro Limited
+#
+
+obj-$(CONFIG_$(PHASE_)INTERCONNECT_QCOM_RPMH) += icc-rpmh.o bcm-voter.o
drivers/interconnect/qcom/bcm-voter.c new file +340 -0

340 lines not on this page · raw message

drivers/interconnect/qcom/bcm-voter.h new file +19 -0
new file mode 100644
index 0000000000000000000000000000000000000000..5acb5822e0e04c5d4e0ca553397692d1fd919c51
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef __DRIVERS_INTERCONNECT_QCOM_BCM_VOTER_H__
+#define __DRIVERS_INTERCONNECT_QCOM_BCM_VOTER_H__
+
+#include <soc/qcom/cmd-db.h>
+#include <soc/qcom/rpmh.h>
+#include <soc/qcom/tcs.h>
+
+#include "icc-rpmh.h"
+
+struct bcm_voter *of_bcm_voter_get(struct udevice *dev, const char *name);
+void qcom_icc_bcm_voter_add(struct bcm_voter *voter, struct qcom_icc_bcm *bcm);
+int qcom_icc_bcm_voter_commit(struct bcm_voter *voter);
+
+#endif
drivers/interconnect/qcom/icc-rpmh.c new file +222 -0

222 lines not on this page · raw message

drivers/interconnect/qcom/icc-rpmh.h new file +129 -0

129 lines not on this page · raw message

Signature · 1 line
2.34.1
#14 lore raw

PATCH v2 5/7 interconnect: add support for the SM8650 SoC

In reply to Neil Armstrong

Add the SM8650 Interconnect nodes definitions, this is heavily based on the Linux driver without the QoS definitions.

---
 drivers/interconnect/qcom/Kconfig  |    6 +
 drivers/interconnect/qcom/Makefile |    1 +
 drivers/interconnect/qcom/sm8650.c | 1664 ++++++++++++++++++++++++++++++++++++
 drivers/interconnect/qcom/sm8650.h |  144 ++++
 4 files changed, 1815 insertions(+)
drivers/interconnect/qcom/Kconfig +6 -0
index ab5b19567ec783a8d3dd11776fa7015fd9e59462..b105c3a1f9acf0cb055a8a600a17ba9bb9e9e527 100644
@@ -4,3 +4,9 @@ config INTERCONNECT_QCOM_RPMH
 	help
 	  Enable support for the interconnect helpers to vote with
 	  the RPMh subsystems in Qualcomm SoCs
+
+config INTERCONNECT_QCOM_SM8650
+	bool "Enable interconnect support for SM8650 SoC"
+	depends on INTERCONNECT_QCOM_RPMH
+	help
+	  Enable support for the interconnect driver for the SM8650 SoC.
drivers/interconnect/qcom/Makefile +1 -0
index 4369ca07f611f9a61103f6aa893841e137e68aea..a33a65bd82e20761707b02374dd2cf81c35ea87c 100644
@@ -4,3 +4,4 @@
 #
 
 obj-$(CONFIG_$(PHASE_)INTERCONNECT_QCOM_RPMH) += icc-rpmh.o bcm-voter.o
+obj-$(CONFIG_$(PHASE_)INTERCONNECT_QCOM_SM8650) += sm8650.o
drivers/interconnect/qcom/sm8650.c new file +1664 -0

1,664 lines not on this page · raw message

drivers/interconnect/qcom/sm8650.h new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
2.34.1
#15 lore raw

PATCH v2 6/7 ufs: qcom: vote for interconnect bandwidth on probe

In reply to Neil Armstrong

Add Interconnect voting on the UFS probe to ask for the largest bandwidth possible.

---
 drivers/ufs/ufs-qcom.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/ufs/ufs-qcom.c +13 -0
index 843585726c7bf001321d927a4daceb64d0d6f153..c21a7b9947c96af61eeb33a2f06d48b2e71afe41 100644
@@ -16,6 +16,7 @@
 #include <generic-phy.h>
 #include <ufs.h>
 #include <asm/gpio.h>
+#include <interconnect.h>
 
 #include <linux/bitops.h>
 #include <linux/delay.h>
@@ -26,6 +27,9 @@
 
 #define ceil(freq, div) ((freq) % (div) == 0 ? ((freq) / (div)) : ((freq) / (div) + 1))
 
+#define UFS_DDR_MAX_BANDWIDTH	7643136
+#define UFS_CPU_MAX_BANDWIDTH	819200
+
 static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_hba *hba, bool enable);
 
 static int ufs_qcom_enable_clks(struct ufs_qcom_priv *priv)
@@ -625,8 +629,17 @@ static struct ufs_hba_ops ufs_qcom_hba_ops = {
 static int ufs_qcom_probe(struct udevice *dev)
 {
 	struct ufs_qcom_priv *priv = dev_get_priv(dev);
+	struct icc_path *path;
 	int ret;
 
+	path = of_icc_get(dev, "ufs-ddr");
+	if (!IS_ERR(path))
+		icc_set_bw(path, 0, UFS_DDR_MAX_BANDWIDTH);
+
+	path = of_icc_get(dev, "cpu-ufs");
+	if (!IS_ERR(path))
+		icc_set_bw(path, 0, UFS_CPU_MAX_BANDWIDTH);
+
 	/* get resets */
 	ret = reset_get_by_name(dev, "rst", &priv->core_reset);
 	if (ret) {
Signature · 1 line
2.34.1
#16 lore raw

PATCH v2 7/7 qcom_defconfig: enable interconnect for SM8650

In reply to Neil Armstrong

Enable the Interconnect drivers for SM8650

---
 configs/qcom_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/qcom_defconfig +3 -0
index 6a5b22591dc983fecc0929bae8949294d7033447..6b180e7e7369379823ec1aa1192ec688b6805f18 100644
@@ -168,3 +168,6 @@ CONFIG_PCI=y
 CONFIG_CMD_PCI=y
 CONFIG_NVME_PCI=y
 CONFIG_PCIE_DW_QCOM=y
+CONFIG_INTERCONNECT=y
+CONFIG_INTERCONNECT_QCOM_RPMH=y
+CONFIG_INTERCONNECT_QCOM_SM8650=y
Signature · 1 line
2.34.1