Normalize IRQ function names to a consistent vfio_pci_*_verb pattern: vfio_pci_interrupt_setup -> vfio_pci_irq_setup vfio_disable_interrupts -> vfio_pci_irq_disable vfio_intx_enable -> vfio_pci_intx_enable vfio_intx_disable -> vfio_pci_intx_disable vfio_pci_vector_init -> vfio_pci_msi_vector_use vfio_msi_setup -> vfio_pci_msi_setup vfio_msi_enable -> vfio_pci_msi_enable vfio_msi_disable -> vfio_pci_msi_disable vfio_update_msi -> vfio_pci_msi_update vfio_pci_teardown_msi -> vfio_pci_msi_teardown vfio_msix_early_setup -> vfio_pci_msix_early_setup vfio_msix_setup -> vfio_pci_msix_setup vfio_msix_enable -> vfio_pci_msix_enable vfio_msix_disable -> vfio_pci_msix_disable vfio_unregister_err_notifier -> vfio_pci_unregister_err_notifier vfio_unregister_req_notifier -> vfio_pci_unregister_req_notifier
Drop the vfio_pci_intx_enable() wrapper that called vfio_intx_enable() and reorder the declarations in pci.h. No functional change. Signed-off-by: Cédric Le Goater <[email protected]> --- hw/vfio/pci.h | 45 ++++++++++++++++++---------------- hw/vfio-user/pci.c | 4 +-- hw/vfio/cpr.c | 2 +- hw/vfio/pci-irq.c | 61 +++++++++++++++++++++------------------------- hw/vfio/pci.c | 38 ++++++++++++++--------------- 5 files changed, 74 insertions(+), 76 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 3315fb4fbceb..184df22b6e67 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -212,29 +212,32 @@ static inline bool vfio_is_base_display(VFIOPCIDevice *vdev) } /* MSI/MSI-X/INTx */ -void vfio_pci_vector_init(VFIOPCIDevice *vdev, int nr); +bool vfio_pci_irq_setup(VFIOPCIDevice *vdev, Error **errp); +void vfio_pci_irq_disable(VFIOPCIDevice *vdev); + +bool vfio_pci_intx_enable(VFIOPCIDevice *vdev, Error **errp); +void vfio_pci_intx_disable(VFIOPCIDevice *vdev); +void vfio_pci_intx_eoi(VFIODevice *vbasedev); +void vfio_pci_intx_set_handler(VFIOPCIDevice *vdev, bool enable); + +bool vfio_pci_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp); +void vfio_pci_msi_vector_use(VFIOPCIDevice *vdev, int nr); +void vfio_pci_msi_enable(VFIOPCIDevice *vdev); +void vfio_pci_msi_disable(VFIOPCIDevice *vdev); +void vfio_pci_msi_update(VFIOPCIDevice *vdev); +void vfio_pci_msi_set_handler(VFIOPCIDevice *vdev, int nr, bool enable); +void vfio_pci_msi_teardown(VFIOPCIDevice *vdev); + +bool vfio_pci_msix_early_setup(VFIOPCIDevice *vdev, Error **errp); +bool vfio_pci_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp); +void vfio_pci_msix_enable(VFIOPCIDevice *vdev); +void vfio_pci_msix_disable(VFIOPCIDevice *vdev); +void vfio_pci_msix_set_notifiers(VFIOPCIDevice *vdev); + void vfio_pci_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector, int vector_n, bool msix); void vfio_pci_prepare_kvm_msi_virq_batch(VFIOPCIDevice *vdev); void vfio_pci_commit_kvm_msi_virq_batch(VFIOPCIDevice *vdev); -bool vfio_pci_intx_enable(VFIOPCIDevice *vdev, Error **errp); -void vfio_pci_intx_set_handler(VFIOPCIDevice *vdev, bool enable); -void vfio_pci_msix_set_notifiers(VFIOPCIDevice *vdev); -void vfio_pci_msi_set_handler(VFIOPCIDevice *vdev, int nr, bool enable); -void vfio_disable_interrupts(VFIOPCIDevice *vdev); -bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp); -void vfio_intx_disable(VFIOPCIDevice *vdev); -void vfio_msi_enable(VFIOPCIDevice *vdev); -void vfio_msi_disable(VFIOPCIDevice *vdev); -void vfio_msix_enable(VFIOPCIDevice *vdev); -void vfio_msix_disable(VFIOPCIDevice *vdev); -void vfio_update_msi(VFIOPCIDevice *vdev); -bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp); -bool vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp); -bool vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp); -bool vfio_pci_interrupt_setup(VFIOPCIDevice *vdev, Error **errp); -void vfio_pci_intx_eoi(VFIODevice *vbasedev); -void vfio_pci_teardown_msi(VFIOPCIDevice *vdev); /* Config space */ int vfio_pci_config_space_read(VFIOPCIDevice *vdev, off_t offset, @@ -301,9 +304,9 @@ extern const VMStateDescription vfio_display_vmstate; /* Notifiers */ void vfio_pci_register_err_notifier(VFIOPCIDevice *vdev); -void vfio_unregister_err_notifier(VFIOPCIDevice *vdev); +void vfio_pci_unregister_err_notifier(VFIOPCIDevice *vdev); void vfio_pci_register_req_notifier(VFIOPCIDevice *vdev); -void vfio_unregister_req_notifier(VFIOPCIDevice *vdev); +void vfio_pci_unregister_req_notifier(VFIOPCIDevice *vdev); /** * vfio_pci_from_vfio_device: Transform from VFIODevice to diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index c749ff149f8a..2a66500c1e6d 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -345,7 +345,7 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp) vfio_user_msix_setup(vdev); } - if (!vfio_pci_interrupt_setup(vdev, errp)) { + if (!vfio_pci_irq_setup(vdev, errp)) { goto out_teardown; } @@ -355,7 +355,7 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp) return; out_teardown: - vfio_pci_teardown_msi(vdev); + vfio_pci_msi_teardown(vdev); vfio_pci_bars_exit(vdev); error: error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index 6e1659dcddc1..3c1304781d76 100644 --- a/hw/vfio/cpr.c +++ b/hw/vfio/cpr.c @@ -69,7 +69,7 @@ static void vfio_cpr_claim_vectors(VFIOPCIDevice *vdev, int nr_vectors, fd = vfio_cpr_load_vector_fd(vdev, "interrupt", i); if (fd >= 0) { - vfio_pci_vector_init(vdev, i); + vfio_pci_msi_vector_use(vdev, i); vfio_pci_msi_set_handler(vdev, i, true); } diff --git a/hw/vfio/pci-irq.c b/hw/vfio/pci-irq.c index 2b2a118b130a..62b0e9a64d90 100644 --- a/hw/vfio/pci-irq.c +++ b/hw/vfio/pci-irq.c @@ -301,7 +301,7 @@ static void vfio_irqchip_change(Notifier *notify, void *data) vfio_intx_update(vdev, &vdev->intx.route); } -bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) +bool vfio_pci_intx_enable(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev = PCI_DEVICE(vdev); uint32_t val = vfio_pci_read_config(pdev, PCI_INTERRUPT_PIN, 1); @@ -329,7 +329,7 @@ bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) * The incoming state is cleared thereafter. */ if (!cpr_is_incoming()) { - vfio_disable_interrupts(vdev); + vfio_pci_irq_disable(vdev); } vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */ @@ -377,7 +377,7 @@ skip_signaling: return true; } -void vfio_intx_disable(VFIOPCIDevice *vdev) +void vfio_pci_intx_disable(VFIOPCIDevice *vdev) { PCIDevice *pdev = PCI_DEVICE(vdev); int fd; @@ -400,11 +400,6 @@ void vfio_intx_disable(VFIOPCIDevice *vdev) trace_vfio_intx_disable(vdev->vbasedev.name); } -bool vfio_pci_intx_enable(VFIOPCIDevice *vdev, Error **errp) -{ - return vfio_intx_enable(vdev, errp); -} - void vfio_pci_intx_set_handler(VFIOPCIDevice *vdev, bool enable) { int fd = event_notifier_get_fd(&vdev->intx.interrupt); @@ -629,7 +624,7 @@ static void set_irq_signalling(VFIODevice *vbasedev, VFIOMSIVector *vector, } } -void vfio_pci_vector_init(VFIOPCIDevice *vdev, int nr) +void vfio_pci_msi_vector_use(VFIOPCIDevice *vdev, int nr) { VFIOMSIVector *vector = &vdev->msi_vectors[nr]; PCIDevice *pdev = PCI_DEVICE(vdev); @@ -660,7 +655,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr, vector = &vdev->msi_vectors[nr]; if (!vector->use) { - vfio_pci_vector_init(vdev, nr); + vfio_pci_msi_vector_use(vdev, nr); } qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt), @@ -801,12 +796,12 @@ void vfio_pci_commit_kvm_msi_virq_batch(VFIOPCIDevice *vdev) } } -void vfio_msix_enable(VFIOPCIDevice *vdev) +void vfio_pci_msix_enable(VFIOPCIDevice *vdev) { PCIDevice *pdev = PCI_DEVICE(vdev); int ret; - vfio_disable_interrupts(vdev); + vfio_pci_irq_disable(vdev); vdev->msi_vectors = g_new0(VFIOMSIVector, vdev->msix->entries); @@ -856,12 +851,12 @@ void vfio_msix_enable(VFIOPCIDevice *vdev) trace_vfio_msix_enable(vdev->vbasedev.name); } -void vfio_msi_enable(VFIOPCIDevice *vdev) +void vfio_pci_msi_enable(VFIOPCIDevice *vdev) { PCIDevice *pdev = PCI_DEVICE(vdev); int ret, i; - vfio_disable_interrupts(vdev); + vfio_pci_irq_disable(vdev); vdev->nr_vectors = msi_nr_vectors_allocated(pdev); retry: @@ -954,7 +949,7 @@ static void vfio_msi_disable_common(VFIOPCIDevice *vdev) vdev->interrupt = VFIO_INT_NONE; } -void vfio_msix_disable(VFIOPCIDevice *vdev) +void vfio_pci_msix_disable(VFIOPCIDevice *vdev) { PCIDevice *pdev = PCI_DEVICE(vdev); Error *err = NULL; @@ -975,12 +970,12 @@ void vfio_msix_disable(VFIOPCIDevice *vdev) /* * Always clear MSI-X IRQ index. A PF device could have enabled - * MSI-X with no vectors. See vfio_msix_enable(). + * MSI-X with no vectors. See vfio_pci_msix_enable(). */ vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); vfio_msi_disable_common(vdev); - if (!vfio_intx_enable(vdev, &err)) { + if (!vfio_pci_intx_enable(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } @@ -990,13 +985,13 @@ void vfio_msix_disable(VFIOPCIDevice *vdev) trace_vfio_msix_disable(vdev->vbasedev.name); } -void vfio_msi_disable(VFIOPCIDevice *vdev) +void vfio_pci_msi_disable(VFIOPCIDevice *vdev) { Error *err = NULL; vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_MSI_IRQ_INDEX); vfio_msi_disable_common(vdev); - vfio_intx_enable(vdev, &err); + vfio_pci_intx_enable(vdev, &err); if (err) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } @@ -1004,7 +999,7 @@ void vfio_msi_disable(VFIOPCIDevice *vdev) trace_vfio_msi_disable(vdev->vbasedev.name); } -void vfio_update_msi(VFIOPCIDevice *vdev) +void vfio_pci_msi_update(VFIOPCIDevice *vdev) { PCIDevice *pdev = PCI_DEVICE(vdev); int i; @@ -1025,7 +1020,7 @@ void vfio_update_msi(VFIOPCIDevice *vdev) /* * Interrupt setup */ -void vfio_disable_interrupts(VFIOPCIDevice *vdev) +void vfio_pci_irq_disable(VFIOPCIDevice *vdev) { /* * More complicated than it looks. Disabling MSI/X transitions the @@ -1033,17 +1028,17 @@ void vfio_disable_interrupts(VFIOPCIDevice *vdev) * disable MSI/X and then cleanup by disabling INTx. */ if (vdev->interrupt == VFIO_INT_MSIX) { - vfio_msix_disable(vdev); + vfio_pci_msix_disable(vdev); } else if (vdev->interrupt == VFIO_INT_MSI) { - vfio_msi_disable(vdev); + vfio_pci_msi_disable(vdev); } if (vdev->interrupt == VFIO_INT_INTx) { - vfio_intx_disable(vdev); + vfio_pci_intx_disable(vdev); } } -bool vfio_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp) +bool vfio_pci_msi_setup(VFIOPCIDevice *vdev, int pos, Error **errp) { PCIDevice *pdev = PCI_DEVICE(vdev); uint16_t ctrl; @@ -1259,7 +1254,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp) * need to first look for where the MSI-X table lives. So we * unfortunately split MSI-X setup across two functions. */ -bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) +bool vfio_pci_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev = PCI_DEVICE(vdev); uint8_t pos; @@ -1367,7 +1362,7 @@ bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) return vfio_pci_relocate_msix(vdev, errp); } -bool vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) +bool vfio_pci_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) { PCIDevice *pdev = PCI_DEVICE(vdev); int ret; @@ -1425,7 +1420,7 @@ bool vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp) return true; } -void vfio_pci_teardown_msi(VFIOPCIDevice *vdev) +void vfio_pci_msi_teardown(VFIOPCIDevice *vdev) { PCIDevice *pdev = PCI_DEVICE(vdev); @@ -1503,7 +1498,7 @@ void vfio_pci_register_err_notifier(VFIOPCIDevice *vdev) } } -void vfio_unregister_err_notifier(VFIOPCIDevice *vdev) +void vfio_pci_unregister_err_notifier(VFIOPCIDevice *vdev) { Error *err = NULL; @@ -1577,7 +1572,7 @@ void vfio_pci_register_req_notifier(VFIOPCIDevice *vdev) } } -void vfio_unregister_req_notifier(VFIOPCIDevice *vdev) +void vfio_pci_unregister_req_notifier(VFIOPCIDevice *vdev) { Error *err = NULL; @@ -1596,7 +1591,7 @@ void vfio_unregister_req_notifier(VFIOPCIDevice *vdev) vdev->req_enabled = false; } -bool vfio_pci_interrupt_setup(VFIOPCIDevice *vdev, Error **errp) +bool vfio_pci_irq_setup(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev = PCI_DEVICE(vdev); @@ -1620,11 +1615,11 @@ bool vfio_pci_interrupt_setup(VFIOPCIDevice *vdev, Error **errp) kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier); /* - * During CPR, do not call vfio_intx_enable at this time. Instead, + * During CPR, do not call vfio_pci_intx_enable at this time. Instead, * call it from vfio_pci_post_load after the intx routing data has * been loaded from vmstate. */ - if (!cpr_is_incoming() && !vfio_intx_enable(vdev, errp)) { + if (!cpr_is_incoming() && !vfio_pci_intx_enable(vdev, errp)) { timer_free(vdev->intx.mmap_timer); pci_device_set_intx_routing_notifier(pdev, NULL); kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 5fd099695c8e..9a3e960126ea 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -482,13 +482,13 @@ void vfio_pci_write_config(PCIDevice *pdev, if (!was_enabled) { if (is_enabled) { - vfio_msi_enable(vdev); + vfio_pci_msi_enable(vdev); } } else { if (!is_enabled) { - vfio_msi_disable(vdev); + vfio_pci_msi_disable(vdev); } else { - vfio_update_msi(vdev); + vfio_pci_msi_update(vdev); } } } else if (pdev->cap_present & QEMU_PCI_CAP_MSIX && @@ -500,9 +500,9 @@ void vfio_pci_write_config(PCIDevice *pdev, is_enabled = msix_enabled(pdev); if (!was_enabled && is_enabled) { - vfio_msix_enable(vdev); + vfio_pci_msix_enable(vdev); } else if (was_enabled && !is_enabled) { - vfio_msix_disable(vdev); + vfio_pci_msix_disable(vdev); } } else if (ranges_overlap(addr, len, PCI_BASE_ADDRESS_0, 24) || range_covers_byte(addr, len, PCI_COMMAND)) { @@ -1021,14 +1021,14 @@ static bool vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos, Error **errp) switch (cap_id) { case PCI_CAP_ID_MSI: - ret = vfio_msi_setup(vdev, pos, errp); + ret = vfio_pci_msi_setup(vdev, pos, errp); break; case PCI_CAP_ID_EXP: vfio_check_pcie_flr(vdev, pos); ret = vfio_setup_pcie_cap(vdev, pos, size, errp); break; case PCI_CAP_ID_MSIX: - ret = vfio_msix_setup(vdev, pos, errp); + ret = vfio_pci_msix_setup(vdev, pos, errp); break; case PCI_CAP_ID_PM: vfio_check_pm_reset(vdev, pos); @@ -1361,7 +1361,7 @@ void vfio_pci_pre_reset(VFIOPCIDevice *vdev) uint32_t val; uint16_t cmd; - vfio_disable_interrupts(vdev); + vfio_pci_irq_disable(vdev); /* * Stop any ongoing DMA by disconnecting I/O, MMIO, and bus master. @@ -1410,7 +1410,7 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev) Error *err = NULL; int ret, nr; - if (!vfio_intx_enable(vdev, &err)) { + if (!vfio_pci_intx_enable(vdev, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } @@ -1618,9 +1618,9 @@ static int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f) } if (msi_enabled(pdev)) { - vfio_msi_enable(vdev); + vfio_pci_msi_enable(vdev); } else if (msix_enabled(pdev)) { - vfio_msix_enable(vdev); + vfio_pci_msix_enable(vdev); } return ret; @@ -1944,7 +1944,7 @@ bool vfio_pci_config_setup(VFIOPCIDevice *vdev, Error **errp) vfio_bars_prepare(vdev); - if (!vfio_msix_early_setup(vdev, errp)) { + if (!vfio_pci_msix_early_setup(vdev, errp)) { return false; } @@ -2043,7 +2043,7 @@ static void vfio_pci_realize(PCIDevice *pdev, Error **errp) vfio_bar_quirk_setup(vdev, i); } - if (!vfio_pci_interrupt_setup(vdev, errp)) { + if (!vfio_pci_irq_setup(vdev, errp)) { goto out_unset_idev; } @@ -2097,7 +2097,7 @@ static void vfio_pci_realize(PCIDevice *pdev, Error **errp) out_deregister: vfio_display_exit(vdev); if (vdev->interrupt == VFIO_INT_INTx) { - vfio_intx_disable(vdev); + vfio_pci_intx_disable(vdev); } pci_device_set_intx_routing_notifier(pdev, NULL); if (vdev->irqchip_change_notifier.notify) { @@ -2111,7 +2111,7 @@ out_unset_idev: pci_device_unset_iommu_device(pdev); } out_teardown: - vfio_pci_teardown_msi(vdev); + vfio_pci_msi_teardown(vdev); vfio_pci_bars_exit(vdev); error: error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name); @@ -2130,17 +2130,17 @@ static void vfio_exitfn(PCIDevice *pdev) VFIODevice *vbasedev = &vdev->vbasedev; vfio_display_exit(vdev); - vfio_unregister_req_notifier(vdev); - vfio_unregister_err_notifier(vdev); + vfio_pci_unregister_req_notifier(vdev); + vfio_pci_unregister_err_notifier(vdev); pci_device_set_intx_routing_notifier(pdev, NULL); if (vdev->irqchip_change_notifier.notify) { kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier); } - vfio_disable_interrupts(vdev); + vfio_pci_irq_disable(vdev); if (vdev->intx.mmap_timer) { timer_free(vdev->intx.mmap_timer); } - vfio_pci_teardown_msi(vdev); + vfio_pci_msi_teardown(vdev); vfio_pci_disable_rp_atomics(vdev); vfio_pci_bars_exit(vdev); vfio_migration_exit(vbasedev); -- 2.56.0
