From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
To: <netdev@vger.kernel.org>
Cc: Fabrice Gasnier <fabrice.gasnier@st.com>
Subject: [PATCH (net.git) 1/5] stmmac: fix stmmac_tx_avail should be called with TX locked
Date: Tue, 4 Nov 2014 17:08:05 +0100 [thread overview]
Message-ID: <1415117289-7733-2-git-send-email-peppe.cavallaro@st.com> (raw)
In-Reply-To: <1415117289-7733-1-git-send-email-peppe.cavallaro@st.com>
From: Fabrice Gasnier <fabrice.gasnier@st.com>
stmmac_tx_avail() may lie if used unprotected. It's using cur_tx
and dirty_tx index. These index may be already in use by tx_clean
when entering xmit routine. So, this should be called locked.
This can cause transmit queue to be stuck, with following message:
NETDEV WATCHDOG: eth0 (stmmaceth): transmit queue 0 timed out
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6f77a46..bcd8a34 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1894,7 +1894,10 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
unsigned int nopaged_len = skb_headlen(skb);
unsigned int enh_desc = priv->plat->enh_desc;
+ spin_lock(&priv->tx_lock);
+
if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) {
+ spin_unlock(&priv->tx_lock);
if (!netif_queue_stopped(dev)) {
netif_stop_queue(dev);
/* This is a hard error, log it. */
@@ -1903,8 +1906,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_BUSY;
}
- spin_lock(&priv->tx_lock);
-
if (priv->tx_path_in_lpi_mode)
stmmac_disable_eee_mode(priv);
--
1.7.4.4
next prev parent reply other threads:[~2014-11-04 16:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 16:08 [PATCH (net.git) 0/5] stmmac: review and fix lock and atomicity Giuseppe Cavallaro
2014-11-04 16:08 ` Giuseppe Cavallaro [this message]
2014-11-04 16:08 ` [PATCH (net.git) 2/5] stmmac: release tx lock, in case of dma mapping error Giuseppe Cavallaro
2014-11-04 16:08 ` [PATCH (net.git) 3/5] stmmac: fix lock in stmmac_set_rx_mode Giuseppe Cavallaro
2014-11-04 16:08 ` [PATCH (net.git) 4/5] stmmac: fix concurrency in eee initialization Giuseppe Cavallaro
2014-11-04 16:08 ` [PATCH (net.git) 5/5] stmmac: fix atomicity in pm routines Giuseppe Cavallaro
2014-11-05 21:24 ` [PATCH (net.git) 0/5] stmmac: review and fix lock and atomicity David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415117289-7733-2-git-send-email-peppe.cavallaro@st.com \
--to=peppe.cavallaro@st.com \
--cc=fabrice.gasnier@st.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox