[PATCH 2/4] usb: Add tunneled parameter to usb device structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add 'tunneled' parameter to usb device structure to describe if a device
connection is tunneled over USB4 or connected directly using native
USB2/USB3.

Tunneled devices depend on USB4 NHI host to maintain the tunnel.
Knowledge about tunneled devices is important to ensure correct
suspend and resume order between USB4 hosts and tunneled devices.
i.e. make sure tunnel is up before the USB device using it resumes.

USB hosts such as xHCI have vendor specific ways to detect tunneled
connections. This 'tunneled' parameter can be set by USB3 host driver
during hcd->driver->update_device(hcd, udev) callback

Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
---
 drivers/usb/host/xhci.c | 3 ++-
 include/linux/usb.h     | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a85173098de1..e11251e3e4fc 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4517,7 +4517,8 @@ static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
 	if (hcd->speed >= HCD_USB3 && !udev->parent->parent) {
 		port = xhci->usb3_rhub.ports[udev->portnum - 1];
 
-		if (xhci_port_is_tunneled(xhci, port))
+		udev->tunneled = xhci_port_is_tunneled(xhci, port);
+		if (udev->tunneled)
 			dev_dbg(&udev->dev, "tunneled over USB4 link\n");
 		else
 			dev_dbg(&udev->dev, "native USB 3.x link\n");
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 1913a13833f2..a4c5c09ea2bd 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -605,6 +605,7 @@ struct usb3_lpm_parameters {
  *	WUSB devices are not, until we authorize them from user space.
  *	FIXME -- complete doc
  * @authenticated: Crypto authentication passed
+ * @tunneled: Connected to root port and tunneled over USB4
  * @lpm_capable: device supports LPM
  * @lpm_devinit_allow: Allow USB3 device initiated LPM, exit latency is in range
  * @usb2_hw_lpm_capable: device can perform USB2 hardware LPM
@@ -685,6 +686,7 @@ struct usb_device {
 	unsigned have_langid:1;
 	unsigned authorized:1;
 	unsigned authenticated:1;
+	unsigned tunneled:1;
 	unsigned lpm_capable:1;
 	unsigned lpm_devinit_allow:1;
 	unsigned usb2_hw_lpm_capable:1;
-- 
2.25.1





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux