From 68919cace8242363edfe8ff9b9c68b5e58c30db4 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 7 Oct 2013 10:36:38 +0300 Subject: hw/vfio: set interrupts using pci irq wrappers pci_set_irq and the other pci irq wrappers use PCI_INTERRUPT_PIN config register to compute device INTx pin to assert/deassert. save INTX pin into the config register before calling pci_set_irq Signed-off-by: Marcel Apfelbaum Signed-off-by: Michael S. Tsirkin --- hw/misc/vfio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'hw/misc') diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index a1c08fb74e..9d02e49a3e 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -297,7 +297,7 @@ static void vfio_intx_interrupt(void *opaque) 'A' + vdev->intx.pin); vdev->intx.pending = true; - qemu_set_irq(vdev->pdev.irq[vdev->intx.pin], 1); + pci_irq_assert(&vdev->pdev); vfio_mmap_set_enabled(vdev, false); if (vdev->intx.mmap_timeout) { timer_mod(vdev->intx.mmap_timer, @@ -315,7 +315,7 @@ static void vfio_eoi(VFIODevice *vdev) vdev->host.bus, vdev->host.slot, vdev->host.function); vdev->intx.pending = false; - qemu_set_irq(vdev->pdev.irq[vdev->intx.pin], 0); + pci_irq_deassert(&vdev->pdev); vfio_unmask_intx(vdev); } @@ -341,7 +341,7 @@ static void vfio_enable_intx_kvm(VFIODevice *vdev) qemu_set_fd_handler(irqfd.fd, NULL, NULL, vdev); vfio_mask_intx(vdev); vdev->intx.pending = false; - qemu_set_irq(vdev->pdev.irq[vdev->intx.pin], 0); + pci_irq_deassert(&vdev->pdev); /* Get an eventfd for resample/unmask */ if (event_notifier_init(&vdev->intx.unmask, 0)) { @@ -417,7 +417,7 @@ static void vfio_disable_intx_kvm(VFIODevice *vdev) */ vfio_mask_intx(vdev); vdev->intx.pending = false; - qemu_set_irq(vdev->pdev.irq[vdev->intx.pin], 0); + pci_irq_deassert(&vdev->pdev); /* Tell KVM to stop listening for an INTx irqfd */ if (kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd)) { @@ -488,6 +488,7 @@ static int vfio_enable_intx(VFIODevice *vdev) vfio_disable_interrupts(vdev); vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */ + pci_config_set_interrupt_pin(vdev->pdev.config, pin); #ifdef CONFIG_KVM /* @@ -547,7 +548,7 @@ static void vfio_disable_intx(VFIODevice *vdev) vfio_disable_intx_kvm(vdev); vfio_disable_irqindex(vdev, VFIO_PCI_INTX_IRQ_INDEX); vdev->intx.pending = false; - qemu_set_irq(vdev->pdev.irq[vdev->intx.pin], 0); + pci_irq_deassert(&vdev->pdev); vfio_mmap_set_enabled(vdev, true); fd = event_notifier_get_fd(&vdev->intx.interrupt); -- cgit v1.2.1 From 9e64f8a3fcc88a508990a62ecc5a1269e41272ad Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 7 Oct 2013 10:36:39 +0300 Subject: hw: set interrupts using pci irq wrappers pci_set_irq and the other pci irq wrappers use PCI_INTERRUPT_PIN config register to compute device INTx pin to assert/deassert. An irq is allocated using pci_allocate_irq wrapper only if is needed by non pci devices. Removed irq related fields from state if not used anymore. Signed-off-by: Marcel Apfelbaum Signed-off-by: Michael S. Tsirkin --- hw/misc/ivshmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/misc') diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 2838866f45..8d144baa1e 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -133,7 +133,7 @@ static void ivshmem_update_irq(IVShmemState *s, int val) isr ? 1 : 0, s->intrstatus, s->intrmask); } - qemu_set_irq(d->irq[0], (isr != 0)); + pci_set_irq(d, (isr != 0)); } static void ivshmem_IntrMask_write(IVShmemState *s, uint32_t val) -- cgit v1.2.1 From 309cd62d6b2628b4f0e2850b42011077f40956c7 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 24 Jul 2013 18:56:12 +0300 Subject: pvpanic: add API to access io port Add API to find pvpanic device and get its io port. Will be used to fill in guest info structure. Reviewed-by: Gerd Hoffmann Tested-by: Gerd Hoffmann Reviewed-by: Igor Mammedov Tested-by: Igor Mammedov Signed-off-by: Michael S. Tsirkin --- hw/misc/pvpanic.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'hw/misc') diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index b64e3bb7b4..226e2983d3 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -117,8 +117,19 @@ void pvpanic_init(ISABus *bus) isa_create_simple(bus, TYPE_ISA_PVPANIC_DEVICE); } +#define PVPANIC_IOPORT_PROP "ioport" + +uint16_t pvpanic_port(void) +{ + Object *o = object_resolve_path_type("", TYPE_ISA_PVPANIC_DEVICE, NULL); + if (!o) { + return 0; + } + return object_property_get_int(o, PVPANIC_IOPORT_PROP, NULL); +} + static Property pvpanic_isa_properties[] = { - DEFINE_PROP_UINT16("ioport", PVPanicState, ioport, 0x505), + DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505), DEFINE_PROP_END_OF_LIST(), }; -- cgit v1.2.1