diff mbox series

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

Message ID 20210204113121.29786-3-john.efstathiades@pebblebay.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series LAN7800 USB network interface driver NAPI support | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 3 maintainers not CCed: woojung.huh@microchip.com kuba@kernel.org linux-usb@vger.kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 6 this patch: 6
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 6 this patch: 6
netdev/header_inline success Link
netdev/stable success Stable not CCed

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);