linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: mv88e6xxx: call _mv88e6xxx_stats_wait with SMI lock held
@ 2015-08-03 13:17 Vivien Didelot
  2015-08-03 15:01 ` Guenter Roeck
  2015-08-03 22:46 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Vivien Didelot @ 2015-08-03 13:17 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Guenter Roeck,
	Andrew Lunn, Florian Fainelli, Vivien Didelot

At switch setup, _mv88e6xxx_stats_wait was called without holding the
SMI mutex. Fix this by requesting the lock for this call.

Also, return the _mv88e6xxx_stats_wait code, since it may fail.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 5e1dce1..8966cf2 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -1938,6 +1938,7 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
 int mv88e6xxx_setup_global(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+	int ret;
 	int i;
 
 	/* Set the default address aging time to 5 minutes, and
@@ -2036,9 +2037,11 @@ int mv88e6xxx_setup_global(struct dsa_switch *ds)
 	REG_WRITE(REG_GLOBAL, GLOBAL_STATS_OP, GLOBAL_STATS_OP_FLUSH_ALL);
 
 	/* Wait for the flush to complete. */
-	_mv88e6xxx_stats_wait(ds);
+	mutex_lock(&ps->smi_mutex);
+	ret = _mv88e6xxx_stats_wait(ds);
+	mutex_unlock(&ps->smi_mutex);
 
-	return 0;
+	return ret;
 }
 
 int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active)
-- 
2.4.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dsa: mv88e6xxx: call _mv88e6xxx_stats_wait with SMI lock held
  2015-08-03 13:17 [PATCH] net: dsa: mv88e6xxx: call _mv88e6xxx_stats_wait with SMI lock held Vivien Didelot
@ 2015-08-03 15:01 ` Guenter Roeck
  2015-08-03 22:46 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2015-08-03 15:01 UTC (permalink / raw)
  To: Vivien Didelot, netdev
  Cc: linux-kernel, kernel, David S. Miller, Andrew Lunn, Florian Fainelli

On 08/03/2015 06:17 AM, Vivien Didelot wrote:
> At switch setup, _mv88e6xxx_stats_wait was called without holding the
> SMI mutex. Fix this by requesting the lock for this call.
>
> Also, return the _mv88e6xxx_stats_wait code, since it may fail.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Not strictly needed because the mutex is initialized in the same call
sequence, but it doesn't hurt and is technically ok (and may prevent others
from submitting the same patch again ;-)

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/net/dsa/mv88e6xxx.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 5e1dce1..8966cf2 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -1938,6 +1938,7 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
>   int mv88e6xxx_setup_global(struct dsa_switch *ds)
>   {
>   	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
> +	int ret;
>   	int i;
>
>   	/* Set the default address aging time to 5 minutes, and
> @@ -2036,9 +2037,11 @@ int mv88e6xxx_setup_global(struct dsa_switch *ds)
>   	REG_WRITE(REG_GLOBAL, GLOBAL_STATS_OP, GLOBAL_STATS_OP_FLUSH_ALL);
>
>   	/* Wait for the flush to complete. */
> -	_mv88e6xxx_stats_wait(ds);
> +	mutex_lock(&ps->smi_mutex);
> +	ret = _mv88e6xxx_stats_wait(ds);
> +	mutex_unlock(&ps->smi_mutex);
>
> -	return 0;
> +	return ret;
>   }
>
>   int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active)
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dsa: mv88e6xxx: call _mv88e6xxx_stats_wait with SMI lock held
  2015-08-03 13:17 [PATCH] net: dsa: mv88e6xxx: call _mv88e6xxx_stats_wait with SMI lock held Vivien Didelot
  2015-08-03 15:01 ` Guenter Roeck
@ 2015-08-03 22:46 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-08-03 22:46 UTC (permalink / raw)
  To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, linux, andrew, f.fainelli

From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Mon,  3 Aug 2015 09:17:44 -0400

> At switch setup, _mv88e6xxx_stats_wait was called without holding the
> SMI mutex. Fix this by requesting the lock for this call.
> 
> Also, return the _mv88e6xxx_stats_wait code, since it may fail.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-03 22:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 13:17 [PATCH] net: dsa: mv88e6xxx: call _mv88e6xxx_stats_wait with SMI lock held Vivien Didelot
2015-08-03 15:01 ` Guenter Roeck
2015-08-03 22:46 ` David Miller

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