Skip to contentSkip to conversation

Add support of busfreq

RFC PATCH In review Alexandre Bailon 8 participants 16 messages Mar 13, 2019 – Jun 10, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add support of busfreq

This series implements busfreq, a framework used in MXP's tree to scale the interconnect and dram frequencies. In the vendor tree, device's driver request for a performance level, which is used to scale the frequencies. This series implements it using the interconnect framework. Devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

Busfreq is quite generic. It could be used for any i.MX SoC. A busfreq platform driver just have to define a list of interconnect nodes, and some OPPs.

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.
As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

As exemple, this series implements busfreq for Alexandre Bailon (3):
drivers: interconnect: Add a driver for i.MX SoC
drivers: interconnect: imx: Add support of i.MX8MM
dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

 .../bindings/interconnect/imx8mm.txt          |  24 +
 drivers/interconnect/Kconfig                  |   1 +
 drivers/interconnect/Makefile                 |   1 +
 drivers/interconnect/imx/Kconfig              |  17 +
 drivers/interconnect/imx/Makefile             |   2 +
 drivers/interconnect/imx/busfreq-imx8mm.c     | 132 ++++
 drivers/interconnect/imx/busfreq.c            | 570 ++++++++++++++++++
 drivers/interconnect/imx/busfreq.h            | 123 ++++
 include/dt-bindings/interconnect/imx8mm.h     |  37 ++
 9 files changed, 907 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interconnect/imx8mm.txt
 create mode 100644 drivers/interconnect/imx/Kconfig
 create mode 100644 drivers/interconnect/imx/Makefile
 create mode 100644 drivers/interconnect/imx/busfreq-imx8mm.c
 create mode 100644 drivers/interconnect/imx/busfreq.c
 create mode 100644 drivers/interconnect/imx/busfreq.h
 create mode 100644 include/dt-bindings/interconnect/imx8mm.h
Signature · 1 line
2.19.2
#1 lore raw

RFC PATCH 1/3 drivers: interconnect: Add a driver for i.MX SoC

This adds support of i.MX SoC to interconnect framework. This is based on busfreq, from NXP's tree.
This is is generic enough to be used to add support of interconnect framework to any i.MX SoC, and, even, this could used for some other SoC.
Thanks to interconnect framework, devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.
Busfreq platform drivers just have to registers interconnect nodes, and OPPs.

---
 drivers/interconnect/Kconfig       |   1 +
 drivers/interconnect/Makefile      |   1 +
 drivers/interconnect/imx/Kconfig   |  13 +
 drivers/interconnect/imx/Makefile  |   1 +
 drivers/interconnect/imx/busfreq.c | 570 +++++++++++++++++++++++++++++
 drivers/interconnect/imx/busfreq.h | 123 +++++++
 6 files changed, 709 insertions(+)
 create mode 100644 drivers/interconnect/imx/Kconfig
 create mode 100644 drivers/interconnect/imx/Makefile
 create mode 100644 drivers/interconnect/imx/busfreq.c
 create mode 100644 drivers/interconnect/imx/busfreq.h
drivers/interconnect/Kconfig +1 -0
index 07a8276fa35a..99955906bea8 100644
@@ -11,5 +11,6 @@ menuconfig INTERCONNECT
 if INTERCONNECT
 
 source "drivers/interconnect/qcom/Kconfig"
+source "drivers/interconnect/imx/Kconfig"
 
 endif
drivers/interconnect/Makefile +1 -0
index 28f2ab0824d5..20a13b7eb37f 100644
@@ -4,3 +4,4 @@ icc-core-objs				:= core.o
 
 obj-$(CONFIG_INTERCONNECT)		+= icc-core.o
 obj-$(CONFIG_INTERCONNECT_QCOM)		+= qcom/
+obj-$(CONFIG_INTERCONNECT_IMX)		+= imx/
drivers/interconnect/imx/Kconfig new file +13 -0
new file mode 100644
index 000000000000..afd7b71bbd82
@@ -0,0 +1,13 @@
+config INTERCONNECT_IMX
+	bool "i.MX interconnect drivers"
+	depends on ARCH_MXC || ARCH_MXC_ARM64 || COMPILE_TEST
+	help
+	  Support for i.MX interconnect hardware.
+
+config BUSFREQ
+	bool "busfreq interconnect driver"
+	depends on INTERCONNECT_IMX
+	help
+	  A generic interconnect driver that could be used for any i.MX.
+	  This provides a way to register master and slave and some opp
+	  to use when one or more master are in use.
drivers/interconnect/imx/Makefile new file +1 -0
new file mode 100644
index 000000000000..fea647183815
@@ -0,0 +1 @@
+obj-$(CONFIG_BUSFREQ) += busfreq.o
drivers/interconnect/imx/busfreq.c new file +570 -0

570 lines not on this page · raw message

drivers/interconnect/imx/busfreq.h new file +123 -0

123 lines not on this page · raw message

Signature · 7 lines
2.19.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw

Re: [RFC PATCH 1/3] drivers: interconnect: Add a driver for i.MX SoC

Quoted 10 lines · Alexandre Bailon

This adds support of i.MX SoC to interconnect framework. This is based on busfreq, from NXP's tree.
This is is generic enough to be used to add support of interconnect framework to any i.MX SoC, and, even, this could used for some other SoC.

Thanks to interconnect framework, devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

This part is difficult for me to understand:

Quoted 79 lines
drivers/interconnect/imx/busfreq.c new file +79 -0
+static int busfreq_opp_bw_gt(struct busfreq_opp_node *opp_node,
+			      u32 avg_bw, u32 peak_bw)
+{
+	if (!opp_node)
+		return 0;
+	if (opp_node->min_avg_bw == BUSFREQ_UNDEFINED_BW) {
+		if (avg_bw)
+			return 2;
+		else
+			return 1;
+	}
+	if (opp_node->min_peak_bw == BUSFREQ_UNDEFINED_BW) {
+		if (peak_bw)
+			return 2;
+		else
+			return 1;
+	}
+	if (avg_bw >= opp_node->min_avg_bw)
+		return 1;
+	if (peak_bw >= opp_node->min_peak_bw)
+		return 1;
+	return 0;
+}
+
+static struct busfreq_opp *busfreq_cmp_bw_opp(struct busfreq_icc_desc *desc,
+					      struct busfreq_opp *opp1,
+					      struct busfreq_opp *opp2)
+{
+	int i;
+	int opp1_valid;
+	int opp2_valid;
+	int opp1_count = 0;
+	int opp2_count = 0;
+
+	if (!opp1 && !opp2)
+		return desc->current_opp;
+
+	if (!opp1)
+		return opp2;
+
+	if (!opp2)
+		return opp1;
+
+	if (opp1 == opp2)
+		return opp1;
+
+	for (i = 0; i < opp1->nodes_count; i++) {
+		struct busfreq_opp_node *opp_node1, *opp_node2;
+		struct icc_node *icc_node;
+		u32 avg_bw;
+		u32 peak_bw;
+
+		opp_node1 = &opp1->nodes[i];
+		opp_node2 = &opp2->nodes[i];
+		icc_node = opp_node1->icc_node;
+		avg_bw = icc_node->avg_bw;
+		peak_bw = icc_node->peak_bw;
+
+		opp1_valid = busfreq_opp_bw_gt(opp_node1, avg_bw, peak_bw);
+		opp2_valid = busfreq_opp_bw_gt(opp_node2, avg_bw, peak_bw);
+
+		if (opp1_valid == opp2_valid && opp1_valid == 1) {
+			if (opp_node1->min_avg_bw > opp_node2->min_avg_bw &&
+				opp_node1->min_avg_bw != BUSFREQ_UNDEFINED_BW)
+				opp1_valid++;
+			if (opp_node1->min_avg_bw < opp_node2->min_avg_bw &&
+				opp_node2->min_avg_bw != BUSFREQ_UNDEFINED_BW)
+				opp2_valid++;
+		}
+
+		opp1_count += opp1_valid;
+		opp2_count += opp2_valid;
+	}
+
+	if (opp1_count > opp2_count)
+		return opp1;
+	if (opp1_count < opp2_count)
+		return opp2;
+	return opp1->perf_level >= opp2->perf_level ? opp2 : opp1;

drivers/interconnect/imx/busfreq.c line 230

Quoted 10 lines
drivers/interconnect/imx/busfreq.c new file +10 -0
+}
+
+static int busfreq_set_best_opp(struct busfreq_icc_desc *desc)
+{
+	struct busfreq_opp *opp, *best_opp = desc->current_opp;
+
+	list_for_each_entry(opp, &desc->opps, node)
+		best_opp = busfreq_cmp_bw_opp(desc, opp, best_opp);
+	return busfreq_set_opp(desc, best_opp);
+}

The goal seems to be to find the smaller platform-level "busfreq_opp" which can meet all aggregated requests.

But why implement this by comparing opps against each other? It would be easier to just iterate OPPs from low to high and stop on the first one which meets all requirements.

The sdm845 provider seems to take a different approach: there are BCMs ("Bus Clock Managers") which are attached to some of the icc nodes and those are individually scaled in order to meet BW requirements. On imx8m we can scale buses via clk so we could just attach clks to some of the nodes (NOC, DRAM, few PL301).

--
Regards,
Leonard

#3 lore raw

RFC PATCH 2/3 drivers: interconnect: imx: Add support of i.MX8MM

In reply to Alexandre Bailon

This adds a platform driver for the i.MX8MM SoC.

---
 drivers/interconnect/imx/Kconfig          |   4 +
 drivers/interconnect/imx/Makefile         |   1 +
 drivers/interconnect/imx/busfreq-imx8mm.c | 132 ++++++++++++++++++++++
 include/dt-bindings/interconnect/imx8mm.h |  37 ++++++
 4 files changed, 174 insertions(+)
 create mode 100644 drivers/interconnect/imx/busfreq-imx8mm.c
 create mode 100644 include/dt-bindings/interconnect/imx8mm.h
drivers/interconnect/imx/Kconfig +4 -0
index afd7b71bbd82..b569d40e5ca0 100644
@@ -11,3 +11,7 @@ config BUSFREQ
 	  A generic interconnect driver that could be used for any i.MX.
 	  This provides a way to register master and slave and some opp
 	  to use when one or more master are in use.
+
+config BUSFREQ_IMX8MM
+	bool "i.MX8MM busfreq driver"
+	depends on BUSFREQ
drivers/interconnect/imx/Makefile +1 -0
index fea647183815..a92fea6e042d 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_BUSFREQ) += busfreq.o
+obj-$(CONFIG_BUSFREQ_IMX8MM) += busfreq-imx8mm.o
drivers/interconnect/imx/busfreq-imx8mm.c new file +132 -0

132 lines not on this page · raw message

include/dt-bindings/interconnect/imx8mm.h new file +37 -0
new file mode 100644
index 000000000000..4318ed319edc
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Interconnect framework driver for i.MX SoC
+ *
+ * Copyright (c) 2019, BayLibre
+ * Author: Alexandre Bailon <[email protected]>
+ */
+
+#ifndef __IMX8MM_INTERCONNECT_IDS_H
+#define __IMX8MM_INTERCONNECT_IDS_H
+
+#define IMX8MM_NOC	0
+#define IMX8MM_CPU_0	1
+#define IMX8MM_CPU_1	2
+#define IMX8MM_CPU_2	3
+#define IMX8MM_CPU_3	4
+#define IMX8MM_VPU_H1	5
+#define IMX8MM_VPU_G1	6
+#define IMX8MM_VPU_G2	7
+#define IMX8MM_MIPI	8
+#define IMX8MM_USB_1	9
+#define IMX8MM_USB_2	10
+#define IMX8MM_PCIE	11
+#define IMX8MM_GPU	12
+#define IMX8MM_DRAM	13
+
+#define IMX8MM_PL301	100
+#define IMX8MM_SAI1	101
+#define IMX8MM_SAI2	102
+#define IMX8MM_SAI3	103
+#define IMX8MM_SAI4	104
+#define IMX8MM_SAI5	105
+#define IMX8MM_SAI6	106
+#define IMX8MM_SPDIF	107
+#define IMX8MM_FEC	108
+
+#endif /* __IMX8MM_INTERCONNECT_IDS_H */
Signature · 1 line
2.19.2
#4 lore raw

RFC PATCH 3/3 dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

In reply to Alexandre Bailon

Document the device-tree bindings interconnect driver for i.MX8MM SoC.

---
 .../bindings/interconnect/imx8mm.txt          | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interconnect/imx8mm.txt
Documentation/devicetree/bindings/interconnect/imx8mm.txt new file +24 -0
new file mode 100644
index 000000000000..81f0cf134de2
@@ -0,0 +1,24 @@
+i.MX busfreq driver binding
+----------------------------------------------------
+
+Required properties :
+- compatible : must be "fsl,busfreq-imx8mm"
+- #interconnect-cells : should contain 1
+- clocks : list of phandles and specifiers to all interconnect bus clocks
+- clock-names : clock names must include "dram-alt", "dram-apb", "dram-core",
+                "noc", "ahb" and "axi"
+
+Examples:
+
+	icc0: icc {
+		compatible = "fsl,busfreq-imx8mm";
+		#interconnect-cells = <1>;
+		clocks = <&clk IMX8MM_CLK_DRAM_ALT>,
+			 <&clk IMX8MM_CLK_DRAM_APB>,
+			 <&clk IMX8MM_CLK_DRAM_CORE>,
+			 <&clk IMX8MM_CLK_NOC_DIV>,
+			 <&clk IMX8MM_CLK_AHB_DIV>,
+			 <&clk IMX8MM_CLK_MAIN_AXI>;
+		clock-names = "dram-alt", "dram-apb", "dram-core", "noc",
+			 "ahb", "axi";
+	};
Signature · 1 line
2.19.2
#5 lore raw
In reply to Alexandre Bailon

+Jacky and Leonard, Ranjani

Hi Alexandre,

Quoted 10 lines

From: Alexandre Bailon [mailto:[email protected]]

This series implements busfreq, a framework used in MXP's tree to scale the interconnect and dram frequencies.
In the vendor tree, device's driver request for a performance level, which is used to scale the frequencies.
This series implements it using the interconnect framework. Devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

Quoted 4 lines

Busfreq is quite generic. It could be used for any i.MX SoC.
A busfreq platform driver just have to define a list of interconnect nodes, and some OPPs.

It's really great to see this patch series.
And it should be the correct direction we're heading to upstream busfreq support.

Quoted 7 lines

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.
As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

How can I test this patch series?
Any additional patches you can share with us?
Or what else we need to do to test it? We can help with it.

Regards
Dong Aisheng

Quoted 27 lines

As exemple, this series implements busfreq for Alexandre Bailon (3):
drivers: interconnect: Add a driver for i.MX SoC
drivers: interconnect: imx: Add support of i.MX8MM
dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

 .../bindings/interconnect/imx8mm.txt          |  24 +
 drivers/interconnect/Kconfig                  |   1 +
 drivers/interconnect/Makefile                 |   1 +
 drivers/interconnect/imx/Kconfig              |  17 +
 drivers/interconnect/imx/Makefile             |   2 +
 drivers/interconnect/imx/busfreq-imx8mm.c     | 132 ++++
 drivers/interconnect/imx/busfreq.c            | 570
++++++++++++++++++
 drivers/interconnect/imx/busfreq.h            | 123 ++++
 include/dt-bindings/interconnect/imx8mm.h     |  37 ++
 9 files changed, 907 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/interconnect/imx8mm.txt
 create mode 100644 drivers/interconnect/imx/Kconfig  create mode
100644 drivers/interconnect/imx/Makefile  create mode 100644
drivers/interconnect/imx/busfreq-imx8mm.c
 create mode 100644 drivers/interconnect/imx/busfreq.c
 create mode 100644 drivers/interconnect/imx/busfreq.h
 create mode 100644 include/dt-bindings/interconnect/imx8mm.h

--
2.19.2

#6 lore raw

Hi Aisheng

Quoted 30 lines · Aisheng Dong

+Jacky and Leonard, Ranjani

Hi Alexandre,

Quoted 10 lines

From: Alexandre Bailon [mailto:[email protected]]

This series implements busfreq, a framework used in MXP's tree to scale the interconnect and dram frequencies.
In the vendor tree, device's driver request for a performance level, which is used to scale the frequencies.
This series implements it using the interconnect framework. Devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

Quoted 4 lines

Busfreq is quite generic. It could be used for any i.MX SoC.
A busfreq platform driver just have to define a list of interconnect nodes, and some OPPs.

It's really great to see this patch series.
And it should be the correct direction we're heading to upstream busfreq support.

Quoted 7 lines

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.
As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

Quoted 3 lines

How can I test this patch series?
Any additional patches you can share with us?
Or what else we need to do to test it? We can help with it.

Many other patches will be required to test the series.
There are a couple of patches that updates i.MX device drivers to request for bandwidth (does similar thing as bus_freq_request and bus_freq_release).
In addition, a patch to that allow to scale the DRAM
frequency using CCF is required. I'm still working on this patch. It works correctly on 4.14, but since I rebased it on linux-next/master, it stopped to work. I'm trying to fix it now. I will share all this patches ASAP.

Best Regards,
Alexandre

Quoted 31 lines

Regards
Dong Aisheng

Quoted 27 lines

As exemple, this series implements busfreq for Alexandre Bailon (3):
drivers: interconnect: Add a driver for i.MX SoC
drivers: interconnect: imx: Add support of i.MX8MM
dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

  .../bindings/interconnect/imx8mm.txt          |  24 +
  drivers/interconnect/Kconfig                  |   1 +
  drivers/interconnect/Makefile                 |   1 +
  drivers/interconnect/imx/Kconfig              |  17 +
  drivers/interconnect/imx/Makefile             |   2 +
  drivers/interconnect/imx/busfreq-imx8mm.c     | 132 ++++
  drivers/interconnect/imx/busfreq.c            | 570
++++++++++++++++++
  drivers/interconnect/imx/busfreq.h            | 123 ++++
  include/dt-bindings/interconnect/imx8mm.h     |  37 ++
  9 files changed, 907 insertions(+)

create mode 100644
Documentation/devicetree/bindings/interconnect/imx8mm.txt
create mode 100644 drivers/interconnect/imx/Kconfig create mode
100644 drivers/interconnect/imx/Makefile create mode 100644 drivers/interconnect/imx/busfreq-imx8mm.c
create mode 100644 drivers/interconnect/imx/busfreq.c create mode 100644 drivers/interconnect/imx/busfreq.h create mode 100644 include/dt-bindings/interconnect/imx8mm.h

--
2.19.2

#7 lore raw
Quoted 7 lines · Alexandre Bailon
Quoted 6 lines
Quoted 6 lines

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.
As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

Quoted 8 lines
Quoted 3 lines

How can I test this patch series?
Any additional patches you can share with us?
Or what else we need to do to test it? We can help with it.

Many other patches will be required to test the series. There are a couple of patches that updates i.MX device drivers to request for bandwidth (does similar thing as bus_freq_request and bus_freq_release).

The interconnect framework asks for bandwidth in bytes/second but in NXP tree most requests are of the form "request_bus_freq(BUS_FREQ_HIGH);". In many cases (ethernet) it doesn't seem you can calculate a specific bandwidth usefully.

Instead of asking for "infinite bandwidth zero latency" to force everything to "high" it would be nicer to "request an opp".

Power-domain bindings mentioned that consumer-devices can specify a "required-opps" property but I've found zero users in tree. Maybe some helpers could be written to parse that property and automatically request ICC opp on device suspend/resume via device-links?

I know that stuff was written for genpd but it looks like a very good fit to me.

Quoted 2 lines

In addition, a patch to that allow to scale the DRAM frequency using CCF is required. I'm still working on this patch.

I'm not sure what you mean here, do you want a clk set_rate to change the DRAM freq? It makes sense for DDRC to be a node in the interconnect framework and switch OPP inside icc implementation via an ATF call.

--
Regards,
Leonard

#8 lore raw
Quoted 22 lines · Leonard Crestez
Quoted 7 lines · Alexandre Bailon
Quoted 6 lines
Quoted 6 lines

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.
As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

Quoted 8 lines
Quoted 3 lines

How can I test this patch series?
Any additional patches you can share with us?
Or what else we need to do to test it? We can help with it.

Many other patches will be required to test the series. There are a couple of patches that updates i.MX device drivers to request for bandwidth (does similar thing as bus_freq_request and bus_freq_release).

The interconnect framework asks for bandwidth in bytes/second but in NXP tree most requests are of the form "request_bus_freq(BUS_FREQ_HIGH);". In many cases (ethernet) it doesn't seem you can calculate a specific bandwidth usefully.

Quoted 7 lines

Instead of asking for "infinite bandwidth zero latency" to force everything to "high" it would be nicer to "request an opp".

Power-domain bindings mentioned that consumer-devices can specify a "required-opps" property but I've found zero users in tree. Maybe some helpers could be written to parse that property and automatically request ICC opp on device suspend/resume via device-links?

Documentation/devicetree/bindings/power/qcom,rpmpd.txt is using it currently in mainline.

Quoted 2 lines

I know that stuff was written for genpd but it looks like a very good fit to me.

Yes, the very first user is genpd but we have designed it with an open mind and so it shouldn't be difficult to make use of it at other places.

There is some WIP which you can look at :

- Introduce OPP bandwidth bindings lore.kernel.org/lkml/[email protected]

- DVFS in the OPP core
https://lore.kernel.org/lkml/[email protected]

Signature · 1 line
viresh
#9 lore raw
In reply to Alexandre Bailon

Hi Alex,

Some nitpick review comments below.

Quoted 2 lines · Alexandre Bailon

This series implements busfreq, a framework used in MXP's

s/MXP/NXP/

Quoted 7 lines

tree to scale the interconnect and dram frequencies. In the vendor tree, device's driver request for a performance level, which is used to scale the frequencies. This series implements it using the interconnect framework. Devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

Quoted 8 lines

Busfreq is quite generic. It could be used for any i.MX SoC. A busfreq platform driver just have to define a list of interconnect nodes, and some OPPs.

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.

In your v2 cover letter could you post a link to a git branch that has everything integrated that is needed to test the series? I guess this is similar to what Aisheng asked for already.

Quoted 3 lines

As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

It's not clear to me whether this series actual scales the dram frequency based on what you said above. Is it just theoretical or do you have it working with a pile of out-of-tree patches? Would be good to include that pile of patches in your integration branch that I suggested above.

Thanks,
Mike

Quoted 27 lines

As exemple, this series implements busfreq for Alexandre Bailon (3):
drivers: interconnect: Add a driver for i.MX SoC
drivers: interconnect: imx: Add support of i.MX8MM
dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

 .../bindings/interconnect/imx8mm.txt          |  24 +
 drivers/interconnect/Kconfig                  |   1 +
 drivers/interconnect/Makefile                 |   1 +
 drivers/interconnect/imx/Kconfig              |  17 +
 drivers/interconnect/imx/Makefile             |   2 +
 drivers/interconnect/imx/busfreq-imx8mm.c     | 132 ++++
 drivers/interconnect/imx/busfreq.c            | 570 ++++++++++++++++++
 drivers/interconnect/imx/busfreq.h            | 123 ++++
 include/dt-bindings/interconnect/imx8mm.h     |  37 ++
 9 files changed, 907 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interconnect/imx8mm.txt
 create mode 100644 drivers/interconnect/imx/Kconfig
 create mode 100644 drivers/interconnect/imx/Makefile
 create mode 100644 drivers/interconnect/imx/busfreq-imx8mm.c
 create mode 100644 drivers/interconnect/imx/busfreq.c
 create mode 100644 drivers/interconnect/imx/busfreq.h
 create mode 100644 include/dt-bindings/interconnect/imx8mm.h

--
2.19.2

Signature · 5 lines
Michael Turquette
CEO
BayLibre - At the Heart of Embedded Linux
http://baylibre.com/
Schedule a meeting: https://calendly.com/mturquette
#10 lore raw

Hi Mike,

Quoted 21 lines · Michael Turquette

Hi Alex,

Some nitpick review comments below.

Quoted 2 lines · Alexandre Bailon

This series implements busfreq, a framework used in MXP's

s/MXP/NXP/

Quoted 11 lines

tree to scale the interconnect and dram frequencies. In the vendor tree, device's driver request for a performance level, which is used to scale the frequencies. This series implements it using the interconnect framework. Devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

Busfreq is quite generic. It could be used for any i.MX SoC. A busfreq platform driver just have to define a list of interconnect nodes, and some OPPs.

Quoted 8 lines
Quoted 4 lines

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.

In your v2 cover letter could you post a link to a git branch that has everything integrated that is needed to test the series? I guess this is similar to what Aisheng asked for already.

I will do it.

Quoted 10 lines
Quoted 4 lines

As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

It's not clear to me whether this series actual scales the dram frequency based on what you said above. Is it just theoretical or do you have it working with a pile of out-of-tree patches? Would be good to include that pile of patches in your integration branch that I suggested above.

The current series only introduce busfreq generic driver, and the busfreq driver for the imx8mm.
As is, the imx8mm driver will just be loaded, but do nothing because
none of the drivers have been updated to request bandwidth using the interconnect framework.
In addition, the current clock driver of imx8mm doesn't allow dram frequency scaling, so if busfreq driver tries, it will fail (should be harmless because any other clocks should restored to their previous rate).

My intent was to sent a first draft o busfreq, to get some feedback, before to send a more complete, and fully functional series.

Thanks,
Alexandre

Quoted 34 lines

Thanks,
Mike

Quoted 27 lines

As exemple, this series implements busfreq for Alexandre Bailon (3):
drivers: interconnect: Add a driver for i.MX SoC
drivers: interconnect: imx: Add support of i.MX8MM
dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

  .../bindings/interconnect/imx8mm.txt          |  24 +
  drivers/interconnect/Kconfig                  |   1 +
  drivers/interconnect/Makefile                 |   1 +
  drivers/interconnect/imx/Kconfig              |  17 +
  drivers/interconnect/imx/Makefile             |   2 +
  drivers/interconnect/imx/busfreq-imx8mm.c     | 132 ++++
  drivers/interconnect/imx/busfreq.c            | 570 ++++++++++++++++++
  drivers/interconnect/imx/busfreq.h            | 123 ++++
  include/dt-bindings/interconnect/imx8mm.h     |  37 ++
  9 files changed, 907 insertions(+)

create mode 100644 Documentation/devicetree/bindings/interconnect/imx8mm.txt create mode 100644 drivers/interconnect/imx/Kconfig
create mode 100644 drivers/interconnect/imx/Makefile
create mode 100644 drivers/interconnect/imx/busfreq-imx8mm.c create mode 100644 drivers/interconnect/imx/busfreq.c
create mode 100644 drivers/interconnect/imx/busfreq.h
create mode 100644 include/dt-bindings/interconnect/imx8mm.h

--
2.19.2

#11 lore raw
Quoted 12 lines · Alexandre Bailon
Quoted 11 lines · Alexandre Bailon
Quoted 4 lines

As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

It's not clear to me whether this series actual scales the dram frequency based on what you said above. Is it just theoretical or do you have it working with a pile of out-of-tree patches? Would be good to include that pile of patches in your integration branch that I suggested above.

Quoted 8 lines

The current series only introduce busfreq generic driver, and the busfreq driver for the imx8mm.
As is, the imx8mm driver will just be loaded, but do nothing because none of the drivers have been updated to request bandwidth using the interconnect framework.

My intent was to sent a first draft o busfreq, to get some feedback, before to send a more complete, and fully functional series.

It's been a while since this was first posted and imx8mm now boots fine in linux-next. Is there a more up-to-date WIP branch somewhere? Otherwise I can try to hack this series into a bootable form.

Quoted 4 lines

In addition, the current clock driver of imx8mm doesn't allow dram frequency scaling, so if busfreq driver tries, it will fail (should be harmless because any other clocks should restored to their previous rate).

I'm confused about this. In NXP tree the actual DRAM switch is done inside ATF via SIP calls and involves corralling all CPUs. Do you want an "dram" clk which wraps the SIP calls required to changing dram frequency and root switching etc?

I've been looking at the busfreq implementation in the NXP tree and refactoring just the "dram freq switch" behind a clk might work nicely.

This would be similar to the imx_cpu clk used for cpufreq-dt and it might even be possible to upstream this separately from the rest of busfreq logic dealing with device requests.

I haven't done a very careful review but I noticed you're not using the OPP framework and instead redefined everything? It's not clear why.

--
Regards,
Leonard

#12 lore raw

Hi, Alexandre

Quoted 17 lines

-----Original Message-----
From: Leonard Crestez
Sent: Wednesday, May 15, 2019 3:34 AM
To: Alexandre Bailon <[email protected]>; Jacky Bai <[email protected]>
Cc: Michael Turquette <[email protected]>; Linux PM list <linux- [email protected]>; Georgi Djakov <[email protected]>; Patrick Titiano <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>; Stephen Boyd <[email protected]>; Emilio Lopez <[email protected]>; Hans de Goede <[email protected]>; linux-clk <[email protected]>; linux-arm-kernel <linux-arm- [email protected]>; Zening Wang <[email protected]>; Aisheng Dong <[email protected]>; Kevin Hilman <[email protected]>; Carlo Caione <[email protected]>; dl-linux- imx <[email protected]>; Anson Huang <[email protected]>; Viresh Kumar <[email protected]>
Subject: Re: [RFC PATCH 0/3] Add support of busfreq

Quoted 7 lines
Quoted 1 line · Alexandre Bailon
Quoted 1 line

On Wed, Mar 13, 2019 at 12:33 PM Alexandre Bailon

Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines

As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

I have similar question as previous reviewer, is there any branch that we can test this series?

And, from the patch, it has multiple levels description of fabric arch, while we ONLY intend to scale "bus" frequency per devices' request, here "bus" includes DRAM, NOC and AHB, AXI, should we make it more flatter, such as just a virtual fabric as a single provider, and then all other devices as nodes under this provider?

Anson

Quoted 43 lines
Quoted 7 lines
Quoted 6 lines

It's not clear to me whether this series actual scales the dram frequency based on what you said above. Is it just theoretical or do you have it working with a pile of out-of-tree patches? Would be good to include that pile of patches in your integration branch that I suggested above.

Quoted 8 lines

The current series only introduce busfreq generic driver, and the busfreq driver for the imx8mm.
As is, the imx8mm driver will just be loaded, but do nothing because none of the drivers have been updated to request bandwidth using the interconnect framework.

My intent was to sent a first draft o busfreq, to get some feedback, before to send a more complete, and fully functional series.

It's been a while since this was first posted and imx8mm now boots fine in linux-next. Is there a more up-to-date WIP branch somewhere? Otherwise I can try to hack this series into a bootable form.

Quoted 1 line

In addition, the current clock driver of imx8mm doesn't allow dram >

frequency scaling, so if busfreq driver tries, it will fail (should be > harmless because any other clocks should restored to their previous > rate).

I'm confused about this. In NXP tree the actual DRAM switch is done inside ATF via SIP calls and involves corralling all CPUs. Do you want an "dram" clk which wraps the SIP calls required to changing dram frequency and root switching etc?

I've been looking at the busfreq implementation in the NXP tree and refactoring just the "dram freq switch" behind a clk might work nicely.

This would be similar to the imx_cpu clk used for cpufreq-dt and it might even be possible to upstream this separately from the rest of busfreq logic dealing with device requests.

I haven't done a very careful review but I noticed you're not using the OPP framework and instead redefined everything? It's not clear why.

--
Regards,
Leonard

#13 lore raw
Quoted 6 lines · Anson Huang
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

I have similar question as previous reviewer, is there any branch that we can test this series?

I've been looking at this and pushed a fixed-up functional variant to my personal github:

https://github.com/cdleonard/linux/commits/next_imx8mm_busfreq

It builds and probes and switches DRAM freq between low and high based on whether ethernet is down or up (for testing purposes). The pile of out-of-tree patches required to get this work is quite small.

The DRAM freq switch is done via a clk wrapper previously sent as RFC:

     https://patchwork.kernel.org/patch/10968303/

That part needs more work but it could serve as a neat encapsulation similar to imx_cpu clk used for cpufreq-dt.

Quoted 4 lines

And, from the patch, it has multiple levels description of fabric arch, while we ONLY intend to scale "bus" frequency per devices' request, here "bus" includes DRAM, NOC and AHB, AXI, should we make it more flatter, such as just a virtual fabric as a single provider, and then all other devices as nodes under this provider?

The imx8mm interconnect bindings describe many bus endpoints but all requests are aggregated to a single platform-level OPP which is equivalent to "low/audio/high mode" from NXP tree.

It might be better to associate clks to several ICC nodes and this way scale NOC and DRAM separately? As far as I understand an interconnect provider is free to decide on granularity.

As a wilder idea it might even be possible to use a stanard "devfreq-with-perfmon" for DDRC and have interconnect request a min freq to that instead of doing clk_set_rate on dram directly. That could bring features from both worlds, scaling both proactively and reactively.

--
Regards,
Leonard

#14 lore raw
In reply to Alexandre Bailon
Quoted 21 lines · Alexandre Bailon

This series implements busfreq, a framework used in MXP's tree to scale the interconnect and dram frequencies. In the vendor tree, device's driver request for a performance level, which is used to scale the frequencies. This series implements it using the interconnect framework. Devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

Busfreq is quite generic. It could be used for any i.MX SoC. A busfreq platform driver just have to define a list of interconnect nodes, and some OPPs.

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.
As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

Quoted 5 lines

As exemple, this series implements busfreq for Alexandre Bailon (3):
drivers: interconnect: Add a driver for i.MX SoC
drivers: interconnect: imx: Add support of i.MX8MM
dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

Hi Alexandre,

I am quite late but I just found your email.

This looks very similar to existing framework - devfreq, which purpose is to scale the system busses based on performance counters/events. It would be nice if we could avoid duplication of existing subsystems.

Best regards,
Krzysztof

#15 lore raw
Quoted 28 lines · Krzysztof Kozlowski
Quoted 21 lines · Alexandre Bailon

This series implements busfreq, a framework used in MXP's tree to scale the interconnect and dram frequencies. In the vendor tree, device's driver request for a performance level, which is used to scale the frequencies. This series implements it using the interconnect framework. Devices' driver request for bandwidth which is use by busfreq to determine a performance level, and then scale the frequency.

Busfreq is quite generic. It could be used for any i.MX SoC. A busfreq platform driver just have to define a list of interconnect nodes, and some OPPs.

This series is sent as RFC mostly because the current support of i.MX SoC won't benefit of busfreq framework, because the clocks' driver don't support interconnect / dram frequency scaling.
As exemple, this series implements busfreq for i.MX8MM whose upstreaming is in progress. Because this relies on ATF to do the frequency scaling, it won't be hard make it work.

Quoted 5 lines

As exemple, this series implements busfreq for Alexandre Bailon (3):
drivers: interconnect: Add a driver for i.MX SoC
drivers: interconnect: imx: Add support of i.MX8MM
dt-bindings: interconnect: Document fsl,busfreq-imx8mm bindings

Quoted 7 lines

Hi Alexandre,

I am quite late but I just found your email.

This looks very similar to existing framework - devfreq, which purpose is to scale the system busses based on performance counters/events. It would be nice if we could avoid duplication of existing subsystems.

Hi Krzysztof,

Scaling buses based on performance counters is suboptimal and sometimes might not work well. In contrast with devfreq, the interconnect API is allowing drivers to express their needs in advance and be proactive. It is also designed to deal with multi-tiered bus topologies and to aggregate the requests from the different consumer drivers.

Thanks,
Georgi

Quoted 4 lines

Best regards,
Krzysztof