[PATCH net v4 1/3] net: stmmac: initialize est_lock at probe time

Maxime Chevallier maxime.chevallier at bootlin.com
Thu Oct 29 01:08:09 PDT 2026


Hi,

On 10/26/26 17:55, Lorenzo Bianconi wrote:
> priv->est is allocated with devm_kzalloc() on the first TAPRIO REPLACE
> and priv->est_lock is initialized in the same place, which ties the
> validity of the lock to whether TAPRIO has ever been configured. The
> lock is also never destroyed.
> 
> Initialize priv->est_lock in __stmmac_dvr_probe() next to priv->lock
> and destroy it in stmmac_dvr_remove(). This keeps the lock valid for
> the entire lifetime of the device, independent of the TAPRIO state,
> and removes the lazy initialization from the TAPRIO configuration
> path.
> 
> No functional change intended.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at oss.qualcomm.com>

Reviewed-by: Maxime Chevallier <maxime.chevallier at bootlin.com>

Maxime

> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++
>  drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c   | 2 --
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index b20e5038eead..9e09e11cc35e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8204,6 +8204,7 @@ static int __stmmac_dvr_probe(struct device *device,
>  	stmmac_napi_add(ndev);
>  
>  	mutex_init(&priv->lock);
> +	mutex_init(&priv->est_lock);
>  	rwlock_init(&priv->ptp_lock);
>  
>  	stmmac_fpe_init(priv);
> @@ -8337,6 +8338,7 @@ void stmmac_dvr_remove(struct device *dev)
>  
>  	destroy_workqueue(priv->wq);
>  	mutex_destroy(&priv->lock);
> +	mutex_destroy(&priv->est_lock);
>  	bitmap_free(priv->af_xdp_zc_qps);
>  
>  	pm_runtime_disable(dev);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> index e137fb9012d4..aea235a69105 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> @@ -1028,8 +1028,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
>  					 GFP_KERNEL);
>  		if (!priv->est)
>  			return -ENOMEM;
> -
> -		mutex_init(&priv->est_lock);
>  	} else {
>  		mutex_lock(&priv->est_lock);
>  		memset(priv->est, 0, sizeof(*priv->est));
> 




More information about the linux-arm-kernel mailing list