From: Jon Derrick <jonathan.derrick@intel.com>
To: <linux-pci@vger.kernel.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Bjorn Helgaas <helgaas@kernel.org>,
Andrzej Jakowski <andrzej.jakowski@linux.intel.com>,
Dave Fugate <david.fugate@intel.com>,
Jon Derrick <jonathan.derrick@intel.com>
Subject: [PATCH 1/2] PCI: vmd: Reset the VMD subdevice domain on probe
Date: Sun, 27 Sep 2020 21:05:56 -0400 [thread overview]
Message-ID: <20200928010557.5324-2-jonathan.derrick@intel.com> (raw)
In-Reply-To: <20200928010557.5324-1-jonathan.derrick@intel.com>
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 | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 50b3520d261d..676acff3622f 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -445,6 +445,36 @@ static struct pci_ops vmd_ops = {
.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 ports 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];
@@ -784,6 +814,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
if (!vmd->cfgbar)
return -ENOMEM;
+ vmd_domain_reset_sbr(dev);
pci_set_master(dev);
if (dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)) &&
dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)))
--
2.18.1
next prev parent reply other threads:[~2020-09-28 2:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 1:05 [PATCH 0/2] VMD subdevice secondary bus resets Jon Derrick
2020-09-28 1:05 ` Jon Derrick [this message]
2020-09-28 1:05 ` [PATCH 2/2] PCI: Add a reset quirk for VMD Jon Derrick
2020-11-19 11:37 ` [PATCH 0/2] VMD subdevice secondary bus resets Lorenzo Pieralisi
2020-11-19 18:45 ` 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=20200928010557.5324-2-jonathan.derrick@intel.com \
--to=jonathan.derrick@intel.com \
--cc=andrzej.jakowski@linux.intel.com \
--cc=david.fugate@intel.com \
--cc=helgaas@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.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).