Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thunderbolt: Add device links only when software connection manager is used

We only need to set up the device links when software connection manager
path is used. The firmware connection manager does not need them and if
they are present they may even cause problems.

Reviewed-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

+67 -67
-67
drivers/thunderbolt/nhi.c
··· 17 17 #include <linux/module.h> 18 18 #include <linux/delay.h> 19 19 #include <linux/property.h> 20 - #include <linux/platform_data/x86/apple.h> 21 20 22 21 #include "nhi.h" 23 22 #include "nhi_regs.h" ··· 1126 1127 return true; 1127 1128 } 1128 1129 1129 - /* 1130 - * During suspend the Thunderbolt controller is reset and all PCIe 1131 - * tunnels are lost. The NHI driver will try to reestablish all tunnels 1132 - * during resume. This adds device links between the tunneled PCIe 1133 - * downstream ports and the NHI so that the device core will make sure 1134 - * NHI is resumed first before the rest. 1135 - */ 1136 - static void tb_apple_add_links(struct tb_nhi *nhi) 1137 - { 1138 - struct pci_dev *upstream, *pdev; 1139 - 1140 - if (!x86_apple_machine) 1141 - return; 1142 - 1143 - switch (nhi->pdev->device) { 1144 - case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE: 1145 - case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C: 1146 - case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI: 1147 - case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI: 1148 - break; 1149 - default: 1150 - return; 1151 - } 1152 - 1153 - upstream = pci_upstream_bridge(nhi->pdev); 1154 - while (upstream) { 1155 - if (!pci_is_pcie(upstream)) 1156 - return; 1157 - if (pci_pcie_type(upstream) == PCI_EXP_TYPE_UPSTREAM) 1158 - break; 1159 - upstream = pci_upstream_bridge(upstream); 1160 - } 1161 - 1162 - if (!upstream) 1163 - return; 1164 - 1165 - /* 1166 - * For each hotplug downstream port, create add device link 1167 - * back to NHI so that PCIe tunnels can be re-established after 1168 - * sleep. 1169 - */ 1170 - for_each_pci_bridge(pdev, upstream->subordinate) { 1171 - const struct device_link *link; 1172 - 1173 - if (!pci_is_pcie(pdev)) 1174 - continue; 1175 - if (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM || 1176 - !pdev->is_hotplug_bridge) 1177 - continue; 1178 - 1179 - link = device_link_add(&pdev->dev, &nhi->pdev->dev, 1180 - DL_FLAG_AUTOREMOVE_SUPPLIER | 1181 - DL_FLAG_PM_RUNTIME); 1182 - if (link) { 1183 - dev_dbg(&nhi->pdev->dev, "created link from %s\n", 1184 - dev_name(&pdev->dev)); 1185 - } else { 1186 - dev_warn(&nhi->pdev->dev, "device link creation from %s failed\n", 1187 - dev_name(&pdev->dev)); 1188 - } 1189 - } 1190 - } 1191 - 1192 1130 static struct tb *nhi_select_cm(struct tb_nhi *nhi) 1193 1131 { 1194 1132 struct tb *tb; ··· 1213 1277 if (res) 1214 1278 return res; 1215 1279 } 1216 - 1217 - tb_apple_add_links(nhi); 1218 - tb_acpi_add_links(nhi); 1219 1280 1220 1281 tb = nhi_select_cm(nhi); 1221 1282 if (!tb) {
+67
drivers/thunderbolt/tb.c
··· 10 10 #include <linux/errno.h> 11 11 #include <linux/delay.h> 12 12 #include <linux/pm_runtime.h> 13 + #include <linux/platform_data/x86/apple.h> 13 14 14 15 #include "tb.h" 15 16 #include "tb_regs.h" ··· 1572 1571 .disconnect_xdomain_paths = tb_disconnect_xdomain_paths, 1573 1572 }; 1574 1573 1574 + /* 1575 + * During suspend the Thunderbolt controller is reset and all PCIe 1576 + * tunnels are lost. The NHI driver will try to reestablish all tunnels 1577 + * during resume. This adds device links between the tunneled PCIe 1578 + * downstream ports and the NHI so that the device core will make sure 1579 + * NHI is resumed first before the rest. 1580 + */ 1581 + static void tb_apple_add_links(struct tb_nhi *nhi) 1582 + { 1583 + struct pci_dev *upstream, *pdev; 1584 + 1585 + if (!x86_apple_machine) 1586 + return; 1587 + 1588 + switch (nhi->pdev->device) { 1589 + case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE: 1590 + case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C: 1591 + case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI: 1592 + case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI: 1593 + break; 1594 + default: 1595 + return; 1596 + } 1597 + 1598 + upstream = pci_upstream_bridge(nhi->pdev); 1599 + while (upstream) { 1600 + if (!pci_is_pcie(upstream)) 1601 + return; 1602 + if (pci_pcie_type(upstream) == PCI_EXP_TYPE_UPSTREAM) 1603 + break; 1604 + upstream = pci_upstream_bridge(upstream); 1605 + } 1606 + 1607 + if (!upstream) 1608 + return; 1609 + 1610 + /* 1611 + * For each hotplug downstream port, create add device link 1612 + * back to NHI so that PCIe tunnels can be re-established after 1613 + * sleep. 1614 + */ 1615 + for_each_pci_bridge(pdev, upstream->subordinate) { 1616 + const struct device_link *link; 1617 + 1618 + if (!pci_is_pcie(pdev)) 1619 + continue; 1620 + if (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM || 1621 + !pdev->is_hotplug_bridge) 1622 + continue; 1623 + 1624 + link = device_link_add(&pdev->dev, &nhi->pdev->dev, 1625 + DL_FLAG_AUTOREMOVE_SUPPLIER | 1626 + DL_FLAG_PM_RUNTIME); 1627 + if (link) { 1628 + dev_dbg(&nhi->pdev->dev, "created link from %s\n", 1629 + dev_name(&pdev->dev)); 1630 + } else { 1631 + dev_warn(&nhi->pdev->dev, "device link creation from %s failed\n", 1632 + dev_name(&pdev->dev)); 1633 + } 1634 + } 1635 + } 1636 + 1575 1637 struct tb *tb_probe(struct tb_nhi *nhi) 1576 1638 { 1577 1639 struct tb_cm *tcm; ··· 1657 1593 INIT_DELAYED_WORK(&tcm->remove_work, tb_remove_work); 1658 1594 1659 1595 tb_dbg(tb, "using software connection manager\n"); 1596 + 1597 + tb_apple_add_links(nhi); 1598 + tb_acpi_add_links(nhi); 1660 1599 1661 1600 return tb; 1662 1601 }