@@ -14,6 +14,7 @@
#include <linux/srcu.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
+#include <linux/delay.h>
#include <asm/irqdomain.h>
#include <asm/device.h>
@@ -424,6 +425,36 @@ static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,
.write = vmd_pci_write,
};
+static void vmd_domain_reset_sbr(struct vmd_dev *vmd)
+{
+ char __iomem *base;
+ int rp;
+ u16 ctl;
+
+ /*
+ * Subdevice config space is mapped linearly using 4k config space
+ * increments. Use increments of 0x8000 to locate root port devices.
+ */
+ for (rp = 0; rp < 4; rp++) {
+ base = vmd->cfgbar + rp * 0x8000;
+ if (readl(base + PCI_COMMAND) == 0xFFFFFFFF)
+ continue;
+
+ /* pci_reset_secondary_bus() */
+ ctl = readw(base + PCI_BRIDGE_CONTROL);
+ ctl |= PCI_BRIDGE_CTL_BUS_RESET;
+ writew(ctl, base + PCI_BRIDGE_CONTROL);
+ readw(base + PCI_BRIDGE_CONTROL);
+ msleep(2);
+
+ ctl &= ~PCI_BRIDGE_CTL_BUS_RESET;
+ writew(ctl, base + PCI_BRIDGE_CONTROL);
+ readw(base + PCI_BRIDGE_CONTROL);
+ }
+
+ ssleep(1);
+}
+
static void vmd_attach_resources(struct vmd_dev *vmd)
{
vmd->dev->resource[VMD_MEMBAR1].child = &vmd->resources[1];
@@ -707,6 +738,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
if (vmd->irq_domain)
dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain);
+ vmd_domain_reset_sbr(vmd);
pci_scan_child_bus(vmd->bus);
pci_assign_unassigned_bus_resources(vmd->bus);
The VMD subdevice domain resource requirements may have changed in-between module loads. Generic PCI resource assignment code may rely on existing resource configuration rather than the VMD preference of re-examining the domain. Add a Secondary Bus Reset to the VMD subdevice domain during driver attachment to clear the PCI config space of the subdevices. Signed-off-by: Jon Derrick <jonathan.derrick@intel.com> --- drivers/pci/controller/vmd.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)