Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1542598

Re: [PATCH v2 2/2] net: ethernet: stmmac: remove private tx queue lock

From Pavel Machek <pavel@ucw.cz>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/2] net: ethernet: stmmac: remove private tx queue lock
Date 2016-12-15 10:50 +0100
Message-ID <sOAPL-48G-3@gated-at.bofh.it> (permalink)
References <sMgLv-4a0-5@gated-at.bofh.it> <sMgLv-4a0-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi!

> The driver uses a private lock for synchronization of the xmit function and
> the xmit completion handler, but since the NETIF_F_LLTX flag is not set,
> the xmit function is also called with the xmit_lock held.
> 
> On the other hand the completion handler uses the reverse locking order by
> first taking the private lock and (in case that the tx queue had been
> stopped) then the xmit_lock.
> 
> Improve the locking by removing the private lock and using only the
> xmit_lock for synchronization instead.

Do you have stmmac hardware to test on?

I believe something is very wrong with the locking there. In
particular... scheduling the stmmac_tx_timer() function to run often
should not do anything bad if locking is correct... but it breaks the
driver rather quickly. [Example patch below, needs applying to two
places in net-next.]

(Other possibility is that hardware races with the driver.)

Giuseppe, is there documentation available for the chip? Driver says

  Documentation available at:
          http://www.stlinux.com

but that page does not work for me...

404 Not Found

Code: NoSuchBucket
Message: The specified bucket does not exist
BucketName: www.stlinux.com
RequestId: 1C8A20CB99AE7F75
HostId:
ljPnqbEpyD8exct5MUgcDXSW8n+I67Yw0aejNhLuBQ0pqN0UCfiRBa3ztlOMngiXoSN+COX+VSw=

Best regards,
									Pavel

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ffbcd03..8040370 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1973,8 +1973,9 @@ static void stmmac_xmit_common(struct sk_buff *skb, struct net_device *dev, int
 	 */
 	priv->tx_count_frames += nfrags + 1;
 	if (likely(priv->tx_coal_frames > priv->tx_count_frames)) {
-		mod_timer(&priv->txtimer,
-			  STMMAC_COAL_TIMER(priv->tx_coal_timer));
+		if (priv->tx_count_frames == nfrags + 1)
+			mod_timer(&priv->txtimer,
+				  STMMAC_COAL_TIMER(priv->tx_coal_timer));
 	} else {
 		priv->tx_count_frames = 0;
 		priv->hw->desc->set_tx_ic(desc);


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2 2/2] net: ethernet: stmmac: remove private tx queue  lock Pavel Machek <pavel@ucw.cz> - 2016-12-15 10:50 +0100
  Re: [PATCH v2 2/2] net: ethernet: stmmac: remove private tx queue  lock Giuseppe CAVALLARO <peppe.cavallaro@st.com> - 2016-12-15 11:10 +0100
    Re: [PATCH v2 2/2] net: ethernet: stmmac: remove private tx queue  lock Pavel Machek <pavel@ucw.cz> - 2016-12-15 11:50 +0100
  Re: [PATCH v2 2/2] net: ethernet: stmmac: remove private tx queue  lock Lino Sanfilippo <LinoSanfilippo@gmx.de> - 2016-12-15 20:50 +0100
    Re: [PATCH v2 2/2] net: ethernet: stmmac: remove private tx queue  lock Pavel Machek <pavel@ucw.cz> - 2016-12-15 23:10 +0100

csiph-web