Skip to content

Commit 0a58465

Browse files
Francisco MunozLorenzo Pieralisi
authored andcommitted
PCI: vmd: Fix secondary bus reset for Intel bridges
The reset was never applied in the current implementation because Intel Bridges owned by VMD are parentless. Internally, pci_reset_bus() applies a reset to the parent of the PCI device supplied as argument, but in this case it failed because there wasn't a parent. In more detail, this change allows the VMD driver to enumerate NVMe devices in pass-through configurations when guest reboots are performed. There was an attempted to fix this, but later we discovered that the code inside pci_reset_bus() wasn’t triggering secondary bus resets. Therefore, we updated the parameters passed to it, and now NVMe SSDs attached to VMD bridges are properly enumerated in VT-d pass-through scenarios. Link: https://lore.kernel.org/r/[email protected] Fixes: 6aab562 ("PCI: vmd: Clean up domain before enumeration") Signed-off-by: Francisco Munoz <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Nirmal Patel <[email protected]> Reviewed-by: Jonathan Derrick <[email protected]>
1 parent d899aa6 commit 0a58465

File tree

1 file changed

+20
-2
lines changed
  • drivers/pci/controller

1 file changed

+20
-2
lines changed

drivers/pci/controller/vmd.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
719719
resource_size_t offset[2] = {0};
720720
resource_size_t membar2_offset = 0x2000;
721721
struct pci_bus *child;
722+
struct pci_dev *dev;
722723
int ret;
723724

724725
/*
@@ -859,8 +860,25 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
859860

860861
pci_scan_child_bus(vmd->bus);
861862
vmd_domain_reset(vmd);
862-
list_for_each_entry(child, &vmd->bus->children, node)
863-
pci_reset_bus(child->self);
863+
864+
/* When Intel VMD is enabled, the OS does not discover the Root Ports
865+
* owned by Intel VMD within the MMCFG space. pci_reset_bus() applies
866+
* a reset to the parent of the PCI device supplied as argument. This
867+
* is why we pass a child device, so the reset can be triggered at
868+
* the Intel bridge level and propagated to all the children in the
869+
* hierarchy.
870+
*/
871+
list_for_each_entry(child, &vmd->bus->children, node) {
872+
if (!list_empty(&child->devices)) {
873+
dev = list_first_entry(&child->devices,
874+
struct pci_dev, bus_list);
875+
if (pci_reset_bus(dev))
876+
pci_warn(dev, "can't reset device: %d\n", ret);
877+
878+
break;
879+
}
880+
}
881+
864882
pci_assign_unassigned_bus_resources(vmd->bus);
865883

866884
/*

0 commit comments

Comments
 (0)