mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
kvm/msi: do explicit commit when adding msi routes
We invoke the kvm_irqchip_commit_routes() for each addition to MSI route table, which is not efficient if we are adding lots of routes in some cases. This patch lets callers invoke the kvm_irqchip_commit_routes(), so the callers can decide how to optimize. [1] https://lists.gnu.org/archive/html/qemu-devel/2021-11/msg00967.html Signed-off-by: Longpeng <longpeng2@huawei.com> Message-Id: <20220222141116.2091-3-longpeng2@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
9568690868
commit
def4c5570c
7 changed files with 21 additions and 10 deletions
|
@ -424,16 +424,19 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, int vector,
|
|||
Error **errp)
|
||||
{
|
||||
PCIDevice *pdev = PCI_DEVICE(s);
|
||||
KVMRouteChange c;
|
||||
int ret;
|
||||
|
||||
IVSHMEM_DPRINTF("ivshmem_add_kvm_msi_virq vector:%d\n", vector);
|
||||
assert(!s->msi_vectors[vector].pdev);
|
||||
|
||||
ret = kvm_irqchip_add_msi_route(kvm_state, vector, pdev);
|
||||
c = kvm_irqchip_begin_route_changes(kvm_state);
|
||||
ret = kvm_irqchip_add_msi_route(&c, vector, pdev);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "kvm_irqchip_add_msi_route failed");
|
||||
return;
|
||||
}
|
||||
kvm_irqchip_commit_route_changes(&c);
|
||||
|
||||
s->msi_vectors[vector].virq = ret;
|
||||
s->msi_vectors[vector].pdev = pdev;
|
||||
|
|
|
@ -412,6 +412,7 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
|||
static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector,
|
||||
int vector_n, bool msix)
|
||||
{
|
||||
KVMRouteChange c;
|
||||
int virq;
|
||||
|
||||
if ((msix && vdev->no_kvm_msix) || (!msix && vdev->no_kvm_msi)) {
|
||||
|
@ -422,11 +423,13 @@ static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector,
|
|||
return;
|
||||
}
|
||||
|
||||
virq = kvm_irqchip_add_msi_route(kvm_state, vector_n, &vdev->pdev);
|
||||
c = kvm_irqchip_begin_route_changes(kvm_state);
|
||||
virq = kvm_irqchip_add_msi_route(&c, vector_n, &vdev->pdev);
|
||||
if (virq < 0) {
|
||||
event_notifier_cleanup(&vector->kvm_interrupt);
|
||||
return;
|
||||
}
|
||||
kvm_irqchip_commit_route_changes(&c);
|
||||
|
||||
if (kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, &vector->kvm_interrupt,
|
||||
NULL, virq) < 0) {
|
||||
|
|
|
@ -683,10 +683,12 @@ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,
|
|||
int ret;
|
||||
|
||||
if (irqfd->users == 0) {
|
||||
ret = kvm_irqchip_add_msi_route(kvm_state, vector, &proxy->pci_dev);
|
||||
KVMRouteChange c = kvm_irqchip_begin_route_changes(kvm_state);
|
||||
ret = kvm_irqchip_add_msi_route(&c, vector, &proxy->pci_dev);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
kvm_irqchip_commit_route_changes(&c);
|
||||
irqfd->virq = ret;
|
||||
}
|
||||
irqfd->users++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue