[PATCH net] net: stmmac: dwmac-imx: request high frequency mode

Shenwei Wang shenwei.wang at nxp.com
Wed Oct 4 12:54:42 PDT 2023


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.

Signed-off-by: Mario Castaneda <mario.ignacio.castaneda.lopez at nxp.com>
Signed-off-by: Shenwei Wang <shenwei.wang at nxp.com>
Tested-by: Mario Castaneda <mario.ignacio.castaneda.lopez at nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index 8f730ada71f91..ba6ae0465ecaa 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -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);
 	}
-- 
2.34.1




More information about the linux-arm-kernel mailing list