From: Jon Derrick <jonathan.derrick@intel.com>
To: Bjorn Helgaas <helgaas@kernel.org>,
Keith Busch <keith.busch@intel.com>, <linux-pci@vger.kernel.org>
Cc: Joerg Roedel <jroedel@suse.de>,
Myron Stowe <myron.stowe@redhat.com>,
Dave Fugate <david.fugate@intel.com>,
Scott Bauer <scott.bauer@intel.com>,
Christoph Hellwig <hch@lst.de>,
Jon Derrick <jonathan.derrick@intel.com>
Subject: [PATCH 3/5] PCI/VMD: Add offset to bus numbers if necessary
Date: Fri, 18 May 2018 13:28:00 -0600 [thread overview]
Message-ID: <20180518192802.20371-4-jonathan.derrick@intel.com> (raw)
In-Reply-To: <20180518192802.20371-1-jonathan.derrick@intel.com>
Depending on platform configuration, certain VMD devices may have an
additional configuration option which specifies the range of bus numbers
allowed in a VMD PCIe domain. We determine this requirement by checking
the value of two vendor specific config registers in the VMD endpoint:
VMCAP[0] | VMCONFIG[9:8] | Bus Numbers
----------------------------------------
0 | * | 0-255
1 | 00 | 0-127
1 | 01 | 128-255
1 | 10 | 0-255
This feature is also added as a bit in driver_data, to allow future
conforming device ids which support these features to be enabled through
sysfs new_id.
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
drivers/pci/host/vmd.c | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/host/vmd.c b/drivers/pci/host/vmd.c
index 1544121b74f3..34fa6cf0b0ee 100644
--- a/drivers/pci/host/vmd.c
+++ b/drivers/pci/host/vmd.c
@@ -24,6 +24,10 @@
#define VMD_MEMBAR1 2
#define VMD_MEMBAR2 4
+#define PCI_REG_VMCAP 0x40
+#define BUS_RESTRICT_CAP(vmcap) (vmcap & 0x1)
+#define PCI_REG_VMCONFIG 0x44
+#define BUS_RESTRICT_CFG(vmcfg) ((vmcfg >> 8) & 0x3)
#define PCI_REG_VMLOCK 0x70
#define MB2_SHADOW_EN(vmlock) (vmlock & 0x2)
@@ -34,6 +38,12 @@ enum vmd_features {
* resource assignment to enable guest virtualization
*/
VMD_FEAT_HAS_MEMBAR_SHADOW = (1 << 0),
+
+ /*
+ * Device may provide root port configuration information which limits
+ * bus numbering
+ */
+ VMD_FEAT_HAS_BUS_RESTRICTIONS = (1 << 1),
};
/*
@@ -567,7 +577,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
unsigned long flags;
LIST_HEAD(resources);
resource_size_t offset[2] = {0};
- resource_size_t membar2_offset = 0x2000;
+ resource_size_t membar2_offset = 0x2000, busn_start = 0;
/*
* Shadow registers may exist in certain VMD device ids which allow
@@ -598,11 +608,25 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
}
}
+ /*
+ * Certain VMD devices may have a root port configuration option which
+ * limits the bus range to between 0-127 or 128-255
+ */
+ if (features & VMD_FEAT_HAS_BUS_RESTRICTIONS) {
+ u32 vmcap, vmconfig;
+
+ pci_read_config_dword(vmd->dev, PCI_REG_VMCAP, &vmcap);
+ pci_read_config_dword(vmd->dev, PCI_REG_VMCONFIG, &vmconfig);
+ if (BUS_RESTRICT_CAP(vmcap) &&
+ (BUS_RESTRICT_CFG(vmconfig) == 0x1))
+ busn_start = 128;
+ }
+
res = &vmd->dev->resource[VMD_CFGBAR];
vmd->resources[0] = (struct resource) {
.name = "VMD CFGBAR",
- .start = 0,
- .end = (resource_size(res) >> 20) - 1,
+ .start = busn_start,
+ .end = busn_start + (resource_size(res) >> 20) - 1,
.flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED,
};
@@ -670,8 +694,8 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
pci_add_resource_offset(&resources, &vmd->resources[1], offset[0]);
pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]);
- vmd->bus = pci_create_root_bus(&vmd->dev->dev, 0, &vmd_ops, sd,
- &resources);
+ vmd->bus = pci_create_root_bus(&vmd->dev->dev, busn_start, &vmd_ops,
+ sd, &resources);
if (!vmd->bus) {
pci_free_resource_list(&resources);
irq_domain_remove(vmd->irq_domain);
--
2.14.3
next prev parent reply other threads:[~2018-05-18 19:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-18 19:27 [PATCH 0/5] Enable an additional VMD device id Jon Derrick
2018-05-18 19:27 ` [PATCH 1/5] PCI: Add Intel VMD devices to pci ids Jon Derrick
2018-05-18 19:27 ` [PATCH 2/5] PCI/VMD: Assign membar addresses from shadow registers Jon Derrick
2018-05-18 19:28 ` Jon Derrick [this message]
2018-05-18 19:28 ` [PATCH 4/5] x86/PCI: Add additional VMD device root ports to VMD AER quirk Jon Derrick
2018-05-24 13:37 ` Bjorn Helgaas
2018-05-18 19:28 ` [PATCH 5/5] PCI/VMD: Add an additional VMD device id to driver device id table Jon Derrick
2018-05-24 11:44 ` [PATCH 0/5] Enable an additional VMD device id Lorenzo Pieralisi
2018-05-24 16:15 ` Derrick, Jonathan
2018-05-24 16:34 ` Lorenzo Pieralisi
2018-05-24 16:36 ` Derrick, Jonathan
2018-05-24 16:58 ` Lorenzo Pieralisi
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=20180518192802.20371-4-jonathan.derrick@intel.com \
--to=jonathan.derrick@intel.com \
--cc=david.fugate@intel.com \
--cc=hch@lst.de \
--cc=helgaas@kernel.org \
--cc=jroedel@suse.de \
--cc=keith.busch@intel.com \
--cc=linux-pci@vger.kernel.org \
--cc=myron.stowe@redhat.com \
--cc=scott.bauer@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).