From patchwork Sun May 8 13:09:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 765762 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p48DBFxc011594 for ; Sun, 8 May 2011 13:11:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752937Ab1EHNLL (ORCPT ); Sun, 8 May 2011 09:11:11 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:53843 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751185Ab1EHNLE (ORCPT ); Sun, 8 May 2011 09:11:04 -0400 Received: by mail-pz0-f46.google.com with SMTP id 9so2015354pzk.19 for ; Sun, 08 May 2011 06:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=FvnP3TrmjFQuyt+mmcfcEQ8i1kJi9EMDteGPpYGr0Lo=; b=EbAWyCSkEIvoHfjtrDr1O7ZjsehsSrDEey+DSVZoj1el1aeidnbb77RA81Am7YYpLt fF9Tmj67vEfnu8+VWf6YSMMyVwMi+S1nwjtYuH1YVaz16IP1lUPfKM9hFo1xtc0WZdtM xbp2JQvJWnTciv7Ksyk7Ug3coviuJtNry3QvY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=rLuAyZolgqns7NbtJwgxvs7DkYOum5JntWatIjOXjl5UuBB9l8qEX9JYig+VyvaLWj dge1/JqoP3HPdS6Jmz28U+Mf7ZYysaubBI059aHb6lFbEN3xi4sSHqkpXiSxWQy3wuAw tBNfUHGlgi0YzGDICM9+TQtc/SsYh4NwLIa/o= Received: by 10.68.65.40 with SMTP id u8mr5935344pbs.229.1304860264495; Sun, 08 May 2011 06:11:04 -0700 (PDT) Received: from localhost.localdomain ([202.112.128.133]) by mx.google.com with ESMTPS id y7sm3442117pbk.30.2011.05.08.06.10.56 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 May 2011 06:11:03 -0700 (PDT) From: Asias He To: Pekka Enberg , Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi Cc: kvm@vger.kernel.org, Asias He Subject: [PATCH v2 1/4] kvm tools: Use virt_queue__trigger_irq() to trigger IRQ for virtio console Date: Sun, 8 May 2011 21:09:22 +0800 Message-Id: <1304860165-28810-2-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1304860165-28810-1-git-send-email-asias.hejun@gmail.com> References: <1304860165-28810-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 08 May 2011 13:11:19 +0000 (UTC) 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 --- 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)