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

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Oct 4 23:28:08 PDT 2023


Hello Shenwei,

On 04.10.23 21:54, 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:
> 
>     [ 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);

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


>  	} 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.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




More information about the linux-arm-kernel mailing list