net: stmmac: dwmac-imx: request high frequency mode
Subsystems (5)
PATCH 1/1 net: stmmac: dwmac-imx: request high frequency mode
Some i.MX SoCs like the i.mx8mq support adjusting the frequency of the DDR, AHB, and AXI buses based on system loading. If the dwmac interface in the driver does not request a HIGH frequency, it can significantly degrade performance when the system switches to a lower frequency to conserve power.
For example, on an i.MX8MQ EVK board, the throughput dropped to around 100Mbit/s on a 1Gbit connection:
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 117 MBytes 97.9 Mbits/sec
However, throughput can return to expected levels after its driver requests the high frequency mode. Requesting high frequency in the dwmac driver is essential to maintain full throughput when the i.MX SoC adjusts bus speeds for power savings.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +3 -0
@@ -6,6 +6,7 @@* */ +#include <linux/busfreq-imx.h> #include <linux/clk.h> #include <linux/gpio/consumer.h> #include <linux/kernel.h>
@@ -152,7 +153,9 @@ static int imx_dwmac_clks_config(void *priv, bool enabled)clk_disable_unprepare (dwmac->clk_mem);return ret; } +request_bus_freq (BUS_FREQ_HIGH ); }else { +release_bus_freq (BUS_FREQ_HIGH );clk_disable_unprepare (dwmac->clk_tx);clk_disable_unprepare (dwmac->clk_mem); }
Signature · 1 line
2.34.1
Quoted 12 lines · Shenwei Wang
Some i.MX SoCs like the i.mx8mq support adjusting the frequency of the DDR, AHB, and AXI buses based on system loading. If the dwmac interface in the driver does not request a HIGH frequency, it can significantly degrade performance when the system switches to a lower frequency to conserve power.
For example, on an i.MX8MQ EVK board, the throughput dropped to around 100Mbit/s on a 1Gbit connection:
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 117 MBytes 97.9 Mbits/sec
Quoted 8 lines
However, throughput can return to expected levels after its driver requests the high frequency mode. Requesting high frequency in the dwmac driver is essential to maintain full throughput when the i.MX SoC adjusts bus speeds for power savings.
Signed-off-by Mario Castaneda <[email protected]>Signed-off-by Shenwei Wang <[email protected]>Tested-by Mario Castaneda <[email protected]>
I assume that you cannot go full dynamic and adjust the bus frequency based upon the negotiated link speed? There may be a need to adjust the bus frequency prior to starting any DMA transfers, otherwise dynamic frequency scaling of the bus may cause all sorts of issues?
Regardless of the answer:
Signature · 1 line
Florian
Quoted 5 lines
-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Wednesday, October 4, 2023 3:00 PM
To: Shenwei Wang <[email protected]>; David S. Miller
Quoted 8 lines
Quoted 3 lines
Signed-off-by Mario Castaneda <[email protected]>Signed-off-by Shenwei Wang <[email protected]>Tested-by Mario Castaneda <[email protected]>I assume that you cannot go full dynamic and adjust the bus frequency based upon the negotiated link speed? There may be a need to adjust the bus frequency prior to starting any DMA transfers, otherwise dynamic frequency scaling of the bus may cause all sorts of issues?
Once BUS_FREQ_HIGH is requested, the system will not change the bus frequency when transitioning to a low power state.
The hardware supports glitch-free frequency scaling, so blocks like DMA will not be affected during bus frequency adjustments.
Regards,
Shenwei
Quoted 6 lines
Regardless of the answer:
Reviewed-by Florian Fainelli <[email protected]>--
Florian
Jakub Kicinski
maintainerQuoted 9 lines · On Wed, 4 Oct 2023 14:54:42 -0500 Shenwei Wang wrote:
Some i.MX SoCs like the i.mx8mq support adjusting the frequency of the DDR, AHB, and AXI buses based on system loading. If the dwmac interface in the driver does not request a HIGH frequency, it can significantly degrade performance when the system switches to a lower frequency to conserve power.
For example, on an i.MX8MQ EVK board, the throughput dropped to around 100Mbit/s on a 1Gbit connection:
Quoted 7 lines
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 117 MBytes 97.9 Mbits/secHowever, throughput can return to expected levels after its driver requests the high frequency mode. Requesting high frequency in the dwmac driver is essential to maintain full throughput when the i.MX SoC adjusts bus speeds for power savings.
Oh, another one in one day :S Although this one feels much more like a bug that escaped testing because testing didn't use power saving? In any case, do you happen to have a user report you can mention here? Quoting stable rules:
| Serious issues as reported by a user of a distribution kernel may also | be considered if they fix a notable performance or interactivity | issue. As these fixes are not as obvious and have a higher risk of a | subtle regression they should only be submitted by a distribution | kernel maintainer and include an addendum linking to a bugzilla entry | if it exists and additional information on the user-visible impact.
And a Fixes tag would be good, please add.
Signature · 1 line
pw-bot: cr
Quoted 9 lines · Shenwei Wang
Some i.MX SoCs like the i.mx8mq support adjusting the frequency of the DDR, AHB, and AXI buses based on system loading. If the dwmac interface in the driver does not request a HIGH frequency, it can significantly degrade performance when the system switches to a lower frequency to conserve power.
For example, on an i.MX8MQ EVK board, the throughput dropped to around 100Mbit/s on a 1Gbit connection:
Quoted 7 lines
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 117 MBytes 97.9 Mbits/secHowever, throughput can return to expected levels after its driver requests the high frequency mode. Requesting high frequency in the dwmac driver is essential to maintain full throughput when the i.MX SoC adjusts bus speeds for power savings.
Isn't this going to cause a power regression? I expect there are applications which expect this behaviour and are happy with 100Mbps. And you are going to change it so their battery goes flatter faster, or they need to run their fan more often. So maybe you need a DT property to always forcing high speed.
And as Florian pointed out, maybe you should look at the negotiated speed, and if you have a 10 or 100Mbps link, the MAC does not need high frequency, so why not allow it to be low and safe some power.
Andrew
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello Shenwei,
Quoted 37 lines · Shenwei Wang
Some i.MX SoCs like the i.mx8mq support adjusting the frequency of the DDR, AHB, and AXI buses based on system loading. If the dwmac interface in the driver does not request a HIGH frequency, it can significantly degrade performance when the system switches to a lower frequency to conserve power.
For example, on an i.MX8MQ EVK board, the throughput dropped to around 100Mbit/s on a 1Gbit connection:
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 117 MBytes 97.9 Mbits/secHowever, throughput can return to expected levels after its driver requests the high frequency mode. Requesting high frequency in the dwmac driver is essential to maintain full throughput when the i.MX SoC adjusts bus speeds for power savings.
Signed-off-by Mario Castaneda <[email protected]>Signed-off-by Shenwei Wang <[email protected]>Tested-by Mario Castaneda <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +1
-0@@ -6,6 +6,7 @@* */ +#include <linux/busfreq-imx.h> #include <linux/clk.h> #include <linux/gpio/consumer.h> #include <linux/kernel.h>
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c static int imx_dwmac_clks_config(void *priv, bool enabled) · line 156
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +1
-0@@ -152,7 +153,9 @@ static int imx_dwmac_clks_config(void *priv, bool enabled)clk_disable_unprepare (dwmac->clk_mem);return ret; } +request_bus_freq (BUS_FREQ_HIGH );
I don't find request_bus_freq in linux-next (next-20231005). AFAIK, it was only ever suggested as RFC and never went beyond that as a reimplmeentation on top of devfreq was requested instead of the i.MX-specific API used in the vendor fork.
Did you observe this performance pregression with mainline?
Cheers,
Ahmad
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +1
-0}else { +release_bus_freq (BUS_FREQ_HIGH );clk_disable_unprepare (dwmac->clk_tx);clk_disable_unprepare (dwmac->clk_mem); }
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 11 lines
-----Original Message-----
From: Ahmad Fatoum <[email protected]>
Sent: Thursday, October 5, 2023 1:28 AM
To: Shenwei Wang <[email protected]>; David S. MillerQuoted 4 lines
clk_disable_unprepare(dwmac->clk_mem); return ret; }+
request_bus_freq(BUS_FREQ_HIGH);
Quoted 6 lines
I don't find
request_bus_freqin linux-next (next-20231005). AFAIK, it was only ever suggested as RFC and never went beyond that as a reimplmeentation on top of devfreq was requested instead of the i.MX-specific API used in the vendor fork.Did you observe this performance pregression with mainline?
My apologies. I did not realize I was working on a wrong working tree. The busfreq-imx driver hasn't yet gotten upstreamed.
Please ignore this patch.
Regards,
Shenwei
Quoted 23 lines
Cheers,
AhmadQuoted 5 lines
} else { + release_bus_freq(BUS_FREQ_HIGH); clk_disable_unprepare(dwmac->clk_tx); clk_disable_unprepare(dwmac->clk_mem); }--
Pengutronix e.K. | |
Steuerwalder Str. 21 |
http://www.pen/
gutronix.de%2F&data=05%7C01%7Cshenwei.wang%40nxp.com%7Cbab522390 5f542a0cabb08dbc56c406d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C 0%7C638320840957133285%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% 7C&sdata=kxhSaLbYLmFqYkbN%2BXg1lHfwRbRgWrSNy35BMpcMnSk%3D&reser ved=0 |31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Shenwei,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Shenwei-Wang/net-stmmac-dwmac-imx-request-high-frequency-mode/20231005-035606 base: net/main patch link: https://lore.kernel.org/r/20231004195442.414766-1-shenwei.wang%40nxp.com patch subject: [PATCH net] net: stmmac: dwmac-imx: request high frequency mode config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231005/[email protected]/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231005/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c:9:10: fatal error: linux/busfreq-imx.h: No such file or directory
9 | #include <linux/busfreq-imx.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
vim +9 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
> 9 #include <linux/busfreq-imx.h>
10 #include <linux/clk.h>
11 #include <linux/gpio/consumer.h>
12 #include <linux/kernel.h>
13 #include <linux/mfd/syscon.h>
14 #include <linux/module.h>
15 #include <linux/of.h>
16 #include <linux/of_net.h>
17 #include <linux/phy.h>
18 #include <linux/platform_device.h>
19 #include <linux/pm_wakeirq.h>
20 #include <linux/regmap.h>
21 #include <linux/slab.h>
22 #include <linux/stmmac.h>
23 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Shenwei,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Shenwei-Wang/net-stmmac-dwmac-imx-request-high-frequency-mode/20231005-035606 base: net/main patch link: https://lore.kernel.org/r/20231004195442.414766-1-shenwei.wang%40nxp.com patch subject: [PATCH net] net: stmmac: dwmac-imx: request high frequency mode config: arm-defconfig (https://download.01.org/0day-ci/archive/20231025/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231025/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c:9:10: fatal error: 'linux/busfreq-imx.h' file not found
#include <linux/busfreq-imx.h>
^~~~~~~~~~~~~~~~~~~~~1 error generated.
vim +9 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
> 9 #include <linux/busfreq-imx.h>
10 #include <linux/clk.h>
11 #include <linux/gpio/consumer.h>
12 #include <linux/kernel.h>
13 #include <linux/mfd/syscon.h>
14 #include <linux/module.h>
15 #include <linux/of.h>
16 #include <linux/of_net.h>
17 #include <linux/phy.h>
18 #include <linux/platform_device.h>
19 #include <linux/pm_wakeirq.h>
20 #include <linux/regmap.h>
21 #include <linux/slab.h>
22 #include <linux/stmmac.h>
23 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki