diff mbox series

[net-next,2/9] lan78xx: disable U1/U2 power state transitions

Message ID 20210204113121.29786-3-john.efstathiades@pebblebay.com
State New
Headers show
Series [net-next,1/9] lan78xx: add NAPI interface support | expand

Commit Message

John Efstathiades Feb. 4, 2021, 11:31 a.m. UTC
Use macro DEFAULT_U1_U2_INIT_ENABLE to configure default behaviour
of U1/U2 link power state transitions (on/off).

Disable U1/U2 link power state transitions by default to reduce
URB processing latency and maximise throughput.

Signed-off-by: John Efstathiades <john.efstathiades@pebblebay.com>
---
 drivers/net/usb/lan78xx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

John Efstathiades Feb. 10, 2021, 3:27 p.m. UTC | #1
> -----Original Message-----

> From: Andrew Lunn <andrew@lunn.ch>

> Sent: 04 February 2021 13:40


> Could you expand this comment a bit. Most people here are network

> people, and have not idea what U1/U2 is. I assume it is some USB term?


Yes, they refer to USB 3.0 power states.

> Some performance numbers would be nice here. And maybe current draw?


I'll do this in the next revision of the patch.

John
diff mbox series

Patch

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 1c872edc816a..38664b48329a 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -56,6 +56,8 @@ 
 #define TX_ALIGNMENT			(4)
 #define RXW_PADDING			2
 
+#define DEFAULT_U1_U2_INIT_ENABLE	false
+
 #define MIN_IPV4_DGRAM			68
 
 #define LAN78XX_USB_VENDOR_ID		(0x0424)
@@ -1351,7 +1353,8 @@  static int lan78xx_link_reset(struct lan78xx_net *dev)
 
 		phy_ethtool_ksettings_get(phydev, &ecmd);
 
-		if (dev->udev->speed == USB_SPEED_SUPER) {
+		if (DEFAULT_U1_U2_INIT_ENABLE &&
+		    dev->udev->speed == USB_SPEED_SUPER) {
 			if (ecmd.base.speed == 1000) {
 				/* disable U2 */
 				ret = lan78xx_read_reg(dev, USB_CFG1, &buf);
@@ -1368,6 +1371,11 @@  static int lan78xx_link_reset(struct lan78xx_net *dev)
 				buf |= USB_CFG1_DEV_U1_INIT_EN_;
 				ret = lan78xx_write_reg(dev, USB_CFG1, buf);
 			}
+		} else {
+			ret = lan78xx_read_reg(dev, USB_CFG1, &buf);
+			buf &= ~USB_CFG1_DEV_U2_INIT_EN_;
+			buf &= ~USB_CFG1_DEV_U1_INIT_EN_;
+			ret = lan78xx_write_reg(dev, USB_CFG1, buf);
 		}
 
 		ladv = phy_read(phydev, MII_ADVERTISE);