netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: better error reporting
@ 2015-10-03 17:09 Russell King
  2015-10-03 19:27 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Russell King @ 2015-10-03 17:09 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, Guenter Roeck

Add additional error reporting to the generic DSA code, so it's easier
to debug when things go wrong.  This was useful when initially bringing
up 88e6176 on a new board.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 net/dsa/dsa.c   |  4 ++--
 net/dsa/slave.c | 24 ++++++++++++++++--------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index c59fa5d9c22c..aa398bcef9e3 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -326,8 +326,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
 
 		ret = dsa_slave_create(ds, parent, i, pd->port_names[i]);
 		if (ret < 0) {
-			netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s)\n",
-				   index, i, pd->port_names[i]);
+			netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
+				   index, i, pd->port_names[i], ret);
 			ret = 0;
 		}
 	}
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index cce97385f743..115a3fda36b3 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1010,8 +1010,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
 	struct dsa_switch *ds = p->parent;
 
 	p->phy = ds->slave_mii_bus->phy_map[addr];
-	if (!p->phy)
+	if (!p->phy) {
+		netdev_err(slave_dev, "no phy at %d\n", addr);
 		return -ENODEV;
+	}
 
 	/* Use already configured phy mode */
 	if (p->phy_interface == PHY_INTERFACE_MODE_NA)
@@ -1045,7 +1047,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 		 */
 		ret = of_phy_register_fixed_link(port_dn);
 		if (ret) {
-			netdev_err(slave_dev, "failed to register fixed PHY\n");
+			netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret);
 			return ret;
 		}
 		phy_is_fixed = true;
@@ -1056,17 +1058,20 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 		phy_flags = ds->drv->get_phy_flags(ds, p->port);
 
 	if (phy_dn) {
-		ret = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
+		int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
+
 		/* If this PHY address is part of phys_mii_mask, which means
 		 * that we need to divert reads and writes to/from it, then we
 		 * want to bind this device using the slave MII bus created by
 		 * DSA to make that happen.
 		 */
-		if (!phy_is_fixed && ret >= 0 &&
-		    (ds->phys_mii_mask & (1 << ret))) {
-			ret = dsa_slave_phy_connect(p, slave_dev, ret);
-			if (ret)
+		if (!phy_is_fixed && phy_id >= 0 &&
+		    (ds->phys_mii_mask & (1 << phy_id))) {
+			ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
+			if (ret) {
+				netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
 				return ret;
+			}
 		} else {
 			p->phy = of_phy_connect(slave_dev, phy_dn,
 						dsa_slave_adjust_link,
@@ -1083,8 +1088,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 	 */
 	if (!p->phy) {
 		ret = dsa_slave_phy_connect(p, slave_dev, p->port);
-		if (ret)
+		if (ret) {
+			netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret);
 			return ret;
+		}
 	} else {
 		netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
 			    p->phy->addr, p->phy->drv->name);
@@ -1195,6 +1202,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 
 	ret = dsa_slave_phy_setup(p, slave_dev);
 	if (ret) {
+		netdev_err(master, "error %d setting up slave phy\n", ret);
 		free_netdev(slave_dev);
 		return ret;
 	}
-- 
2.1.0

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

* Re: [PATCH] net: dsa: better error reporting
  2015-10-03 17:09 [PATCH] net: dsa: better error reporting Russell King
@ 2015-10-03 19:27 ` Andrew Lunn
  2015-10-03 20:16 ` Florian Fainelli
  2015-10-07  9:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2015-10-03 19:27 UTC (permalink / raw)
  To: Russell King; +Cc: netdev, Guenter Roeck

On Sat, Oct 03, 2015 at 06:09:07PM +0100, Russell King wrote:
> Add additional error reporting to the generic DSA code, so it's easier
> to debug when things go wrong.  This was useful when initially bringing
> up 88e6176 on a new board.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks
	Andrew

> ---
>  net/dsa/dsa.c   |  4 ++--
>  net/dsa/slave.c | 24 ++++++++++++++++--------
>  2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index c59fa5d9c22c..aa398bcef9e3 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -326,8 +326,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
>  
>  		ret = dsa_slave_create(ds, parent, i, pd->port_names[i]);
>  		if (ret < 0) {
> -			netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s)\n",
> -				   index, i, pd->port_names[i]);
> +			netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
> +				   index, i, pd->port_names[i], ret);
>  			ret = 0;
>  		}
>  	}
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index cce97385f743..115a3fda36b3 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1010,8 +1010,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
>  	struct dsa_switch *ds = p->parent;
>  
>  	p->phy = ds->slave_mii_bus->phy_map[addr];
> -	if (!p->phy)
> +	if (!p->phy) {
> +		netdev_err(slave_dev, "no phy at %d\n", addr);
>  		return -ENODEV;
> +	}
>  
>  	/* Use already configured phy mode */
>  	if (p->phy_interface == PHY_INTERFACE_MODE_NA)
> @@ -1045,7 +1047,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
>  		 */
>  		ret = of_phy_register_fixed_link(port_dn);
>  		if (ret) {
> -			netdev_err(slave_dev, "failed to register fixed PHY\n");
> +			netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret);
>  			return ret;
>  		}
>  		phy_is_fixed = true;
> @@ -1056,17 +1058,20 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
>  		phy_flags = ds->drv->get_phy_flags(ds, p->port);
>  
>  	if (phy_dn) {
> -		ret = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
> +		int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
> +
>  		/* If this PHY address is part of phys_mii_mask, which means
>  		 * that we need to divert reads and writes to/from it, then we
>  		 * want to bind this device using the slave MII bus created by
>  		 * DSA to make that happen.
>  		 */
> -		if (!phy_is_fixed && ret >= 0 &&
> -		    (ds->phys_mii_mask & (1 << ret))) {
> -			ret = dsa_slave_phy_connect(p, slave_dev, ret);
> -			if (ret)
> +		if (!phy_is_fixed && phy_id >= 0 &&
> +		    (ds->phys_mii_mask & (1 << phy_id))) {
> +			ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
> +			if (ret) {
> +				netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
>  				return ret;
> +			}
>  		} else {
>  			p->phy = of_phy_connect(slave_dev, phy_dn,
>  						dsa_slave_adjust_link,
> @@ -1083,8 +1088,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
>  	 */
>  	if (!p->phy) {
>  		ret = dsa_slave_phy_connect(p, slave_dev, p->port);
> -		if (ret)
> +		if (ret) {
> +			netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret);
>  			return ret;
> +		}
>  	} else {
>  		netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
>  			    p->phy->addr, p->phy->drv->name);
> @@ -1195,6 +1202,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
>  
>  	ret = dsa_slave_phy_setup(p, slave_dev);
>  	if (ret) {
> +		netdev_err(master, "error %d setting up slave phy\n", ret);
>  		free_netdev(slave_dev);
>  		return ret;
>  	}
> -- 
> 2.1.0
> 

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

* Re: [PATCH] net: dsa: better error reporting
  2015-10-03 17:09 [PATCH] net: dsa: better error reporting Russell King
  2015-10-03 19:27 ` Andrew Lunn
@ 2015-10-03 20:16 ` Florian Fainelli
  2015-10-07  9:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2015-10-03 20:16 UTC (permalink / raw)
  To: Russell King, netdev; +Cc: Andrew Lunn, Guenter Roeck

Le 03/10/2015 10:09, Russell King a écrit :
> Add additional error reporting to the generic DSA code, so it's easier
> to debug when things go wrong.  This was useful when initially bringing
> up 88e6176 on a new board.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---

[snip]

>  	} else {
>  		netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
>  			    p->phy->addr, p->phy->drv->name);
> @@ -1195,6 +1202,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
>  
>  	ret = dsa_slave_phy_setup(p, slave_dev);
>  	if (ret) {
> +		netdev_err(master, "error %d setting up slave phy\n", ret);
>  		free_netdev(slave_dev);
>  		return ret;

All of these debug messages are going to happen prior to the slave
network device being registered, so you would get these error messages
to be printed with an extraneous " (unregistered)" which is fine, just a
tad annoying sometimes.

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH] net: dsa: better error reporting
  2015-10-03 17:09 [PATCH] net: dsa: better error reporting Russell King
  2015-10-03 19:27 ` Andrew Lunn
  2015-10-03 20:16 ` Florian Fainelli
@ 2015-10-07  9:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-10-07  9:59 UTC (permalink / raw)
  To: rmk+kernel; +Cc: netdev, andrew, linux

From: Russell King <rmk+kernel@arm.linux.org.uk>
Date: Sat, 03 Oct 2015 18:09:07 +0100

> Add additional error reporting to the generic DSA code, so it's easier
> to debug when things go wrong.  This was useful when initially bringing
> up 88e6176 on a new board.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Applied.

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

end of thread, other threads:[~2015-10-07  9:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-03 17:09 [PATCH] net: dsa: better error reporting Russell King
2015-10-03 19:27 ` Andrew Lunn
2015-10-03 20:16 ` Florian Fainelli
2015-10-07  9:59 ` 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).