<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I missed the mutex lock that needs to be reinitialized. Please ignore this version and I will send a new one.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
thanks</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
xiaolei</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Wang, Xiaolei<br>
<b>Sent:</b> Wednesday, May 8, 2024 12:16 PM<br>
<b>To:</b> alexandre.torgue@foss.st.com <alexandre.torgue@foss.st.com>; joabreu@synopsys.com <joabreu@synopsys.com>; davem@davemloft.net <davem@davemloft.net>; edumazet@google.com <edumazet@google.com>; kuba@kernel.org <kuba@kernel.org>; pabeni@redhat.com <pabeni@redhat.com>;
mcoquelin.stm32@gmail.com <mcoquelin.stm32@gmail.com>; richardcochran@gmail.com <richardcochran@gmail.com>; bartosz.golaszewski@linaro.org <bartosz.golaszewski@linaro.org>; horms@kernel.org <horms@kernel.org>; ahalaney@redhat.com <ahalaney@redhat.com>; rohan.g.thomas@intel.com
<rohan.g.thomas@intel.com>; j.zink@pengutronix.de <j.zink@pengutronix.de>; rmk+kernel@armlinux.org.uk <rmk+kernel@armlinux.org.uk>; leong.ching.swee@intel.com <leong.ching.swee@intel.com><br>
<b>Cc:</b> netdev@vger.kernel.org <netdev@vger.kernel.org>; linux-stm32@st-md-mailman.stormreply.com <linux-stm32@st-md-mailman.stormreply.com>; linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org><br>
<b>Subject:</b> [PATCH v2] net: stmmac: move the lock to struct plat_stmmacenet_data</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Reinitialize the whole est structure would also reset the mutex lock<br>
which is embedded in the est structure, and then trigger the following<br>
warning. To address this, move the lock to struct plat_stmmacenet_data.<br>
We also need to require the mutex lock when doing this initialization.<br>
<br>
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com><br>
---<br>
v1 -> v2<br>
- move the lock to struct plat_stmmacenet_data<br>
<br>
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 8 ++++----<br>
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 16 ++++++++--------<br>
include/linux/stmmac.h | 2 +-<br>
3 files changed, 13 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c<br>
index e04830a3a1fb..82b7577fea9e 100644<br>
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c<br>
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c<br>
@@ -70,11 +70,11 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)<br>
/* If EST is enabled, disabled it before adjust ptp time. */<br>
if (priv->plat->est && priv->plat->est->enable) {<br>
est_rst = true;<br>
- mutex_lock(&priv->plat->est->lock);<br>
+ mutex_lock(&priv->plat->lock);<br>
priv->plat->est->enable = false;<br>
stmmac_est_configure(priv, priv, priv->plat->est,<br>
priv->plat->clk_ptp_rate);<br>
- mutex_unlock(&priv->plat->est->lock);<br>
+ mutex_unlock(&priv->plat->lock);<br>
}<br>
<br>
write_lock_irqsave(&priv->ptp_lock, flags);<br>
@@ -87,7 +87,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)<br>
ktime_t current_time_ns, basetime;<br>
u64 cycle_time;<br>
<br>
- mutex_lock(&priv->plat->est->lock);<br>
+ mutex_lock(&priv->plat->lock);<br>
priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, ¤t_time);<br>
current_time_ns = timespec64_to_ktime(current_time);<br>
time.tv_nsec = priv->plat->est->btr_reserve[0];<br>
@@ -104,7 +104,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)<br>
priv->plat->est->enable = true;<br>
ret = stmmac_est_configure(priv, priv, priv->plat->est,<br>
priv->plat->clk_ptp_rate);<br>
- mutex_unlock(&priv->plat->est->lock);<br>
+ mutex_unlock(&priv->plat->lock);<br>
if (ret)<br>
netdev_err(priv->dev, "failed to configure EST\n");<br>
}<br>
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c<br>
index cce00719937d..f1e4d755a484 100644<br>
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c<br>
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c<br>
@@ -1004,17 +1004,17 @@ static int tc_taprio_configure(struct stmmac_priv *priv,<br>
if (!plat->est)<br>
return -ENOMEM;<br>
<br>
- mutex_init(&priv->plat->est->lock);<br>
+ mutex_init(&priv->plat->lock);<br>
} else {<br>
memset(plat->est, 0, sizeof(*plat->est));<br>
}<br>
<br>
size = qopt->num_entries;<br>
<br>
- mutex_lock(&priv->plat->est->lock);<br>
+ mutex_lock(&priv->plat->lock);<br>
priv->plat->est->gcl_size = size;<br>
priv->plat->est->enable = qopt->cmd == TAPRIO_CMD_REPLACE;<br>
- mutex_unlock(&priv->plat->est->lock);<br>
+ mutex_unlock(&priv->plat->lock);<br>
<br>
for (i = 0; i < size; i++) {<br>
s64 delta_ns = qopt->entries[i].interval;<br>
@@ -1045,7 +1045,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,<br>
priv->plat->est->gcl[i] = delta_ns | (gates << wid);<br>
}<br>
<br>
- mutex_lock(&priv->plat->est->lock);<br>
+ mutex_lock(&priv->plat->lock);<br>
/* Adjust for real system time */<br>
priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, ¤t_time);<br>
current_time_ns = timespec64_to_ktime(current_time);<br>
@@ -1068,7 +1068,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,<br>
tc_taprio_map_maxsdu_txq(priv, qopt);<br>
<br>
if (fpe && !priv->dma_cap.fpesel) {<br>
- mutex_unlock(&priv->plat->est->lock);<br>
+ mutex_unlock(&priv->plat->lock);<br>
return -EOPNOTSUPP;<br>
}<br>
<br>
@@ -1079,7 +1079,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,<br>
<br>
ret = stmmac_est_configure(priv, priv, priv->plat->est,<br>
priv->plat->clk_ptp_rate);<br>
- mutex_unlock(&priv->plat->est->lock);<br>
+ mutex_unlock(&priv->plat->lock);<br>
if (ret) {<br>
netdev_err(priv->dev, "failed to configure EST\n");<br>
goto disable;<br>
@@ -1096,7 +1096,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,<br>
<br>
disable:<br>
if (priv->plat->est) {<br>
- mutex_lock(&priv->plat->est->lock);<br>
+ mutex_lock(&priv->plat->lock);<br>
priv->plat->est->enable = false;<br>
stmmac_est_configure(priv, priv, priv->plat->est,<br>
priv->plat->clk_ptp_rate);<br>
@@ -1105,7 +1105,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,<br>
priv->xstats.max_sdu_txq_drop[i] = 0;<br>
priv->xstats.mtl_est_txq_hlbf[i] = 0;<br>
}<br>
- mutex_unlock(&priv->plat->est->lock);<br>
+ mutex_unlock(&priv->plat->lock);<br>
}<br>
<br>
priv->plat->fpe_cfg->enable = false;<br>
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h<br>
index dfa1828cd756..316ff7eb8b33 100644<br>
--- a/include/linux/stmmac.h<br>
+++ b/include/linux/stmmac.h<br>
@@ -117,7 +117,6 @@ struct stmmac_axi {<br>
<br>
#define EST_GCL 1024<br>
struct stmmac_est {<br>
- struct mutex lock;<br>
int enable;<br>
u32 btr_reserve[2];<br>
u32 btr_offset[2];<br>
@@ -246,6 +245,7 @@ struct plat_stmmacenet_data {<br>
struct fwnode_handle *port_node;<br>
struct device_node *mdio_node;<br>
struct stmmac_dma_cfg *dma_cfg;<br>
+ struct mutex lock;<br>
struct stmmac_est *est;<br>
struct stmmac_fpe_cfg *fpe_cfg;<br>
struct stmmac_safety_feature_cfg *safety_feat_cfg;<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</body>
</html>