* [PATCH V4] PCI: vmd: Fix secondary bus reset for Intel bridges
@ 2022-12-06 0:16 francisco.munoz.ruiz
2022-12-06 10:47 ` Lorenzo Pieralisi
0 siblings, 1 reply; 2+ messages in thread
From: francisco.munoz.ruiz @ 2022-12-06 0:16 UTC (permalink / raw)
To: alex.williamson, myron.stowe, lorenzo.pieralisi
Cc: helgaas, jonathan.derrick, linux-pci, Francisco Munoz, Nirmal Patel
From: Francisco Munoz <francisco.munoz.ruiz@linux.intel.com>
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.
Fixes: 6aab5622296b ("PCI: vmd: Clean up domain before enumeration")
Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@linux.intel.com>
Reviewed-by: Nirmal Patel <nirmal.patel@linux.intel.com>
Reviewed-by: Jonathan Derrick <jonathan.derrick@linux.dev>
---
V4:
- Changed WARN_ON() for pci_warn()
- Introduced an explanation in code
- Update commit message
V3:
- Add WARN_ON()
- Include Jonathan as reviewer
- Update commit message
V2:
- Update commit message
drivers/pci/controller/vmd.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index e06e9f4fc50f..6d5373173011 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -719,6 +719,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
resource_size_t offset[2] = {0};
resource_size_t membar2_offset = 0x2000;
struct pci_bus *child;
+ struct pci_dev *dev;
int ret;
/*
@@ -859,8 +860,25 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
pci_scan_child_bus(vmd->bus);
vmd_domain_reset(vmd);
- list_for_each_entry(child, &vmd->bus->children, node)
- pci_reset_bus(child->self);
+
+ /* When Intel VMD is enabled, the OS does not discover the Root Ports
+ * owned by Intel VMD within the MMCFG space. pci_reset_bus() applies
+ * a reset to the parent of the PCI device supplied as argument. This
+ * is why we pass a child device, so the reset can be triggered at
+ * the Intel bridge level and propagated to all the children in the
+ * hierarchy.
+ */
+ list_for_each_entry(child, &vmd->bus->children, node) {
+ if (!list_empty(&child->devices)) {
+ dev = list_first_entry(&child->devices,
+ struct pci_dev, bus_list);
+ if (pci_reset_bus(dev))
+ pci_warn(dev, "can't reset device: %d\n", ret);
+
+ break;
+ }
+ }
+
pci_assign_unassigned_bus_resources(vmd->bus);
/*
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V4] PCI: vmd: Fix secondary bus reset for Intel bridges
2022-12-06 0:16 [PATCH V4] PCI: vmd: Fix secondary bus reset for Intel bridges francisco.munoz.ruiz
@ 2022-12-06 10:47 ` Lorenzo Pieralisi
0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Pieralisi @ 2022-12-06 10:47 UTC (permalink / raw)
To: francisco.munoz.ruiz, myron.stowe, alex.williamson, Lorenzo Pieralisi
Cc: Nirmal Patel, jonathan.derrick, helgaas, linux-pci
On Mon, 5 Dec 2022 17:16:37 -0700, francisco.munoz.ruiz@linux.intel.com wrote:
> From: Francisco Munoz <francisco.munoz.ruiz@linux.intel.com>
>
> 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.
>
> [...]
Applied to pci/vmd, thanks!
[1/1] PCI: vmd: Fix secondary bus reset for Intel bridges
https://git.kernel.org/lpieralisi/pci/c/0a584655ef89
Thanks,
Lorenzo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-06 10:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 0:16 [PATCH V4] PCI: vmd: Fix secondary bus reset for Intel bridges francisco.munoz.ruiz
2022-12-06 10:47 ` Lorenzo Pieralisi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.