-From 94c442a8f2c6ef87b31b855106753ddaaa39d72d Mon Sep 17 00:00:00 2001
+From 0f2d8e3d01ee074f7bf4e255f6a21502d75b29e2 Mon Sep 17 00:00:00 2001
From: Sasha Levin <sashal@kernel.org>
Date: Mon, 5 Jul 2021 18:26:54 +0800
Subject: net: stmmac: add mutex lock to protect est parameters
Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 13 ++++++++++++-
+ drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 14 +++++++++++++-
include/linux/stmmac.h | 1 +
- 2 files changed, 13 insertions(+), 1 deletion(-)
+ 2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
-index 40dc14d1415f..8c2eae2a7efd 100644
+index 40dc14d1415f..6bd9f0c50ffe 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
@@ -689,14 +689,18 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
/* Adjust for real system time */
priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, ¤t_time);
current_time_ns = timespec64_to_ktime(current_time);
-@@ -751,8 +756,10 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
+@@ -751,19 +756,23 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
priv->plat->est->ctr[0] = do_div(ctr, NSEC_PER_SEC);
priv->plat->est->ctr[1] = (u32)ctr;
ret = stmmac_fpe_configure(priv, priv->ioaddr,
priv->plat->tx_queues_to_use,
-@@ -764,6 +771,7 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
+ priv->plat->rx_queues_to_use, fpe);
+ if (ret && fpe) {
++ mutex_unlock(&priv->plat->est->lock);
+ netdev_err(priv->dev, "failed to enable Frame Preemption\n");
+ return ret;
+ }
ret = stmmac_est_configure(priv, priv->ioaddr, priv->plat->est,
priv->plat->clk_ptp_rate);
if (ret) {
netdev_err(priv->dev, "failed to configure EST\n");
goto disable;
-@@ -773,9 +781,12 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
+@@ -773,9 +782,12 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
return 0;
disable: