netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yegor Yefremov <yegorslists@googlemail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev <netdev@vger.kernel.org>, davem@davemloft.net
Subject: Re: [PATCH 1/1] KS8695: update ksp->next_rx_desc_read at the end of rx loop
Date: Wed, 17 Mar 2010 10:39:30 +0100	[thread overview]
Message-ID: <f69abfc31003170239k2d64aa8bgbe3f3ae59a074a05@mail.gmail.com> (raw)
In-Reply-To: <1268754720.3094.55.camel@edumazet-laptop>

On Tue, Mar 16, 2010 at 4:52 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mardi 16 mars 2010 à 16:42 +0100, Yegor Yefremov a écrit :
>> KS8695: update ksp->next_rx_desc_read at the end of rx loop
>>
>> There is no need to adjust the next rx descriptor after each packet,
>> so do it only once at the end of the routine.
>>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> Index: linux-2.6.34-rc1/drivers/net/arm/ks8695net.c
>> ===================================================================
>> --- linux-2.6.34-rc1.orig/drivers/net/arm/ks8695net.c
>> +++ linux-2.6.34-rc1/drivers/net/arm/ks8695net.c
>> @@ -538,12 +538,13 @@ rx_finished:
>>                        */
>>                       last_rx_processed = buff_n;
>>                       buff_n = (buff_n + 1) & MAX_RX_DESC_MASK;
>> -                     /*And note which RX descriptor we last did */
>> -                     if (likely(last_rx_processed != -1))
>> -                             ksp->next_rx_desc_read =
>> -                                     (last_rx_processed + 1) &
>> -                                     MAX_RX_DESC_MASK;
>>       }
>> +
>> +     /*And note which RX descriptor we last did */
>> +     if (likely(last_rx_processed != -1))
>> +             ksp->next_rx_desc_read =
>> +                     (last_rx_processed + 1) & MAX_RX_DESC_MASK;
>> +
>
> Very strange to see all these computations...
>
> At this point, why not use
>
> if (likely(last_rx_processed != -1))
>        ksp->next_rx_desc_read = buff_n;
>
> or even get rid of last_rx_processed completely and do :
>
>
> diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
> index a1d4188..ac6ab04 100644
> --- a/drivers/net/arm/ks8695net.c
> +++ b/drivers/net/arm/ks8695net.c
> @@ -461,7 +461,6 @@ static int ks8695_rx(struct ks8695_priv *ksp, int budget)
>        int buff_n;
>        u32 flags;
>        int pktlen;
> -       int last_rx_processed = -1;
>        int received = 0;
>
>        buff_n = ksp->next_rx_desc_read;
> @@ -533,17 +532,9 @@ rx_failure:
>                        ksp->rx_ring[buff_n].status = cpu_to_le32(RDES_OWN);
>  rx_finished:
>                        received++;
> -                       /* And note this as processed so we can start
> -                        * from here next time
> -                        */
> -                       last_rx_processed = buff_n;
>                        buff_n = (buff_n + 1) & MAX_RX_DESC_MASK;
> -                       /*And note which RX descriptor we last did */
> -                       if (likely(last_rx_processed != -1))
> -                               ksp->next_rx_desc_read =
> -                                       (last_rx_processed + 1) &
> -                                       MAX_RX_DESC_MASK;
>        }
> +       ksp->next_rx_desc_read = buff_n;
>        /* And refill the buffers */
>        ks8695_refill_rxbuffers(ksp);

Thank you for reviewing. Great idea. This simplifies the driver a
little. I tested your patch and everything is working as before. I
also added your signed-off-by and made some beatifications.

Yegor

  reply	other threads:[~2010-03-17  9:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16 15:42 [PATCH 1/1] KS8695: update ksp->next_rx_desc_read at the end of rx loop Yegor Yefremov
2010-03-16 15:52 ` Eric Dumazet
2010-03-17  9:39   ` Yegor Yefremov [this message]
2010-03-17  9:40     ` Yegor Yefremov
2010-03-20  5:44       ` 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=f69abfc31003170239k2d64aa8bgbe3f3ae59a074a05@mail.gmail.com \
    --to=yegorslists@googlemail.com \
    --cc=davem@davemloft.net \
    --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).