From: Jon Derrick <jonathan.derrick@intel.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: <linux-pci@vger.kernel.org>, Bjorn Helgaas <helgaas@kernel.org>,
Nirmal Patel <nirmal.patel@intel.com>,
Sushma Kalakota <sushmax.kalakota@intel.com>,
Jon Derrick <jonathan.derrick@intel.com>
Subject: [PATCH 2/5] PCI: Add a reset quirk for VMD
Date: Fri, 20 Nov 2020 15:51:41 -0700 [thread overview]
Message-ID: <20201120225144.15138-3-jonathan.derrick@intel.com> (raw)
In-Reply-To: <20201120225144.15138-1-jonathan.derrick@intel.com>
VMD domains should be reset in-between special attachment such as VFIO
users. VMD does not offer a reset, however the subdevice domain itself
can be reset starting at the Root Bus. Add a Secondary Bus Reset on each
of the individual root port devices immediately downstream of the VMD
root bus.
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
drivers/pci/quirks.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index f70692a..ee58b51 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3744,6 +3744,49 @@ static int reset_ivb_igd(struct pci_dev *dev, int probe)
return 0;
}
+/* Issues SBR to VMD domain to clear PCI configuration */
+static int reset_vmd_sbr(struct pci_dev *dev, int probe)
+{
+ char __iomem *cfgbar, *base;
+ int rp;
+ u16 ctl;
+
+ if (probe)
+ return 0;
+
+ if (dev->dev.driver)
+ return 0;
+
+ cfgbar = pci_iomap(dev, 0, 0);
+ if (!cfgbar)
+ return -ENOMEM;
+
+ /*
+ * 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 = 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);
+ pci_iounmap(dev, cfgbar);
+ return 0;
+}
+
/* Device-specific reset method for Chelsio T4-based adapters */
static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe)
{
@@ -3919,6 +3962,11 @@ static int delay_250ms_after_flr(struct pci_dev *dev, int probe)
reset_ivb_igd },
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IVB_M2_VGA,
reset_ivb_igd },
+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_201D, reset_vmd_sbr },
+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_28C0, reset_vmd_sbr },
+ { PCI_VENDOR_ID_INTEL, 0x467f, reset_vmd_sbr },
+ { PCI_VENDOR_ID_INTEL, 0x4c3d, reset_vmd_sbr },
+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_9A0B, reset_vmd_sbr },
{ PCI_VENDOR_ID_SAMSUNG, 0xa804, nvme_disable_and_flr },
{ PCI_VENDOR_ID_INTEL, 0x0953, delay_250ms_after_flr },
{ PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
--
1.8.3.1
next prev parent reply other threads:[~2020-11-20 22:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 22:51 [PATCH 0/5] Legacy direct-assign mode Jon Derrick
2020-11-20 22:51 ` [PATCH 1/5] PCI: vmd: Reset the VMD subdevice domain on probe Jon Derrick
2020-11-20 22:51 ` Jon Derrick [this message]
2020-11-24 21:40 ` [PATCH 2/5] PCI: Add a reset quirk for VMD Bjorn Helgaas
2020-11-25 17:22 ` Derrick, Jonathan
2020-11-25 17:34 ` Alex Williamson
2020-11-20 22:51 ` [PATCH 3/5] PCI: vmd: Add offset translation helper Jon Derrick
2020-11-20 22:51 ` [PATCH 4/5] PCI: vmd: Pass features to vmd_get_phys_offsets() Jon Derrick
2020-11-20 22:51 ` [PATCH 5/5] PCI: vmd: Add legacy guest passthrough mode Jon Derrick
2021-03-22 12:28 ` [PATCH 0/5] Legacy direct-assign mode Lorenzo Pieralisi
2021-03-22 15:25 ` Derrick, Jonathan
2021-03-22 19:48 ` Christoph Hellwig
2021-03-22 22:55 ` Derrick, Jonathan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120225144.15138-3-jonathan.derrick@intel.com \
--to=jonathan.derrick@intel.com \
--cc=helgaas@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=nirmal.patel@intel.com \
--cc=sushmax.kalakota@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).