thunderbolt: Scan only valid NULL adapter ports in hotplug
authorMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 11 Oct 2017 14:19:54 +0000 (17:19 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 18 Apr 2019 08:18:53 +0000 (11:18 +0300)
The only way to expand Thunderbolt topology is through the NULL adapter
ports (typically ports 1, 2, 3 and 4). There is no point handling
Thunderbolt hotplug events on any other port.

Add a helper function (tb_port_is_null()) that can be used to determine
if the port is NULL port, and use it in software connection manager code
when hotplug event is handled.

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

index cfc451c938fd8d2a4fc792cf62930b720cfac0bf..fb01396a62a9d8fda1d3a9ae3736438662e51939 100644 (file)
@@ -356,10 +356,12 @@ static void tb_handle_hotplug(struct work_struct *work)
                tb_port_info(port,
                             "got plug event for connected port, ignoring\n");
        } else {
-               tb_port_info(port, "hotplug: scanning\n");
-               tb_scan_port(port);
-               if (!port->remote)
-                       tb_port_info(port, "hotplug: no switch found\n");
+               if (tb_port_is_null(port)) {
+                       tb_port_info(port, "hotplug: scanning\n");
+                       tb_scan_port(port);
+                       if (!port->remote)
+                               tb_port_info(port, "hotplug: no switch found\n");
+               }
        }
 
 put_sw:
index 5b5ba8919086591458ecaf54dabcb072c9dcd591..260360ec59a9d3f483fc2065e0acd887ef7934e3 100644 (file)
@@ -350,6 +350,11 @@ static inline bool tb_port_has_remote(const struct tb_port *port)
        return true;
 }
 
+static inline bool tb_port_is_null(const struct tb_port *port)
+{
+       return port && port->port && port->config.type == TB_TYPE_PORT;
+}
+
 static inline bool tb_port_is_pcie_down(const struct tb_port *port)
 {
        return port && port->config.type == TB_TYPE_PCIE_DOWN;