mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 06:43:53 -06:00
vfio: refactor out IRQ signalling setup
This makes for a slightly more readable vfio_msix_vector_do_use() implementation, and we will rely on this shortly. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250520150419.2172078-5-john.levon@nutanix.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
1539945946
commit
a483ad5347
1 changed files with 20 additions and 15 deletions
|
@ -511,6 +511,25 @@ static void vfio_update_kvm_msi_virq(VFIOMSIVector *vector, MSIMessage msg,
|
|||
kvm_irqchip_commit_routes(kvm_state);
|
||||
}
|
||||
|
||||
static void set_irq_signalling(VFIODevice *vbasedev, VFIOMSIVector *vector,
|
||||
unsigned int nr)
|
||||
{
|
||||
Error *err = NULL;
|
||||
int32_t fd;
|
||||
|
||||
if (vector->virq >= 0) {
|
||||
fd = event_notifier_get_fd(&vector->kvm_interrupt);
|
||||
} else {
|
||||
fd = event_notifier_get_fd(&vector->interrupt);
|
||||
}
|
||||
|
||||
if (!vfio_device_irq_set_signaling(vbasedev, VFIO_PCI_MSIX_IRQ_INDEX, nr,
|
||||
VFIO_IRQ_SET_ACTION_TRIGGER,
|
||||
fd, &err)) {
|
||||
error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name);
|
||||
}
|
||||
}
|
||||
|
||||
static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
|
||||
MSIMessage *msg, IOHandler *handler)
|
||||
{
|
||||
|
@ -583,21 +602,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
|
|||
strerror(-ret));
|
||||
}
|
||||
} else {
|
||||
Error *err = NULL;
|
||||
int32_t fd;
|
||||
|
||||
if (vector->virq >= 0) {
|
||||
fd = event_notifier_get_fd(&vector->kvm_interrupt);
|
||||
} else {
|
||||
fd = event_notifier_get_fd(&vector->interrupt);
|
||||
}
|
||||
|
||||
if (!vfio_device_irq_set_signaling(&vdev->vbasedev,
|
||||
VFIO_PCI_MSIX_IRQ_INDEX, nr,
|
||||
VFIO_IRQ_SET_ACTION_TRIGGER, fd,
|
||||
&err)) {
|
||||
error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
|
||||
}
|
||||
set_irq_signalling(&vdev->vbasedev, vector, nr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue