netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
	<dwmw2@infradead.org>, <dave.taht@bufferbloat.net>
Subject: Re: [PATCH] net: 8139cp: fix a BUG_ON triggered by wrong bytes_compl
Date: Wed, 27 Nov 2013 14:05:22 +0800	[thread overview]
Message-ID: <52958BA2.4060405@huawei.com> (raw)
In-Reply-To: <1385526903.5352.6.camel@edumazet-glaptop2.roam.corp.google.com>

On 2013/11/27 12:35, Eric Dumazet wrote:
> On Wed, 2013-11-27 at 12:07 +0800, Yang Yingliang wrote:
>> Using iperf to send packets(GSO mode is on), a bug is triggered:
>>
> 
>> When a skb has frags, bytes_compl plus skb->len nr_frags times in cp_tx().
>> It's not the correct value(actually, it should plus skb->len once) and it
>> will trigger the BUG_ON(bytes_compl > num_queued - dql->num_completed).Use
>> txd->opts1 which stores the real length of a frag in cp_start_xmit() to
>> calculate bytes_compl.
>> pkts_compl also has a wrong value, fix it too.
>>
>> It's introduced by commit 871f0d4c("8139cp: enable bql").
>>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>>  drivers/net/ethernet/realtek/8139cp.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
>> index f2a2128..3b837f0 100644
>> --- a/drivers/net/ethernet/realtek/8139cp.c
>> +++ b/drivers/net/ethernet/realtek/8139cp.c
>> @@ -664,7 +664,7 @@ static void cp_tx (struct cp_private *cp)
>>  	while (tx_tail != tx_head) {
>>  		struct cp_desc *txd = cp->tx_ring + tx_tail;
>>  		struct sk_buff *skb;
>> -		u32 status;
>> +		u32 status, flags;
>>  
>>  		rmb();
>>  		status = le32_to_cpu(txd->opts1);
>> @@ -678,8 +678,10 @@ static void cp_tx (struct cp_private *cp)
>>  				 le32_to_cpu(txd->opts1) & 0xffff,
>>  				 PCI_DMA_TODEVICE);
>>  
>> -		bytes_compl += skb->len;
>> -		pkts_compl++;
>> +		flags = le32_to_cpu(txd->opts1);
> 
> Why not using 'status' here, its the same value.
> 
>> +		bytes_compl += (flags & 0xffff);
>> +		if (flags & FirstFrag)
>> +			pkts_compl++;
>>  
>>  		if (status & LastFrag) {
>>  			if (status & (TxError | TxFIFOUnder)) {
> 
> I dont know, this seems a bit convoluted and dangerous, as
> cp_start_xmit() did :
> 
> netdev_sent_queue(dev, skb->len);

I tried to let pkts_compl equals sum of every frags' length.
Your way looks more simpler. I'll post an updated version of
the patch as you suggested.

Thanks!

> 
> So I would just use :
> 
> diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
> index f2a2128165dd..4a935a966e28 100644
> --- a/drivers/net/ethernet/realtek/8139cp.c
> +++ b/drivers/net/ethernet/realtek/8139cp.c
> @@ -678,8 +678,6 @@ static void cp_tx (struct cp_private *cp)
>  				 le32_to_cpu(txd->opts1) & 0xffff,
>  				 PCI_DMA_TODEVICE);
>  
> -		bytes_compl += skb->len;
> -		pkts_compl++;
>  
>  		if (status & LastFrag) {
>  			if (status & (TxError | TxFIFOUnder)) {
> @@ -702,6 +700,8 @@ static void cp_tx (struct cp_private *cp)
>  				netif_dbg(cp, tx_done, cp->dev,
>  					  "tx done, slot %d\n", tx_tail);
>  			}
> +			bytes_compl += skb->len;
> +			pkts_compl++;
>  			dev_kfree_skb_irq(skb);
>  		}
>  
> 
> 
> 
> .
> 

  reply	other threads:[~2013-11-27  6:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27  4:07 [PATCH] net: 8139cp: fix a BUG_ON triggered by wrong bytes_compl Yang Yingliang
2013-11-27  4:35 ` Eric Dumazet
2013-11-27  6:05   ` Yang Yingliang [this message]
2013-11-27  6:32   ` [PATCH v2] " Yang Yingliang
2013-11-29 21:19     ` 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=52958BA2.4060405@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=dave.taht@bufferbloat.net \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=eric.dumazet@gmail.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;
as well as URLs for NNTP newsgroup(s).