diff options
-rw-r--r-- | core/pci.c | 13 | ||||
-rw-r--r-- | hw/p7ioc-phb.c | 19 | ||||
-rw-r--r-- | hw/phb3.c | 19 | ||||
-rw-r--r-- | hw/phb4.c | 19 |
4 files changed, 22 insertions, 48 deletions
@@ -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 || @@ -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 || @@ -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 || |