From patchwork Wed Mar 17 13:04:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 86331 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2HD8MQu024738 for ; Wed, 17 Mar 2010 13:08:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754791Ab0CQNIV (ORCPT ); Wed, 17 Mar 2010 09:08:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754366Ab0CQNIU (ORCPT ); Wed, 17 Mar 2010 09:08:20 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2HD8Jkd026676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Mar 2010 09:08:20 -0400 Received: from redhat.com (vpn1-6-114.ams2.redhat.com [10.36.6.114]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o2HD8Ihh014248 for ; Wed, 17 Mar 2010 09:08:18 -0400 Date: Wed, 17 Mar 2010 15:04:55 +0200 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org Subject: [PATCHv6 4/4] virtio-pci: irqfd support Message-ID: <3b54c6173ecb5e80ddead220c76e6d950ffd67e8.1268831034.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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.3 (demeter.kernel.org [140.211.167.41]); Wed, 17 Mar 2010 13:08:23 +0000 (UTC) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 4255d98..f8d8022 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -402,6 +402,27 @@ static void virtio_pci_guest_notifier_read(void *opaque) } } +static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector, + void *opaque, int masked) +{ + VirtQueue *vq = opaque; + EventNotifier *notifier = virtio_queue_get_guest_notifier(vq); + int r = kvm_set_irqfd(dev->msix_irq_entries[vector].gsi, + event_notifier_get_fd(notifier), + !masked); + if (r < 0) { + return (r == -ENOSYS) ? 0 : r; + } + if (masked) { + qemu_set_fd_handler(event_notifier_get_fd(notifier), + virtio_pci_guest_notifier_read, NULL, vq); + } else { + qemu_set_fd_handler(event_notifier_get_fd(notifier), + NULL, NULL, NULL); + } + return 0; +} + static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign) { VirtIOPCIProxy *proxy = opaque; @@ -415,7 +436,11 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign) } qemu_set_fd_handler(event_notifier_get_fd(notifier), virtio_pci_guest_notifier_read, NULL, vq); + msix_set_mask_notifier(&proxy->pci_dev, + virtio_queue_vector(proxy->vdev, n), vq); } else { + msix_set_mask_notifier(&proxy->pci_dev, + virtio_queue_vector(proxy->vdev, n), NULL); qemu_set_fd_handler(event_notifier_get_fd(notifier), NULL, NULL, NULL); event_notifier_cleanup(notifier); @@ -500,6 +525,8 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, proxy->pci_dev.config_write = virtio_write_config; + proxy->pci_dev.msix_mask_notifier = virtio_pci_mask_notifier; + size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) + vdev->config_len; if (size & (size-1)) size = 1 << qemu_fls(size);