From patchwork Sun May 8 13:09:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 765772 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 p48DBQCW011687 for ; Sun, 8 May 2011 13:11:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753277Ab1EHNLX (ORCPT ); Sun, 8 May 2011 09:11:23 -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 S1753084Ab1EHNLW (ORCPT ); Sun, 8 May 2011 09:11:22 -0400 Received: by mail-pz0-f46.google.com with SMTP id 9so2015354pzk.19 for ; Sun, 08 May 2011 06:11:22 -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=B8qMY6Yvf93obrSsFe/CIvuDFPSGqboXGEADYhm0++A=; b=fXEchMA4PZk1mfMtsa093r4Yz91LbbpLlAYtV9vdLfSn0yqrLH1LCtRnXluUgX0+zs 8xTCNX1Sax4eZjzsMi7MtrNgn1cSuXvK4YikpdK2zRMf+H5FH1thH2Tu2lNXtFf7Ojb/ RIB5G+6y6KfGAFgK6Gr3BJtxM5E85+RjoTU8Y= 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=iFHNIGOXOBVIlaNVnSMVT1zXeNCa7ylZmB7jH5B/5maXwt8OATfr/QeJlLYNQM+N9Z mh9SzIniW5suFE+EsHOscc1Um1tyPDPsaqMcJckK3BmKy7R73COrJZPeSZUwZ3K0mceD V+9zUcHcfM89mub+NscwIu9VOpfyT2/kcfnUw= Received: by 10.68.14.164 with SMTP id q4mr8095609pbc.352.1304860282403; Sun, 08 May 2011 06:11:22 -0700 (PDT) Received: from localhost.localdomain ([202.112.128.133]) by mx.google.com with ESMTPS id y7sm3442117pbk.30.2011.05.08.06.11.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 May 2011 06:11:21 -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 3/4] kvm tools: Use virt_queue__trigger_irq() to trigger IRQ for virtio rng Date: Sun, 8 May 2011 21:09:24 +0800 Message-Id: <1304860165-28810-4-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:26 +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/rng.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c index d355cf8..f692dfd 100644 --- a/tools/kvm/virtio/rng.c +++ b/tools/kvm/virtio/rng.c @@ -37,6 +37,7 @@ static struct pci_device_header virtio_rng_pci_device = { struct rng_dev { u8 status; + u8 isr; u16 config_vector; int fd; @@ -72,8 +73,9 @@ static bool virtio_rng_pci_io_in(struct kvm *kvm, u16 port, void *data, int size ioport__write8(data, rdev.status); break; case VIRTIO_PCI_ISR: - ioport__write8(data, 0x1); - kvm__irq_line(kvm, virtio_rng_pci_device.irq_line, 0); + ioport__write8(data, rdev.isr); + kvm__irq_line(kvm, virtio_rng_pci_device.irq_line, VIRTIO_IRQ_LOW); + rdev.isr = VIRTIO_IRQ_LOW; break; case VIRTIO_MSI_CONFIG_VECTOR: ioport__write16(data, rdev.config_vector); @@ -106,7 +108,7 @@ static void virtio_rng_do_io(struct kvm *kvm, void *param) while (virt_queue__available(vq)) { virtio_rng_do_io_request(kvm, vq); - kvm__irq_line(kvm, virtio_rng_pci_device.irq_line, 1); + virt_queue__trigger_irq(vq, virtio_rng_pci_device.irq_line, &rdev.isr, kvm); } }