aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/pci.c13
-rw-r--r--hw/p7ioc-phb.c19
-rw-r--r--hw/phb3.c19
-rw-r--r--hw/phb4.c19
4 files changed, 22 insertions, 48 deletions
diff --git a/core/pci.c b/core/pci.c
index 5f6e259..f227f69 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -188,9 +188,22 @@ static void pci_init_pcie_cap(struct phb *phb, struct pci_device *pd)
pd->mps = 4096;
}
+static void pci_init_aer_cap(struct phb *phb, struct pci_device *pd)
+{
+ int64_t pos;
+
+ if (!pci_has_cap(pd, PCI_CFG_CAP_ID_EXP, false))
+ return;
+
+ pos = pci_find_ecap(phb, pd->bdfn, PCIECAP_ID_AER, NULL);
+ if (pos > 0)
+ pci_set_cap(pd, PCIECAP_ID_AER, pos, true);
+}
+
void pci_init_capabilities(struct phb *phb, struct pci_device *pd)
{
pci_init_pcie_cap(phb, pd);
+ pci_init_aer_cap(phb, pd);
}
static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *parent,
diff --git a/hw/p7ioc-phb.c b/hw/p7ioc-phb.c
index 903fbf5..82d4f15 100644
--- a/hw/p7ioc-phb.c
+++ b/hw/p7ioc-phb.c
@@ -1508,26 +1508,13 @@ static int p7ioc_device_init(struct phb *phb,
struct pci_device *dev,
void *data __unused)
{
- int ecap = 0;
- int aercap = 0;
-
- /* Figure out AER capability */
- if (pci_has_cap(dev, PCI_CFG_CAP_ID_EXP, false)) {
- ecap = pci_cap(dev, PCI_CFG_CAP_ID_EXP, false);
-
- if (!pci_has_cap(dev, PCIECAP_ID_AER, true)) {
- aercap = pci_find_ecap(phb, dev->bdfn,
- PCIECAP_ID_AER, NULL);
- if (aercap > 0)
- pci_set_cap(dev, PCIECAP_ID_AER, aercap, true);
- } else {
- aercap = pci_cap(dev, PCIECAP_ID_AER, true);
- }
- }
+ int ecap, aercap;
/* Common initialization for the device */
pci_device_init(phb, dev);
+ ecap = pci_cap(dev, PCI_CFG_CAP_ID_EXP, false);
+ aercap = pci_cap(dev, PCIECAP_ID_AER, true);
if (dev->dev_type == PCIE_TYPE_ROOT_PORT)
p7ioc_root_port_init(phb, dev, ecap, aercap);
else if (dev->dev_type == PCIE_TYPE_SWITCH_UPPORT ||
diff --git a/hw/phb3.c b/hw/phb3.c
index e246e46..cdb52cb 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -645,29 +645,16 @@ static int phb3_device_init(struct phb *phb,
struct pci_device *dev,
void *data __unused)
{
- int ecap = 0;
- int aercap = 0;
+ int ecap, aercap;
/* Some special adapter tweaks for devices directly under the PHB */
phb3_check_device_quirks(phb, dev);
- /* Figure out PCIe & AER capability */
- if (pci_has_cap(dev, PCI_CFG_CAP_ID_EXP, false)) {
- ecap = pci_cap(dev, PCI_CFG_CAP_ID_EXP, false);
-
- if (!pci_has_cap(dev, PCIECAP_ID_AER, true)) {
- aercap = pci_find_ecap(phb, dev->bdfn,
- PCIECAP_ID_AER, NULL);
- if (aercap > 0)
- pci_set_cap(dev, PCIECAP_ID_AER, aercap, true);
- } else {
- aercap = pci_cap(dev, PCIECAP_ID_AER, true);
- }
- }
-
/* Common initialization for the device */
pci_device_init(phb, dev);
+ ecap = pci_cap(dev, PCI_CFG_CAP_ID_EXP, false);
+ aercap = pci_cap(dev, PCIECAP_ID_AER, true);
if (dev->dev_type == PCIE_TYPE_ROOT_PORT)
phb3_root_port_init(phb, dev, ecap, aercap);
else if (dev->dev_type == PCIE_TYPE_SWITCH_UPPORT ||
diff --git a/hw/phb4.c b/hw/phb4.c
index 3cdacea..6bf0d88 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -662,30 +662,17 @@ static void phb4_check_device_quirks(struct phb *phb, struct pci_device *dev)
static int phb4_device_init(struct phb *phb, struct pci_device *dev,
void *data __unused)
{
- int ecap = 0;
- int aercap = 0;
+ int ecap, aercap;
/* Some special adapter tweaks for devices directly under the PHB */
if (dev->primary_bus == 1)
phb4_check_device_quirks(phb, dev);
- /* Figure out PCIe & AER capability */
- if (pci_has_cap(dev, PCI_CFG_CAP_ID_EXP, false)) {
- ecap = pci_cap(dev, PCI_CFG_CAP_ID_EXP, false);
-
- if (!pci_has_cap(dev, PCIECAP_ID_AER, true)) {
- aercap = pci_find_ecap(phb, dev->bdfn,
- PCIECAP_ID_AER, NULL);
- if (aercap > 0)
- pci_set_cap(dev, PCIECAP_ID_AER, aercap, true);
- } else {
- aercap = pci_cap(dev, PCIECAP_ID_AER, true);
- }
- }
-
/* Common initialization for the device */
pci_device_init(phb, dev);
+ ecap = pci_cap(dev, PCI_CFG_CAP_ID_EXP, false);
+ aercap = pci_cap(dev, PCIECAP_ID_AER, true);
if (dev->dev_type == PCIE_TYPE_ROOT_PORT)
phb4_root_port_init(phb, dev, ecap, aercap);
else if (dev->dev_type == PCIE_TYPE_SWITCH_UPPORT ||