public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter <linux@roeck-us.net>
To: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew@lunn.ch>,
	linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com
Subject: Re: [PATCH 1/2] net: dsa: mv88e6xxx: sleep in _mv88e6xxx_stats_wait
Date: Fri, 10 Jul 2015 10:10:27 -0700	[thread overview]
Message-ID: <20150710171027.GB6585@groeck-UX31A> (raw)
In-Reply-To: <1436547449-26927-1-git-send-email-vivien.didelot@savoirfairelinux.com>

On Fri, Jul 10, 2015 at 12:57:28PM -0400, Vivien Didelot wrote:
> The current _mv88e6xxx_stats_wait function does not sleep while testing
> the stats busy bit. Fix this by using the generic _mv88e6xxx_wait
> function.
> 
> Note that it requires to move _mv88e6xxx_wait on top of
> _mv88e6xxx_stats_wait to avoid undefined reference compilation error.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
> ---
>  drivers/net/dsa/mv88e6xxx.c | 52 +++++++++++++++++++--------------------------
>  1 file changed, 22 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index f6c7409..7753db1 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -557,19 +557,31 @@ static bool mv88e6xxx_6352_family(struct dsa_switch *ds)
>  	return false;
>  }
>  
> +/* Must be called with SMI lock held */
> +static int _mv88e6xxx_wait(struct dsa_switch *ds, int reg, int offset,
> +			   u16 mask)
> +{
> +	unsigned long timeout = jiffies + HZ / 10;
> +
> +	while (time_before(jiffies, timeout)) {
> +		int ret;
> +
> +		ret = _mv88e6xxx_reg_read(ds, reg, offset);
> +		if (ret < 0)
> +			return ret;
> +		if (!(ret & mask))
> +			return 0;
> +
> +		usleep_range(1000, 2000);
> +	}
> +	return -ETIMEDOUT;
> +}
> +
>  /* Must be called with SMI mutex held */
>  static int _mv88e6xxx_stats_wait(struct dsa_switch *ds)
>  {
> -	int ret;
> -	int i;
> -
> -	for (i = 0; i < 10; i++) {
> -		ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_STATS_OP);
> -		if ((ret & GLOBAL_STATS_OP_BUSY) == 0)
> -			return 0;
> -	}

Hi Vivien,

is this really beneficial and/or needed ? It adds at least 1ms delay
to a loop which did not have any delay at all unless the register
read itself was sleeping. Is the original function seen to return
a timeout error under some circumstances ?

Thanks,
Guenter

  parent reply	other threads:[~2015-07-10 17:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10 16:57 [PATCH 1/2] net: dsa: mv88e6xxx: sleep in _mv88e6xxx_stats_wait Vivien Didelot
2015-07-10 16:57 ` [PATCH 2/2] net: dsa: mv88e6xxx: call _mv88e6xxx_stats_wait with SMI lock held Vivien Didelot
2015-07-10 17:13   ` Guenter
2015-07-10 17:10 ` Guenter [this message]
2015-07-10 18:20   ` [PATCH 1/2] net: dsa: mv88e6xxx: sleep in _mv88e6xxx_stats_wait Vivien Didelot
2015-07-10 18:36     ` Guenter Roeck
2015-07-10 19:21       ` Vivien Didelot
2015-07-10 20:05         ` Guenter
2015-07-18 14:58           ` Andrew Lunn
2015-07-18 15:23             ` Vivien Didelot
2015-07-18 15:28               ` Andrew Lunn

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=20150710171027.GB6585@groeck-UX31A \
    --to=linux@roeck-us.net \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    /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