Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Hauke Mehrtens <hauke@hauke-m.de>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	davem@davemloft.net
Cc: kuba@kernel.org, netdev@vger.kernel.org,
	martin.blumenstingl@googlemail.com
Subject: Re: [PATCH 3/3] net: lantiq: Use napi_complete_done()
Date: Mon, 17 Aug 2020 17:33:52 -0700	[thread overview]
Message-ID: <28b6bd3f-761c-9143-e90d-30af5d76e3ed@gmail.com> (raw)
In-Reply-To: <718dce81-ace3-aaad-0f81-e75e227cd722@hauke-m.de>



On 8/17/20 2:17 PM, Hauke Mehrtens wrote:
> On 8/16/20 8:07 PM, Eric Dumazet wrote:
>>
>>
>> On 8/15/20 11:33 AM, Hauke Mehrtens wrote:
>>> Use napi_complete_done() and activate the interrupts when this function
>>> returns true. This way the generic NAPI code can take care of activating
>>> the interrupts.
>>>
>>> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
>>> ---
>>>  drivers/net/ethernet/lantiq_xrx200.c | 8 ++------
>>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
>>> index f34e4dc8c661..674ffb2ecd9a 100644
>>> --- a/drivers/net/ethernet/lantiq_xrx200.c
>>> +++ b/drivers/net/ethernet/lantiq_xrx200.c
>>> @@ -229,10 +229,8 @@ static int xrx200_poll_rx(struct napi_struct *napi, int budget)
>>>  		}
>>>  	}
>>>  
>>> -	if (rx < budget) {
>>> -		napi_complete(&ch->napi);
>>> +	if (napi_complete_done(&ch->napi, rx))
>>>  		ltq_dma_enable_irq(&ch->dma);
>>> -	}
>>>  
>>>  	return rx;
>>>  }
>>> @@ -271,10 +269,8 @@ static int xrx200_tx_housekeeping(struct napi_struct *napi, int budget)
>>>  	if (netif_queue_stopped(net_dev))
>>>  		netif_wake_queue(net_dev);
>>>  
>>> -	if (pkts < budget) {
>>> -		napi_complete(&ch->napi);
>>> +	if (napi_complete_done(&ch->napi, pkts))
>>>  		ltq_dma_enable_irq(&ch->dma);
>>> -	}
>>>  
>>>  	return pkts;
>>>  }
>>>
>>
>>
>> This looks buggy to me.
> 
> Hi Eric,
> 
> Thanks for looking at the patch.
> 
> What exactly looks buggy to you?

You removed the " if (rx < budget) "

But you must not.

Drivers have to keep the test.

Something like that seems more correct :

diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
index 1645e4e7ebdbb3c7abff8fe4207273df20f123d4..e3d617d387ed0f5593c3ba81d1d531d463bb5a6e 100644
--- a/drivers/net/ethernet/lantiq_xrx200.c
+++ b/drivers/net/ethernet/lantiq_xrx200.c
@@ -230,8 +230,8 @@ static int xrx200_poll_rx(struct napi_struct *napi, int budget)
        }
 
        if (rx < budget) {
-               napi_complete(&ch->napi);
-               ltq_dma_enable_irq(&ch->dma);
+               if (napi_complete(&ch->napi, rx))
+                       ltq_dma_enable_irq(&ch->dma);
        }
 
        return rx;
@@ -269,8 +269,8 @@ static int xrx200_tx_housekeeping(struct napi_struct *napi, int budget)
        netdev_completed_queue(ch->priv->net_dev, pkts, bytes);
 
        if (pkts < budget) {
-               napi_complete(&ch->napi);
-               ltq_dma_enable_irq(&ch->dma);
+               if (napi_complete(&ch->napi, pkts))
+                       ltq_dma_enable_irq(&ch->dma);
        }
 
        return pkts;


  reply	other threads:[~2020-08-18  0:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-15 18:33 [PATCH 1/3] net: lantiq: Wake TX queue again Hauke Mehrtens
2020-08-15 18:33 ` [PATCH 2/3] net: lantiq: use netif_tx_napi_add() for TX NAPI Hauke Mehrtens
2020-08-16 18:05   ` Eric Dumazet
2020-08-15 18:33 ` [PATCH 3/3] net: lantiq: Use napi_complete_done() Hauke Mehrtens
2020-08-16 18:07   ` Eric Dumazet
2020-08-17 21:17     ` Hauke Mehrtens
2020-08-18  0:33       ` Eric Dumazet [this message]
2020-08-18  0:48         ` Eric Dumazet

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=28b6bd3f-761c-9143-e90d-30af5d76e3ed@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hauke@hauke-m.de \
    --cc=kuba@kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH 3/3] net: lantiq: Use napi_complete_done()' \
    /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

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).