Re: [PATCH v2] ethernet:arc: Fix racing of TX ring buffer

2016-06-05 Thread Shuyu Wei
On Mon, May 30, 2016 at 11:41:22PM +0200, Lino Sanfilippo wrote: > > Did you see the same issues with the patch before (the one that, as you wrote, > survived a whole night of stress testing)? > > Lino Hi Lino, Sorry for my late reply. I retested the previous patch, it did have the same issue. H

Re: [PATCH v2] ethernet:arc: Fix racing of TX ring buffer

2016-05-27 Thread Shuyu Wei
On Wed, May 25, 2016 at 01:56:20AM +0200, Lino Sanfilippo wrote: > Francois, Shuyu, > > this is the patch with the discussed changes. > > Shuyu it would be great if you could test this one. If it passes > and there are no further objections I will resend it as a regular patch > (including commit

Re: [PATCH v2] ethernet:arc: Fix racing of TX ring buffer

2016-05-23 Thread Shuyu Wei
On Sun, May 22, 2016 at 01:30:27PM +0200, Lino Sanfilippo wrote: > > Thanks for testing. However that extra check for skb not being NULL should > not be > necessary if the code were correct. The changes I suggested were all about > having > skb and info consistent with txbd_curr. > But I just re

Re: [PATCH v2] ethernet:arc: Fix racing of TX ring buffer

2016-05-22 Thread Shuyu Wei
On Sun, May 22, 2016 at 12:58:55AM +0200, Lino Sanfilippo wrote: > --- a/drivers/net/ethernet/arc/emac_main.c > +++ b/drivers/net/ethernet/arc/emac_main.c > @@ -162,7 +162,13 @@ static void arc_emac_tx_clean(struct net_device *ndev) > struct sk_buff *skb = tx_buff->skb; >

Re: [PATCH v2] ethernet:arc: Fix racing of TX ring buffer

2016-05-21 Thread Shuyu Wei
Looks like I got it wrong in the first place. priv->tx_buff is not for the device, so there's no need to move it. The race has been fixed by commit c278c253f3d9, I forgot to check it out. That's my fault. I do find another problem. We need to use a barrier to make sure skb_tx_timestamp() is calle

Re: [PATCH v2] ethernet:arc: Fix racing of TX ring buffer

2016-05-21 Thread Shuyu Wei
On Thu, May 19, 2016 at 11:15:56PM +0200, Lino Sanfilippo wrote: > drivers/net/ethernet/arc/emac_main.c | 33 + > 1 file changed, 17 insertions(+), 16 deletions(-) > > diff --git a/drivers/net/ethernet/arc/emac_main.c > b/drivers/net/ethernet/arc/emac_main.c > ind

[PATCH v2] ethernet:arc: Fix racing of TX ring buffer

2016-05-17 Thread Shuyu Wei
Setting the FOR_EMAC flag should be the last step of modifying the buffer descriptor, or possible racing will occur. The loop counter i in tx_clean() is not needed, and we need to make sure it does not clear the finished txbds. Signed-off-by: Shuyu Wei --- Changes in v2: - Remove loop counter

Re: [PATCH] ethernet:arc: Fix racing of TX ring buffer

2016-05-15 Thread Shuyu Wei
On Sun, May 15, 2016 at 11:19:53AM +0200, Francois Romieu wrote: > > static void arc_emac_tx_clean(struct net_device *ndev) > { > [...] > for (i = 0; i < TX_BD_NUM; i++) { > unsigned int *txbd_dirty = &priv->txbd_dirty; > struct arc_emac_bd *txbd = &priv->tx

Re: [PATCH] ethernet:arc: Fix racing of TX ring buffer

2016-05-14 Thread Shuyu Wei
Sorry, the last two lines is wrong, ignore it. I mean I intended to ignore one or two packets. It's just a trade-off for performance, but it doesn't cause any memory leak.

Re: [PATCH] ethernet:arc: Fix racing of TX ring buffer

2016-05-14 Thread Shuyu Wei
On Sat, May 14, 2016 at 10:03:56PM +0200, Francois Romieu wrote: > Shuyu Wei : > > The tail of the ring buffer(txbd_dirty) should never go ahead of the > > head(txbd_curr) or the ring buffer will corrupt. > > > > This is the root cause of racing. > > No (se

[PATCH] ethernet:arc: Fix racing of TX ring buffer

2016-05-14 Thread Shuyu Wei
: Shuyu Wei --- diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c index a3a9392..5ece05b 100644 --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c @@ -155,7 +155,7 @@ static void arc_emac_tx_clean(struct net_device *ndev