|
|
d96c2d |
From 3aa31d7d6375303fc88438021aad485f50bb1e39 Mon Sep 17 00:00:00 2001
|
|
|
d96c2d |
Message-Id: <3aa31d7d6375303fc88438021aad485f50bb1e39.1404919343.git.crobinso@redhat.com>
|
|
|
d96c2d |
From: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
d96c2d |
Date: Mon, 23 Jun 2014 18:29:51 +0300
|
|
|
d96c2d |
Subject: [PATCH] hw/pci: reserve IO and mem for pci express downstream ports
|
|
|
d96c2d |
with no devices attached
|
|
|
d96c2d |
|
|
|
d96c2d |
Commit c6e298e1f12e0f4ca02b6da5e42919ae055f6830
|
|
|
d96c2d |
hw/pci: reserve IO and mem for pci-2-pci bridges with no devices attached
|
|
|
d96c2d |
|
|
|
d96c2d |
introduced support for hot-plugging devices behind pci-2-pci bridges.
|
|
|
d96c2d |
Extend hotplug support also for pci express downstream ports.
|
|
|
d96c2d |
|
|
|
d96c2d |
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
d96c2d |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
d96c2d |
---
|
|
|
d96c2d |
src/fw/pciinit.c | 34 ++++++++++++++++++++++++++++++++--
|
|
|
d96c2d |
1 file changed, 32 insertions(+), 2 deletions(-)
|
|
|
d96c2d |
|
|
|
d96c2d |
diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
|
|
|
d96c2d |
index 0ad548f..fd5dfb9 100644
|
|
|
d96c2d |
--- a/src/fw/pciinit.c
|
|
|
d96c2d |
+++ b/src/fw/pciinit.c
|
|
|
d96c2d |
@@ -636,6 +636,36 @@ pci_region_create_entry(struct pci_bus *bus, struct pci_device *dev,
|
|
|
d96c2d |
return entry;
|
|
|
d96c2d |
}
|
|
|
d96c2d |
|
|
|
d96c2d |
+static int pci_bus_hotplug_support(struct pci_bus *bus)
|
|
|
d96c2d |
+{
|
|
|
d96c2d |
+ u8 pcie_cap = pci_find_capability(bus->bus_dev, PCI_CAP_ID_EXP);
|
|
|
d96c2d |
+ u8 shpc_cap;
|
|
|
d96c2d |
+
|
|
|
d96c2d |
+ if (pcie_cap) {
|
|
|
d96c2d |
+ u16 pcie_flags = pci_config_readw(bus->bus_dev->bdf,
|
|
|
d96c2d |
+ pcie_cap + PCI_EXP_FLAGS);
|
|
|
d96c2d |
+ u8 port_type = ((pcie_flags & PCI_EXP_FLAGS_TYPE) >>
|
|
|
d96c2d |
+ (__builtin_ffs(PCI_EXP_FLAGS_TYPE) - 1));
|
|
|
d96c2d |
+ u8 downstream_port = (port_type == PCI_EXP_TYPE_DOWNSTREAM) ||
|
|
|
d96c2d |
+ (port_type == PCI_EXP_TYPE_ROOT_PORT);
|
|
|
d96c2d |
+ /*
|
|
|
d96c2d |
+ * PCI Express SPEC, 7.8.2:
|
|
|
d96c2d |
+ * Slot Implemented – When Set, this bit indicates that the Link
|
|
|
d96c2d |
+ * HwInit associated with this Port is connected to a slot (as
|
|
|
d96c2d |
+ * compared to being connected to a system-integrated device or
|
|
|
d96c2d |
+ * being disabled).
|
|
|
d96c2d |
+ * This bit is valid for Downstream Ports. This bit is undefined
|
|
|
d96c2d |
+ * for Upstream Ports.
|
|
|
d96c2d |
+ */
|
|
|
d96c2d |
+ u16 slot_implemented = pcie_flags & PCI_EXP_FLAGS_SLOT;
|
|
|
d96c2d |
+
|
|
|
d96c2d |
+ return downstream_port && slot_implemented;
|
|
|
d96c2d |
+ }
|
|
|
d96c2d |
+
|
|
|
d96c2d |
+ shpc_cap = pci_find_capability(bus->bus_dev, PCI_CAP_ID_SHPC);
|
|
|
d96c2d |
+ return !!shpc_cap;
|
|
|
d96c2d |
+}
|
|
|
d96c2d |
+
|
|
|
d96c2d |
static int pci_bios_check_devices(struct pci_bus *busses)
|
|
|
d96c2d |
{
|
|
|
d96c2d |
dprintf(1, "PCI: check devices\n");
|
|
|
d96c2d |
@@ -678,7 +708,7 @@ static int pci_bios_check_devices(struct pci_bus *busses)
|
|
|
d96c2d |
continue;
|
|
|
d96c2d |
struct pci_bus *parent = &busses[pci_bdf_to_bus(s->bus_dev->bdf)];
|
|
|
d96c2d |
int type;
|
|
|
d96c2d |
- u8 shpc_cap = pci_find_capability(s->bus_dev, PCI_CAP_ID_SHPC);
|
|
|
d96c2d |
+ int hotplug_support = pci_bus_hotplug_support(s);
|
|
|
d96c2d |
for (type = 0; type < PCI_REGION_TYPE_COUNT; type++) {
|
|
|
d96c2d |
u64 align = (type == PCI_REGION_TYPE_IO) ?
|
|
|
d96c2d |
PCI_BRIDGE_IO_MIN : PCI_BRIDGE_MEM_MIN;
|
|
|
d96c2d |
@@ -687,7 +717,7 @@ static int pci_bios_check_devices(struct pci_bus *busses)
|
|
|
d96c2d |
if (pci_region_align(&s->r[type]) > align)
|
|
|
d96c2d |
align = pci_region_align(&s->r[type]);
|
|
|
d96c2d |
u64 sum = pci_region_sum(&s->r[type]);
|
|
|
d96c2d |
- if (!sum && shpc_cap)
|
|
|
d96c2d |
+ if (!sum && hotplug_support)
|
|
|
d96c2d |
sum = align; /* reserve min size for hot-plug */
|
|
|
d96c2d |
u64 size = ALIGN(sum, align);
|
|
|
d96c2d |
int is64 = pci_bios_bridge_region_is64(&s->r[type],
|
|
|
d96c2d |
--
|
|
|
d96c2d |
1.9.3
|
|
|
d96c2d |
|