From patchwork Sun May 8 02:14:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 764972 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p482Fkw5021813 for ; Sun, 8 May 2011 02:15:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751197Ab1EHCPa (ORCPT ); Sat, 7 May 2011 22:15:30 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:60318 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155Ab1EHCPa (ORCPT ); Sat, 7 May 2011 22:15:30 -0400 Received: by pzk9 with SMTP id 9so1919087pzk.19 for ; Sat, 07 May 2011 19:15:29 -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; bh=FvnP3TrmjFQuyt+mmcfcEQ8i1kJi9EMDteGPpYGr0Lo=; b=x+ro9LyzKE+kfifP++HL50DUx4mu03ZzyA2KuxKyEXQeHDIK0JBEqiM1qhRIZMvyDw d3HdiewMwnmJhFhtyG53KLRjvgBaQqcMbQ78hA0D8ZceL9e69HUkpvhuTchVOcQ1yv7o QdRO+B/CjfQ6ydPwvo/jnyzd1AaWfE9aYkvXU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=mHrqNpNzWs5S5Qtty5i8wHhtTHtygh5UHJlzPc6/4Td4WRKbIVpPG+VyRtPdFQoVJ+ aaDF6W60kly7C5pVjLcFuKtKQVZE8tfKfS+/8zhRJAi1kJCi7yAEKefg1pBzjPzF2ymF NJuJGUqWtXMSJQVWuUSS1rc5Sjx3ZH0Y4p5U0= Received: by 10.142.218.21 with SMTP id q21mr3128256wfg.247.1304820929678; Sat, 07 May 2011 19:15:29 -0700 (PDT) Received: from localhost.localdomain ([202.112.128.133]) by mx.google.com with ESMTPS id z10sm6192308wfj.15.2011.05.07.19.15.24 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 07 May 2011 19:15:28 -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 1/3] kvm tools: Use virt_queue__trigger_irq() to trigger IRQ for virtio console Date: Sun, 8 May 2011 10:14:05 +0800 Message-Id: <1304820847-13125-1-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.1 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 (demeter2.kernel.org [140.211.167.43]); Sun, 08 May 2011 02:15:46 +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)