netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] smsc75xx fixes
@ 2012-04-30 17:56 Steve Glendinning
  2012-04-30 17:56 ` [PATCH 1/7] smsc75xx: mark link down on startup and let PHY interrupt deal with carrier changes Steve Glendinning
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

Stephane Fillod's big patch addresses multiple issues, so this patchset
splits it into a separate patch for each issue.

Thanks to Stephane for finding and fixing these bugs.

Steve Glendinning (7):
  smsc75xx: mark link down on startup and let PHY interrupt deal with
    carrier changes
  smsc75xx: fix mdio reads and writes
  smsc75xx: add more information to register io failure warnings
  smsc75xx: fix phy init reset loop
  smsc75xx: fix phy interrupt acknowledge
  smsc75xx: declare smsc75xx's MII as GMII capable
  smsc75xx: enable mac to detect speed/duplex from phy

 drivers/net/usb/smsc75xx.c |   35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

-- 
1.7.9.5

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

* [PATCH 1/7] smsc75xx: mark link down on startup and let PHY interrupt deal with carrier changes
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
@ 2012-04-30 17:56 ` Steve Glendinning
  2012-04-30 17:56 ` [PATCH 2/7] smsc75xx: fix mdio reads and writes Steve Glendinning
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

This patch fixes the same issue as reported on smsc95xx, where the
usb device is connected with no ethernet cable plugged-in.

Without this patch sysfs reports the cable as present

flag@flag-desktop:~$ cat /sys/class/net/eth0/carrier
1

while it's not:

flag@flag-desktop:~$ sudo mii-tool eth0
eth0: no link

Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/smsc75xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index a234948..b1b4649 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -1212,7 +1212,7 @@ static const struct driver_info smsc75xx_info = {
 	.rx_fixup	= smsc75xx_rx_fixup,
 	.tx_fixup	= smsc75xx_tx_fixup,
 	.status		= smsc75xx_status,
-	.flags		= FLAG_ETHER | FLAG_SEND_ZLP,
+	.flags		= FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR,
 };
 
 static const struct usb_device_id products[] = {
-- 
1.7.9.5

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

* [PATCH 2/7] smsc75xx: fix mdio reads and writes
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
  2012-04-30 17:56 ` [PATCH 1/7] smsc75xx: mark link down on startup and let PHY interrupt deal with carrier changes Steve Glendinning
@ 2012-04-30 17:56 ` Steve Glendinning
  2012-04-30 17:56 ` [PATCH 3/7] smsc75xx: add more information to register io failure warnings Steve Glendinning
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

smsc75xx needs MII_ACCESS_BUSY to be set to correctly trigger mdio I/O.  Note smsc75xx is different from smsc95xx in this regard.

Signed-off-by: Stephane Fillod <fillods@users.sf.net>
Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/smsc75xx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index b1b4649..f97207a 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -171,7 +171,7 @@ static int smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
 	idx &= dev->mii.reg_num_mask;
 	addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR)
 		| ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
-		| MII_ACCESS_READ;
+		| MII_ACCESS_READ | MII_ACCESS_BUSY;
 	ret = smsc75xx_write_reg(dev, MII_ACCESS, addr);
 	check_warn_goto_done(ret, "Error writing MII_ACCESS");
 
@@ -210,7 +210,7 @@ static void smsc75xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
 	idx &= dev->mii.reg_num_mask;
 	addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR)
 		| ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
-		| MII_ACCESS_WRITE;
+		| MII_ACCESS_WRITE | MII_ACCESS_BUSY;
 	ret = smsc75xx_write_reg(dev, MII_ACCESS, addr);
 	check_warn_goto_done(ret, "Error writing MII_ACCESS");
 
-- 
1.7.9.5

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

* [PATCH 3/7] smsc75xx: add more information to register io failure warnings
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
  2012-04-30 17:56 ` [PATCH 1/7] smsc75xx: mark link down on startup and let PHY interrupt deal with carrier changes Steve Glendinning
  2012-04-30 17:56 ` [PATCH 2/7] smsc75xx: fix mdio reads and writes Steve Glendinning
@ 2012-04-30 17:56 ` Steve Glendinning
  2012-04-30 17:56 ` [PATCH 4/7] smsc75xx: fix phy init reset loop Steve Glendinning
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

Signed-off-by: Stephane Fillod <fillods@users.sf.net>
Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/smsc75xx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index f97207a..1de7785 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -98,7 +98,7 @@ static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index,
 
 	if (unlikely(ret < 0))
 		netdev_warn(dev->net,
-			"Failed to read register index 0x%08x", index);
+			"Failed to read reg index 0x%08x: %d", index, ret);
 
 	le32_to_cpus(buf);
 	*data = *buf;
@@ -128,7 +128,7 @@ static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index,
 
 	if (unlikely(ret < 0))
 		netdev_warn(dev->net,
-			"Failed to write register index 0x%08x", index);
+			"Failed to write reg index 0x%08x: %d", index, ret);
 
 	kfree(buf);
 
-- 
1.7.9.5

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

* [PATCH 4/7] smsc75xx: fix phy init reset loop
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
                   ` (2 preceding siblings ...)
  2012-04-30 17:56 ` [PATCH 3/7] smsc75xx: add more information to register io failure warnings Steve Glendinning
@ 2012-04-30 17:56 ` Steve Glendinning
  2012-04-30 17:56 ` [PATCH 5/7] smsc75xx: fix phy interrupt acknowledge Steve Glendinning
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

fix bug in phy_init loop that was ignoring BMCR reset bit, akin to smsc95xx's d946092000698fd204d82a9d239103c656fb63bf

Signed-off-by: Stephane Fillod <fillods@users.sf.net>
Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/smsc75xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 1de7785..cc23a58 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -661,7 +661,7 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
 		bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR);
 		check_warn_return(bmcr, "Error reading MII_BMCR");
 		timeout++;
-	} while ((bmcr & MII_BMCR) && (timeout < 100));
+	} while ((bmcr & BMCR_RESET) && (timeout < 100));
 
 	if (timeout >= 100) {
 		netdev_warn(dev->net, "timeout on PHY Reset");
-- 
1.7.9.5

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

* [PATCH 5/7] smsc75xx: fix phy interrupt acknowledge
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
                   ` (3 preceding siblings ...)
  2012-04-30 17:56 ` [PATCH 4/7] smsc75xx: fix phy init reset loop Steve Glendinning
@ 2012-04-30 17:56 ` Steve Glendinning
  2012-04-30 17:56 ` [PATCH 6/7] smsc75xx: declare smsc75xx's MII as GMII capable Steve Glendinning
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

smsc75xx phy interrupt acknowledge needs an mdio_write to clear
PHY_INT_SRC instead of just a read like in smsc95xx.

Signed-off-by: Stephane Fillod <fillods@users.sf.net>
Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/smsc75xx.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index cc23a58..4941782 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -508,9 +508,10 @@ static int smsc75xx_link_reset(struct usbnet *dev)
 	u16 lcladv, rmtadv;
 	int ret;
 
-	/* clear interrupt status */
+	/* read and write to clear phy interrupt status */
 	ret = smsc75xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC);
 	check_warn_return(ret, "Error reading PHY_INT_SRC");
+	smsc75xx_mdio_write(dev->net, mii->phy_id, PHY_INT_SRC, 0xffff);
 
 	ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL);
 	check_warn_return(ret, "Error writing INT_STS");
@@ -643,7 +644,7 @@ static int smsc75xx_set_mac_address(struct usbnet *dev)
 
 static int smsc75xx_phy_initialize(struct usbnet *dev)
 {
-	int bmcr, timeout = 0;
+	int bmcr, ret, timeout = 0;
 
 	/* Initialize MII structure */
 	dev->mii.dev = dev->net;
@@ -672,9 +673,10 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
 		ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
 		ADVERTISE_PAUSE_ASYM);
 
-	/* read to clear */
-	smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
-	check_warn_return(bmcr, "Error reading PHY_INT_SRC");
+	/* read and write to clear phy interrupt status */
+	ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
+	check_warn_return(ret, "Error reading PHY_INT_SRC");
+	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_SRC, 0xffff);
 
 	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK,
 		PHY_INT_MASK_DEFAULT);
-- 
1.7.9.5

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

* [PATCH 6/7] smsc75xx: declare smsc75xx's MII as GMII capable
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
                   ` (4 preceding siblings ...)
  2012-04-30 17:56 ` [PATCH 5/7] smsc75xx: fix phy interrupt acknowledge Steve Glendinning
@ 2012-04-30 17:56 ` Steve Glendinning
  2012-04-30 17:56 ` [PATCH 7/7] smsc75xx: enable mac to detect speed/duplex from phy Steve Glendinning
  2012-05-01  1:55 ` [PATCH 0/7] smsc75xx fixes David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

also explicitly set the phy to advertise 1000 speeds

Signed-off-by: Stephane Fillod <fillods@users.sf.net>
Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/smsc75xx.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 4941782..ae23d85 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -652,6 +652,7 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
 	dev->mii.mdio_write = smsc75xx_mdio_write;
 	dev->mii.phy_id_mask = 0x1f;
 	dev->mii.reg_num_mask = 0x1f;
+	dev->mii.supports_gmii = 1;
 	dev->mii.phy_id = SMSC75XX_INTERNAL_PHY_ID;
 
 	/* reset phy and wait for reset to complete */
@@ -672,6 +673,8 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
 	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
 		ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
 		ADVERTISE_PAUSE_ASYM);
+	smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
+		ADVERTISE_1000FULL);
 
 	/* read and write to clear phy interrupt status */
 	ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
-- 
1.7.9.5

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

* [PATCH 7/7] smsc75xx: enable mac to detect speed/duplex from phy
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
                   ` (5 preceding siblings ...)
  2012-04-30 17:56 ` [PATCH 6/7] smsc75xx: declare smsc75xx's MII as GMII capable Steve Glendinning
@ 2012-04-30 17:56 ` Steve Glendinning
  2012-05-01  1:55 ` [PATCH 0/7] smsc75xx fixes David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: Steve Glendinning @ 2012-04-30 17:56 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Stephane Fillod, Steve Glendinning

This patch sets the automatic speed and duplex detection bits
in MAC_CR to enable the mac to determine its speed automatically
from the phy.

Note this must be done BEFORE the receiver or transmitter is
enabled.

Signed-off-by: Stephane Fillod <fillods@users.sf.net>
Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
---
 drivers/net/usb/smsc75xx.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index ae23d85..00103a8 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -951,6 +951,14 @@ static int smsc75xx_reset(struct usbnet *dev)
 	ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf);
 	check_warn_return(ret, "Failed to write INT_EP_CTL: %d", ret);
 
+	/* allow mac to detect speed and duplex from phy */
+	ret = smsc75xx_read_reg(dev, MAC_CR, &buf);
+	check_warn_return(ret, "Failed to read MAC_CR: %d", ret);
+
+	buf |= (MAC_CR_ADD | MAC_CR_ASD);
+	ret = smsc75xx_write_reg(dev, MAC_CR, buf);
+	check_warn_return(ret, "Failed to write MAC_CR: %d", ret);
+
 	ret = smsc75xx_read_reg(dev, MAC_TX, &buf);
 	check_warn_return(ret, "Failed to read MAC_TX: %d", ret);
 
-- 
1.7.9.5

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

* Re: [PATCH 0/7] smsc75xx fixes
  2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
                   ` (6 preceding siblings ...)
  2012-04-30 17:56 ` [PATCH 7/7] smsc75xx: enable mac to detect speed/duplex from phy Steve Glendinning
@ 2012-05-01  1:55 ` David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2012-05-01  1:55 UTC (permalink / raw)
  To: steve.glendinning; +Cc: netdev, fillods

From: Steve Glendinning <steve.glendinning@shawell.net>
Date: Mon, 30 Apr 2012 18:56:49 +0100

> Stephane Fillod's big patch addresses multiple issues, so this patchset
> splits it into a separate patch for each issue.
> 
> Thanks to Stephane for finding and fixing these bugs.
> 
> Steve Glendinning (7):
>   smsc75xx: mark link down on startup and let PHY interrupt deal with
>     carrier changes
>   smsc75xx: fix mdio reads and writes
>   smsc75xx: add more information to register io failure warnings
>   smsc75xx: fix phy init reset loop
>   smsc75xx: fix phy interrupt acknowledge
>   smsc75xx: declare smsc75xx's MII as GMII capable
>   smsc75xx: enable mac to detect speed/duplex from phy

All applied, thanks Steve.

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

end of thread, other threads:[~2012-05-01  1:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-30 17:56 [PATCH 0/7] smsc75xx fixes Steve Glendinning
2012-04-30 17:56 ` [PATCH 1/7] smsc75xx: mark link down on startup and let PHY interrupt deal with carrier changes Steve Glendinning
2012-04-30 17:56 ` [PATCH 2/7] smsc75xx: fix mdio reads and writes Steve Glendinning
2012-04-30 17:56 ` [PATCH 3/7] smsc75xx: add more information to register io failure warnings Steve Glendinning
2012-04-30 17:56 ` [PATCH 4/7] smsc75xx: fix phy init reset loop Steve Glendinning
2012-04-30 17:56 ` [PATCH 5/7] smsc75xx: fix phy interrupt acknowledge Steve Glendinning
2012-04-30 17:56 ` [PATCH 6/7] smsc75xx: declare smsc75xx's MII as GMII capable Steve Glendinning
2012-04-30 17:56 ` [PATCH 7/7] smsc75xx: enable mac to detect speed/duplex from phy Steve Glendinning
2012-05-01  1:55 ` [PATCH 0/7] smsc75xx 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).