]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
thunderbolt: Do not unnecessarily call ICM get route
authorMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 28 Aug 2018 06:43:00 +0000 (08:43 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 5 Sep 2018 13:15:48 +0000 (15:15 +0200)
BugLink: https://bugs.launchpad.net/bugs/1789358
This command is not really fast and can make resume time slower. We only
need to get route again if the link was changed and during initial
device connected message.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit fdd92e89a492142a113f270dcd7e490805922b71)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Hui Wang <Wang <hui.wang@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/thunderbolt/icm.c

index 500911f1649852d91641e607be198228b9e185a2..ad4eeaa59b163853dcf47bb9e220866855e187a3 100644 (file)
@@ -534,20 +534,13 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr)
                return;
        }
 
-       ret = icm->get_route(tb, link, depth, &route);
-       if (ret) {
-               tb_err(tb, "failed to find route string for switch at %u.%u\n",
-                      link, depth);
-               return;
-       }
-
        sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid);
        if (sw) {
                u8 phy_port, sw_phy_port;
 
                parent_sw = tb_to_switch(sw->dev.parent);
-               sw_phy_port = phy_port_from_route(tb_route(sw), sw->depth);
-               phy_port = phy_port_from_route(route, depth);
+               sw_phy_port = tb_phy_port_from_link(sw->link);
+               phy_port = tb_phy_port_from_link(link);
 
                /*
                 * On resume ICM will send us connected events for the
@@ -559,6 +552,22 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr)
                 */
                if (sw->depth == depth && sw_phy_port == phy_port &&
                    !!sw->authorized == authorized) {
+                       /*
+                        * It was enumerated through another link so update
+                        * route string accordingly.
+                        */
+                       if (sw->link != link) {
+                               ret = icm->get_route(tb, link, depth, &route);
+                               if (ret) {
+                                       tb_err(tb, "failed to update route string for switch at %u.%u\n",
+                                              link, depth);
+                                       tb_switch_put(sw);
+                                       return;
+                               }
+                       } else {
+                               route = tb_route(sw);
+                       }
+
                        update_switch(parent_sw, sw, route, pkg->connection_id,
                                      pkg->connection_key, link, depth, boot);
                        tb_switch_put(sw);
@@ -607,6 +616,14 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr)
                return;
        }
 
+       ret = icm->get_route(tb, link, depth, &route);
+       if (ret) {
+               tb_err(tb, "failed to find route string for switch at %u.%u\n",
+                      link, depth);
+               tb_switch_put(parent_sw);
+               return;
+       }
+
        add_switch(parent_sw, route, &pkg->ep_uuid, pkg->connection_id,
                   pkg->connection_key, link, depth, security_level,
                   authorized, boot);