thunderbolt: Enable/disable sideband depending on USB4 port offline mode
authorMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 26 May 2023 11:55:20 +0000 (14:55 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 12 Jun 2023 05:38:01 +0000 (08:38 +0300)
When USB4 port is in offline mode (this mean there is no device
attached) we want to keep the sideband up to make it possible to
communicate with the retimers. In the same way there is no need to
enable sideband transactions when the USB4 port is not offline as they
are already up.

For this reason make the enabling/disabling depend on the USB4 port
offline status.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/retimer.c
drivers/thunderbolt/tb.h

index a273fb02a02c4bbf5d110bc3ebf441edfafc1803..47becb363adacb50c5813946d6355d8a3dd6d14a 100644 (file)
@@ -206,6 +206,15 @@ static void tb_retimer_set_inbound_sbtx(struct tb_port *port)
 {
        int i;
 
+       /*
+        * When USB4 port is online sideband communications are
+        * already up.
+        */
+       if (!usb4_port_device_is_offline(port->usb4))
+               return;
+
+       tb_port_dbg(port, "enabling sideband transactions\n");
+
        for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++)
                usb4_port_retimer_set_inbound_sbtx(port, i);
 }
@@ -214,6 +223,16 @@ static void tb_retimer_unset_inbound_sbtx(struct tb_port *port)
 {
        int i;
 
+       /*
+        * When USB4 port is offline we need to keep the sideband
+        * communications up to make it possible to communicate with
+        * the connected retimers.
+        */
+       if (usb4_port_device_is_offline(port->usb4))
+               return;
+
+       tb_port_dbg(port, "disabling sideband transactions\n");
+
        for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--)
                usb4_port_retimer_unset_inbound_sbtx(port, i);
 }
index 2bda2816ff47474571c23a523e5424fd77867572..58df106aaa5edbfc0838c206c8bf8526e9f8bee8 100644 (file)
@@ -1301,6 +1301,11 @@ struct usb4_port *usb4_port_device_add(struct tb_port *port);
 void usb4_port_device_remove(struct usb4_port *usb4);
 int usb4_port_device_resume(struct usb4_port *usb4);
 
+static inline bool usb4_port_device_is_offline(const struct usb4_port *usb4)
+{
+       return usb4->offline;
+}
+
 void tb_check_quirks(struct tb_switch *sw);
 
 #ifdef CONFIG_ACPI