netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] dsa: bug fixes
@ 2013-01-21 19:58 Florian Fainelli
  2013-01-21 19:58 ` [PATCH 1/2] dsa: use an unique and non conflicting bus name for the slave MII bus Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Florian Fainelli @ 2013-01-21 19:58 UTC (permalink / raw)
  To: netdev; +Cc: buytenh, konszert, davem, Florian Fainelli

Hello David, Lennert,

These two patches are non-critical bugfixes based on net-next which I
stumbled upon while working on Device Tree bindings for DSA (will comme
as a separate patch later).

Florian Fainelli (2):
  dsa: use an unique and non conflicting bus name for the slave MII bus
  dsa: make dsa_switch_setup check for valid port names

 net/dsa/dsa.c   |    6 ++++++
 net/dsa/slave.c |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

-- 
1.7.10.4

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

* [PATCH 1/2] dsa: use an unique and non conflicting bus name for the slave MII bus
  2013-01-21 19:58 [PATCH 0/2] dsa: bug fixes Florian Fainelli
@ 2013-01-21 19:58 ` Florian Fainelli
  2013-01-21 19:58 ` [PATCH 2/2] dsa: make dsa_switch_setup check for valid port names Florian Fainelli
  2013-01-21 20:41 ` [PATCH 0/2] dsa: bug fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2013-01-21 19:58 UTC (permalink / raw)
  To: netdev; +Cc: buytenh, konszert, davem, Florian Fainelli

The slave MII bus registered by the DSA code is using the parent MII bus
as part of its name (ds->master_mii_bus_id), in case the parent MII bus
name is already 16 characters long (such as d0072004.mdio-mi) we will
get the following WARN_ON in dsa_switch_setup() when calling
mdiobus_register():

[   79.088782] ------------[ cut here ]------------
[   79.093448] WARNING: at fs/sysfs/dir.c:536 sysfs_add_one+0x80/0xa0()
[   79.099831] sysfs: cannot create duplicate filename
'/class/mdio_bus/d0072004.mdio-mi'

This is a genuine warning, because the DSA slave MII bus will also be
named d0072004.mdio-mi, and since MII_BUS_ID_SIZE is 17 characters long
(with null-terminator) the following will truncate the slave MII bus id:

snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "%s-%d:%.2x",
                        ds->master_mii_bus->id, ds->pd->sw_addr);

Fix this by using dsa-<switch index->:<sw_add> which is guaranteed to be
unique.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 net/dsa/slave.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index f434558..6ebd8fb 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -41,8 +41,8 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds)
 	ds->slave_mii_bus->name = "dsa slave smi";
 	ds->slave_mii_bus->read = dsa_slave_phy_read;
 	ds->slave_mii_bus->write = dsa_slave_phy_write;
-	snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "%s:%.2x",
-			ds->master_mii_bus->id, ds->pd->sw_addr);
+	snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d:%.2x",
+			ds->index, ds->pd->sw_addr);
 	ds->slave_mii_bus->parent = &ds->master_mii_bus->dev;
 }
 
-- 
1.7.10.4

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

* [PATCH 2/2] dsa: make dsa_switch_setup check for valid port names
  2013-01-21 19:58 [PATCH 0/2] dsa: bug fixes Florian Fainelli
  2013-01-21 19:58 ` [PATCH 1/2] dsa: use an unique and non conflicting bus name for the slave MII bus Florian Fainelli
@ 2013-01-21 19:58 ` Florian Fainelli
  2013-01-21 20:41 ` [PATCH 0/2] dsa: bug fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2013-01-21 19:58 UTC (permalink / raw)
  To: netdev; +Cc: buytenh, konszert, davem, Florian Fainelli

This patch changes dsa_switch_setup() to ensure that at least one valid
valid port name is specified and will bail out with an error in case we
walked the maximum number of port with a valid port name found.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 net/dsa/dsa.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 45295ca..2bc62ea 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -80,6 +80,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
 	int ret;
 	char *name;
 	int i;
+	bool valid_name_found = false;
 
 	/*
 	 * Probe for switch model.
@@ -131,8 +132,13 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
 		} else {
 			ds->phys_port_mask |= 1 << i;
 		}
+		valid_name_found = true;
 	}
 
+	if (!valid_name_found && i == DSA_MAX_PORTS) {
+		ret = -EINVAL;
+		goto out;
+	}
 
 	/*
 	 * If the CPU connects to this switch, set the switch tree
-- 
1.7.10.4

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

* Re: [PATCH 0/2] dsa: bug fixes
  2013-01-21 19:58 [PATCH 0/2] dsa: bug fixes Florian Fainelli
  2013-01-21 19:58 ` [PATCH 1/2] dsa: use an unique and non conflicting bus name for the slave MII bus Florian Fainelli
  2013-01-21 19:58 ` [PATCH 2/2] dsa: make dsa_switch_setup check for valid port names Florian Fainelli
@ 2013-01-21 20:41 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-01-21 20:41 UTC (permalink / raw)
  To: florian; +Cc: netdev, buytenh, konszert

From: Florian Fainelli <florian@openwrt.org>
Date: Mon, 21 Jan 2013 20:58:49 +0100

> These two patches are non-critical bugfixes based on net-next which I
> stumbled upon while working on Device Tree bindings for DSA (will comme
> as a separate patch later).
> 
> Florian Fainelli (2):
>   dsa: use an unique and non conflicting bus name for the slave MII bus
>   dsa: make dsa_switch_setup check for valid port names

This looks fine to me, all applied to net-next, thanks.

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

end of thread, other threads:[~2013-01-21 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-21 19:58 [PATCH 0/2] dsa: bug fixes Florian Fainelli
2013-01-21 19:58 ` [PATCH 1/2] dsa: use an unique and non conflicting bus name for the slave MII bus Florian Fainelli
2013-01-21 19:58 ` [PATCH 2/2] dsa: make dsa_switch_setup check for valid port names Florian Fainelli
2013-01-21 20:41 ` [PATCH 0/2] dsa: bug fixes 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).