mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-08-26 22:23:12 -04:00
accel/accel-irq: add generic begin_route_changes
A generic accel_irqchip_begin_route_change() fn has been introduced for usage in the MSHV accelerator. It replaces the respective kvm_ fn. Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com> Link: https://lore.kernel.org/r/20260417105618.3621-6-magnuskulke@linux.microsoft.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
61c139c4fa
commit
49b2dcbd24
7 changed files with 30 additions and 14 deletions
|
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "hw/pci/msi.h"
|
||||
|
||||
#include "system/kvm.h"
|
||||
|
|
@ -104,3 +105,23 @@ int accel_irqchip_remove_irqfd_notifier_gsi(EventNotifier *n, int virq)
|
|||
}
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
inline AccelRouteChange accel_irqchip_begin_route_changes(void)
|
||||
{
|
||||
#ifdef CONFIG_MSHV_IS_POSSIBLE
|
||||
if (mshv_msi_via_irqfd_enabled()) {
|
||||
return (AccelRouteChange) {
|
||||
.accel = ACCEL(mshv_state),
|
||||
.changes = 0,
|
||||
};
|
||||
}
|
||||
#endif
|
||||
if (kvm_enabled()) {
|
||||
return (AccelRouteChange) {
|
||||
.accel = ACCEL(kvm_state),
|
||||
.changes = 0,
|
||||
};
|
||||
}
|
||||
error_report("can't initiate route change, no accel irqchip available");
|
||||
abort();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include "hw/core/qdev-properties-system.h"
|
||||
#include "hw/pci/msi.h"
|
||||
#include "hw/pci/msix.h"
|
||||
#include "system/kvm.h"
|
||||
#include "system/accel-irq.h"
|
||||
#include "migration/blocker.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "qemu/error-report.h"
|
||||
|
|
@ -430,7 +430,7 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, int vector,
|
|||
IVSHMEM_DPRINTF("ivshmem_add_kvm_msi_virq vector:%d\n", vector);
|
||||
assert(!s->msi_vectors[vector].pdev);
|
||||
|
||||
c = kvm_irqchip_begin_route_changes(kvm_state);
|
||||
c = accel_irqchip_begin_route_changes();
|
||||
ret = kvm_irqchip_add_msi_route(&c, vector, pdev);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "kvm_irqchip_add_msi_route failed");
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "qemu/module.h"
|
||||
#include "qemu/range.h"
|
||||
#include "qemu/units.h"
|
||||
#include "system/accel-irq.h"
|
||||
#include "system/kvm.h"
|
||||
#include "system/runstate.h"
|
||||
#include "pci.h"
|
||||
|
|
@ -688,7 +689,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
|
|||
if (vdev->defer_kvm_irq_routing) {
|
||||
vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true);
|
||||
} else {
|
||||
vfio_route_change = kvm_irqchip_begin_route_changes(kvm_state);
|
||||
vfio_route_change = accel_irqchip_begin_route_changes();
|
||||
vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true);
|
||||
kvm_irqchip_commit_route_changes(&vfio_route_change);
|
||||
vfio_connect_kvm_msi_virq(vector, nr);
|
||||
|
|
@ -789,7 +790,7 @@ void vfio_pci_prepare_kvm_msi_virq_batch(VFIOPCIDevice *vdev)
|
|||
{
|
||||
assert(!vdev->defer_kvm_irq_routing);
|
||||
vdev->defer_kvm_irq_routing = true;
|
||||
vfio_route_change = kvm_irqchip_begin_route_changes(kvm_state);
|
||||
vfio_route_change = accel_irqchip_begin_route_changes();
|
||||
}
|
||||
|
||||
void vfio_pci_commit_kvm_msi_virq_batch(VFIOPCIDevice *vdev)
|
||||
|
|
|
|||
|
|
@ -869,7 +869,7 @@ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,
|
|||
int ret;
|
||||
|
||||
if (irqfd->users == 0) {
|
||||
AccelRouteChange c = kvm_irqchip_begin_route_changes(kvm_state);
|
||||
AccelRouteChange c = accel_irqchip_begin_route_changes();
|
||||
ret = accel_irqchip_add_msi_route(&c, vector, &proxy->pci_dev);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ static inline bool accel_irqchip_is_split(void)
|
|||
return mshv_msi_via_irqfd_enabled() || kvm_irqchip_is_split();
|
||||
}
|
||||
|
||||
AccelRouteChange accel_irqchip_begin_route_changes(void);
|
||||
int accel_irqchip_add_msi_route(AccelRouteChange *c, int vector,
|
||||
PCIDevice *dev);
|
||||
int accel_irqchip_update_msi_route(int vector, MSIMessage msg, PCIDevice *dev);
|
||||
|
|
|
|||
|
|
@ -476,14 +476,6 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
|
|||
PCIDevice *dev);
|
||||
void kvm_irqchip_commit_routes(KVMState *s);
|
||||
|
||||
static inline AccelRouteChange kvm_irqchip_begin_route_changes(KVMState *s)
|
||||
{
|
||||
return (AccelRouteChange) {
|
||||
.accel = ACCEL(s),
|
||||
.changes = 0,
|
||||
};
|
||||
}
|
||||
|
||||
static inline void kvm_irqchip_commit_route_changes(AccelRouteChange *c)
|
||||
{
|
||||
if (c->changes) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "vmsr_energy.h"
|
||||
#include "system/system.h"
|
||||
#include "system/hw_accel.h"
|
||||
#include "system/accel-irq.h"
|
||||
#include "system/kvm_int.h"
|
||||
#include "system/runstate.h"
|
||||
#include "system/ramblock.h"
|
||||
|
|
@ -6678,7 +6679,7 @@ void kvm_arch_init_irq_routing(KVMState *s)
|
|||
kvm_gsi_routing_allowed = true;
|
||||
|
||||
if (kvm_irqchip_is_split()) {
|
||||
AccelRouteChange c = kvm_irqchip_begin_route_changes(s);
|
||||
AccelRouteChange c = accel_irqchip_begin_route_changes();
|
||||
int i;
|
||||
|
||||
/* If the ioapic is in QEMU and the lapics are in KVM, reserve
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue