diff options
-rw-r--r-- | hw/pci.c | 19 | ||||
-rw-r--r-- | hw/pci.h | 3 | ||||
-rw-r--r-- | hw/pcie.c | 8 | ||||
-rw-r--r-- | hw/pcie_aer.c | 24 |
4 files changed, 21 insertions, 33 deletions
@@ -25,8 +25,6 @@ #include "pci.h" #include "pci_bridge.h" #include "pci_internals.h" -#include "msix.h" -#include "msi.h" #include "monitor.h" #include "net.h" #include "sysemu.h" @@ -1099,23 +1097,6 @@ static void pci_set_irq(void *opaque, int irq_num, int level) pci_change_irq_level(pci_dev, irq_num, change); } -bool pci_msi_enabled(PCIDevice *dev) -{ - return msix_enabled(dev) || msi_enabled(dev); -} - -void pci_msi_notify(PCIDevice *dev, unsigned int vector) -{ - if (msix_enabled(dev)) { - msix_notify(dev, vector); - } else if (msi_enabled(dev)) { - msi_notify(dev, vector); - } else { - /* MSI/MSI-X must be enabled */ - abort(); - } -} - /***********************************************************/ /* monitor info on PCI */ @@ -261,9 +261,6 @@ void do_pci_info_print(Monitor *mon, const QObject *data); void do_pci_info(Monitor *mon, QObject **ret_data); void pci_bridge_update_mappings(PCIBus *b); -bool pci_msi_enabled(PCIDevice *dev); -void pci_msi_notify(PCIDevice *dev, unsigned int vector); - static inline void pci_set_byte(uint8_t *config, uint8_t val) { @@ -167,10 +167,12 @@ static void hotplug_event_notify(PCIDevice *dev) * The Port may optionally send an MSI when there are hot-plug events that * occur while interrupt generation is disabled, and interrupt generation is * subsequently enabled. */ - if (!pci_msi_enabled(dev)) { + if (msix_enabled(dev)) { + msix_notify(dev, pcie_cap_flags_get_vector(dev)); + } else if (msi_enabled(dev)) { + msi_notify(dev, pcie_cap_flags_get_vector(dev)); + } else { qemu_set_irq(dev->irq[dev->exp.hpev_intx], dev->exp.hpev_notified); - } else if (dev->exp.hpev_notified) { - pci_msi_notify(dev, pcie_cap_flags_get_vector(dev)); } } diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c index 47d64003fc..dac27c39fe 100644 --- a/hw/pcie_aer.c +++ b/hw/pcie_aer.c @@ -339,9 +339,13 @@ static bool pcie_aer_msg_root_port(PCIDevice *dev, const PCIEAERMsg *msg) if (root_cmd & msg->severity) { /* 6.2.4.1.2 Interrupt Generation */ - if (pci_msi_enabled(dev)) { + if (msix_enabled(dev)) { if (msi_trigger) { - pci_msi_notify(dev, pcie_aer_root_get_vector(dev)); + msix_notify(dev, pcie_aer_root_get_vector(dev)); + } + } else if (msi_enabled(dev)) { + if (msi_trigger) { + msi_notify(dev, pcie_aer_root_get_vector(dev)); } } else { qemu_set_irq(dev->irq[dev->exp.aer_intx], 1); @@ -761,16 +765,20 @@ void pcie_aer_root_write_config(PCIDevice *dev, /* 6.2.4.1.2 Interrupt Generation */ /* 0 -> 1 */ - uint32_t root_cmd_set = (root_cmd_prev ^ root_cmd) & root_cmd; + uint32_t root_cmd_set = ~root_cmd_prev & root_cmd; uint32_t root_status = pci_get_long(aer_cap + PCI_ERR_ROOT_STATUS); + bool trigger = pcie_aer_root_does_trigger(root_cmd_set, root_status); - if (pci_msi_enabled(dev)) { - if (pcie_aer_root_does_trigger(root_cmd_set, root_status)) { - pci_msi_notify(dev, pcie_aer_root_get_vector(dev)); + if (msix_enabled(dev)) { + if (trigger) { + msix_notify(dev, pcie_aer_root_get_vector(dev)); + } + } else if (msi_enabled(dev)) { + if (trigger) { + msi_notify(dev, pcie_aer_root_get_vector(dev)); } } else { - int int_level = pcie_aer_root_does_trigger(root_cmd, root_status); - qemu_set_irq(dev->irq[dev->exp.aer_intx], int_level); + qemu_set_irq(dev->irq[dev->exp.aer_intx], trigger); } } } |