Skip to content

Commit

Permalink
thunderbolt: Serialize PCIe tunnel creation with PCI rescan
Browse files Browse the repository at this point in the history
We need to make sure a new PCIe tunnel is not created in a middle of
previous PCI rescan because otherwise the rescan code might find too
much and fail to reconfigure devices properly. This is important when
native PCIe hotplug is used. In BIOS assisted hotplug there should be no
such issue.

Fixes: f67cf49 ("thunderbolt: Add support for Internal Connection Manager (ICM)")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
  • Loading branch information
westeri committed Mar 9, 2018
1 parent f2a659f commit a03e828
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/thunderbolt/switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,13 @@ static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val)
if (sw->authorized)
goto unlock;

/*
* Make sure there is no PCIe rescan ongoing when a new PCIe
* tunnel is created. Otherwise the PCIe rescan code might find
* the new tunnel too early.
*/
pci_lock_rescan_remove();

switch (val) {
/* Approve switch */
case 1:
Expand All @@ -735,6 +742,8 @@ static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val)
break;
}

pci_unlock_rescan_remove();

if (!ret) {
sw->authorized = val;
/* Notify status change to the userspace */
Expand Down

0 comments on commit a03e828

Please sign in to comment.