[PATCH 1/3] kvm tools: Use virt_queue__trigger_irq() to trigger IRQ for virtio console

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch uses IRQ injection mechanism introduced by
virt_queue__trigger_irq() which respect virtio IRQ status
and VRING_AVAIL_F_NO_INTERRUPT.

Signed-off-by: Asias He <asias.hejun@xxxxxxxxx>
---
 tools/kvm/virtio/console.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c
index 188227b..f5449ba 100644
--- a/tools/kvm/virtio/console.c
+++ b/tools/kvm/virtio/console.c
@@ -49,6 +49,7 @@ struct con_dev {
 	u32				guest_features;
 	u16				config_vector;
 	u8				status;
+	u8				isr;
 	u16				queue_selector;
 
 	void				*jobs[VIRTIO_CONSOLE_NUM_QUEUES];
@@ -85,7 +86,7 @@ static void virtio_console__inject_interrupt_callback(struct kvm *self, void *pa
 		head = virt_queue__get_iov(vq, iov, &out, &in, self);
 		len = term_getc_iov(CONSOLE_VIRTIO, iov, in);
 		virt_queue__set_used_elem(vq, head, len);
-		kvm__irq_line(self, virtio_console_pci_device.irq_line, 1);
+		virt_queue__trigger_irq(vq, virtio_console_pci_device.irq_line, &cdev.isr, self);
 	}
 
 	mutex_unlock(&cdev.mutex);
@@ -139,8 +140,9 @@ static bool virtio_console_pci_io_in(struct kvm *self, u16 port, void *data, int
 		ioport__write8(data, cdev.status);
 		break;
 	case VIRTIO_PCI_ISR:
-		ioport__write8(data, 0x1);
-		kvm__irq_line(self, virtio_console_pci_device.irq_line, 0);
+		ioport__write8(data, cdev.isr);
+		kvm__irq_line(self, virtio_console_pci_device.irq_line, VIRTIO_IRQ_LOW);
+		cdev.isr = VIRTIO_IRQ_LOW;
 		break;
 	case VIRTIO_MSI_CONFIG_VECTOR:
 		ioport__write16(data, cdev.config_vector);
@@ -170,7 +172,7 @@ static void virtio_console_handle_callback(struct kvm *self, void *param)
 		virt_queue__set_used_elem(vq, head, len);
 	}
 
-	kvm__irq_line(self, virtio_console_pci_device.irq_line, 1);
+	virt_queue__trigger_irq(vq, virtio_console_pci_device.irq_line, &cdev.isr, self);
 }
 
 static bool virtio_console_pci_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)
-- 
1.7.5.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux