[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151030204110.GB10053@lunn.ch>
Date: Fri, 30 Oct 2015 21:41:10 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Vivien Didelot <vivien.didelot@...oirfairelinux.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel@...oirfairelinux.com,
"David S. Miller" <davem@...emloft.net>,
Florian Fainelli <f.fainelli@...il.com>,
Guenter Roeck <linux@...ck-us.net>,
Neil Armstrong <narmstrong@...libre.com>
Subject: Re: [PATCH net-next] net: dsa: mv88e6xxx: assert SMI lock
On Fri, Oct 30, 2015 at 04:35:42PM -0400, Vivien Didelot wrote:
> It's easy to forget to lock the smi_mutex before calling the low-level
> _mv88e6xxx_reg_{read,write}, so add a assert_smi_lock function in them.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@...oirfairelinux.com>
> ---
> drivers/net/dsa/mv88e6xxx.c | 31 ++++++++++++++++++-------------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index b1b14f5..70a0106 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -24,6 +24,16 @@
> #include <net/switchdev.h>
> #include "mv88e6xxx.h"
>
> +static inline void assert_smi_lock(struct dsa_switch *ds)
No need for inline. Gcc will automatically inline it, if it thinks it
is small enough.
> +{
> + struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
> +
> + if (unlikely(!mutex_is_locked(&ps->smi_mutex))) {
> + dev_err(ds->master_dev, "SMI lock not held!\n");
> + dump_stack();
> + }
> +}
> +
> -/* Must be called with SMI mutex held */
> static int _mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg)
> {
> - struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);
> + struct mii_bus *bus;
> int ret;
>
> + assert_smi_lock(ds);
> +
> + bus = dsa_host_dev_to_mii_bus(ds->master_dev);
Is this change of when bus is assigned actually required?
Thanks
Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists