Skip to contentSkip to conversation

usb: host: xhci-tegra: Tegra186/Tegra194 LPM

PATCH In review JC Kuo 3 participants 6 messages Feb 24, 2020 – Feb 27, 2020 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

JC Kuo

author
#0 lore raw

PATCH 1/1 usb: host: xhci-tegra: Tegra186/Tegra194 LPM

Tegra186 and Tegra194 xHC supports USB 3.0 LPM. This commit enables XHCI_LPM_SUPPORT quirk for Tegra186 and Tegra194.

---
 drivers/usb/host/xhci-tegra.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/usb/host/xhci-tegra.c +7 -0
index 8163aefc6c6b..a6e36b3c968f 100644
@@ -203,6 +203,7 @@ struct tegra_xusb_soc {
 
 	bool scale_ss_clock;
 	bool has_ipfs;
+	bool lpm_support;
 };
 
 struct tegra_xusb_context {
@@ -1779,6 +1780,7 @@ static const struct tegra_xusb_soc tegra186_soc = {
 		.data_out = 0xec,
 		.owner = 0xf0,
 	},
+	.lpm_support = true,
 };
 
 static const char * const tegra194_supply_names[] = {
@@ -1808,6 +1810,7 @@ static const struct tegra_xusb_soc tegra194_soc = {
 		.data_out = 0x70,
 		.owner = 0x74,
 	},
+	.lpm_support = true,
 };
 MODULE_FIRMWARE("nvidia/tegra194/xusb.bin");
 
@@ -1832,7 +1835,11 @@ static struct platform_driver tegra_xusb_driver = {
 
 static void tegra_xhci_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
+	struct tegra_xusb *tegra = dev_get_drvdata(dev);
+
 	xhci->quirks |= XHCI_PLAT;
+	if (tegra && tegra->soc->lpm_support)
+		xhci->quirks |= XHCI_LPM_SUPPORT;
 }
 
 static int tegra_xhci_setup(struct usb_hcd *hcd)
Signature · 1 line
2.17.1

A message that is not in the archive (sent off-list or not yet received): 20200224062145.25785-1-jckuo-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 4 lines · JC Kuo

Tegra186 and Tegra194 xHC supports USB 3.0 LPM. This commit enables XHCI_LPM_SUPPORT quirk for Tegra186 and Tegra194.

Thanks, added to queue

-Mathias

#3 lore raw
In reply to a message not in the archive
Quoted 7 lines · JC Kuo

Tegra186 and Tegra194 xHC supports USB 3.0 LPM. This commit enables XHCI_LPM_SUPPORT quirk for Tegra186 and Tegra194.

---
 drivers/usb/host/xhci-tegra.c | 7 +++++++
 1 file changed, 7 insertions(+)

I see that Mathias has already queued this up, but for the record:

JC, is there some way that we can test this? I see that there are some sysfs files that can control LPM enablement on a per-device basis, but is there some way to check that this works as expected? Or do we just assume everything is fine as long as all the devices continue to operate properly? Perhaps there are some state transition counters or something that would indicate that devices are properly transitioning?

Thierry

author
#4 lore raw

Hi Thierry,
Yes, it can be verified with a LPM capable device. For example, a VIA USB 3.0 hub is connected to Jetson-Xavier. "lsusb -v" output [1] shows the device supports LPM and the host has enabled U1/U2 states for the device. If host LPM is disabled, there will be no "U1 Enabled" and "U2 Enabled" strings in "Device Status" section.

To check LPM operation, disconnect all USB 3.0 devices from the hub and disable runtime PM for the super-speed portion of the hub, so that it won't be auto-suspended.

root@tegra-ubuntu:~# echo on > /sys/bus/usb/devices/2-4/power/control

Since there is no data transaction for the hub, link will enter U2 soon. This can be checked by reading XHCI.PORTSC register. In below, PLS (Port Link State) field is U2.

root@tegra-ubuntu:~# devmem 0x3610450
0x00001243

Thanks,
JC

[1] lsusb -v -d 2109:0820
Bus 002 Device 002: ID 2109:0820 VIA Labs, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.10

  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         3
  bMaxPacketSize0         9
  idVendor           0x2109 VIA Labs, Inc.
  idProduct          0x0820
  bcdDevice            4.e3
  iManufacturer           1 VIA Labs, Inc.
  iProduct                2 USB3.0 Hub
  iSerial                 0
  bNumConfigurations      1

...
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 42
bNumDeviceCaps 3
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000002
Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 4 micro seconds
bU2DevExitLat 231 micro seconds
Container ID Device Capability:

    bLength                20
    bDescriptorType        16
    bDevCapabilityType      4
    bReserved               0
    ContainerID             {5cf3ee30-d507-4925-b001-802d79434c30}

Device Status: 0x000d
Self Powered
U1 Enabled
U2 Enabled

Quoted 22 lines · Thierry Reding
Quoted 7 lines · JC Kuo

Tegra186 and Tegra194 xHC supports USB 3.0 LPM. This commit enables XHCI_LPM_SUPPORT quirk for Tegra186 and Tegra194.

---
 drivers/usb/host/xhci-tegra.c | 7 +++++++
 1 file changed, 7 insertions(+)

I see that Mathias has already queued this up, but for the record:

JC, is there some way that we can test this? I see that there are some sysfs files that can control LPM enablement on a per-device basis, but is there some way to check that this works as expected? Or do we just assume everything is fine as long as all the devices continue to operate properly? Perhaps there are some state transition counters or something that would indicate that devices are properly transitioning?

Thierry

A message that is not in the archive (sent off-list or not yet received): 223f5f09-781a-825d-e75e-3b878acec27d-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org

#6 lore raw
Quoted 10 lines · JC Kuo

Hi Thierry,
Yes, it can be verified with a LPM capable device. For example, a VIA USB 3.0 hub is connected to Jetson-Xavier. "lsusb -v" output [1] shows the device supports LPM and the host has enabled U1/U2 states for the device. If host LPM is disabled, there will be no "U1 Enabled" and "U2 Enabled" strings in "Device Status" section.

To check LPM operation, disconnect all USB 3.0 devices from the hub and disable runtime PM for the super-speed portion of the hub, so that it won't be auto-suspended.

Quoted 7 lines
root@tegra-ubuntu:~# echo on > /sys/bus/usb/devices/2-4/power/control

Since there is no data transaction for the hub, link will enter U2 soon. This can be checked by reading XHCI.PORTSC register. In below, PLS (Port Link State) field is U2.

root@tegra-ubuntu:~# devmem 0x3610450
0x00001243

A more human friendly way to read portsc registers:

# cat /sys/kernel/debug/usb/xhci/0000\:00\:14.0/ports/port02/portsc 
Powered Connected Enabled Link:U0 PortSpeed:3 Change: Wake: 

-Mathias

A message that is not in the archive (sent off-list or not yet received): 6c93af2b-5a4d-a3ad-07f4-f5c72f569752-VuQAYsv1563Yd54FQh9/[email protected]

author
#8 lore raw

Hi Mathias,
Thanks for the tip. It's really helpful.

root@tegra-ubuntu:/d/usb/xhci/3610000.usb/ports/port04# cat portsc
Powered Connected Enabled Link:U2 PortSpeed:4 Change: Wake:

-JC

Quoted 26 lines · Mathias Nyman
Quoted 10 lines · JC Kuo

Hi Thierry,
Yes, it can be verified with a LPM capable device. For example, a VIA USB 3.0 hub is connected to Jetson-Xavier. "lsusb -v" output [1] shows the device supports LPM and the host has enabled U1/U2 states for the device. If host LPM is disabled, there will be no "U1 Enabled" and "U2 Enabled" strings in "Device Status" section.

To check LPM operation, disconnect all USB 3.0 devices from the hub and disable runtime PM for the super-speed portion of the hub, so that it won't be auto-suspended.

Quoted 7 lines
root@tegra-ubuntu:~# echo on > /sys/bus/usb/devices/2-4/power/control

Since there is no data transaction for the hub, link will enter U2 soon. This can be checked by reading XHCI.PORTSC register. In below, PLS (Port Link State) field is U2.

root@tegra-ubuntu:~# devmem 0x3610450
0x00001243

A more human friendly way to read portsc registers:

# cat /sys/kernel/debug/usb/xhci/0000\:00\:14.0/ports/port02/portsc 
Powered Connected Enabled Link:U0 PortSpeed:3 Change: Wake: 

-Mathias