From patchwork Sat Oct 30 16:59:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 292152 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 o9UGxlV0031473 for ; Sat, 30 Oct 2010 16:59:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755789Ab0J3Q7m (ORCPT ); Sat, 30 Oct 2010 12:59:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16681 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755698Ab0J3Q7k (ORCPT ); Sat, 30 Oct 2010 12:59:40 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9UGxdcr016563 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 30 Oct 2010 12:59:40 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9UGxce8023160; Sat, 30 Oct 2010 12:59:39 -0400 From: Alex Williamson Subject: [PATCH 3/5] vfio: Add ioctl to re-enable interrupts To: pugs@cisco.com Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, avi@redhat.com, chrisw@redhat.com, mst@redhat.com, alex.williamson@redhat.com Date: Sat, 30 Oct 2010 10:59:38 -0600 Message-ID: <20101030165929.885.47408.stgit@s20.home> In-Reply-To: <20101030164626.885.89216.stgit@s20.home> References: <20101030164626.885.89216.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 30 Oct 2010 16:59:48 +0000 (UTC) diff --git a/drivers/vfio/vfio_intrs.c b/drivers/vfio/vfio_intrs.c index aaee175..a57d5aa 100644 --- a/drivers/vfio/vfio_intrs.c +++ b/drivers/vfio/vfio_intrs.c @@ -83,6 +83,23 @@ done: return ret; } +int vfio_irq_eoi(struct vfio_dev *vdev) +{ + struct pci_dev *pdev = vdev->pdev; + u16 cmd; + + spin_lock_irq(&vdev->irqlock); + pci_block_user_cfg_access(pdev); + + pci_read_config_word(pdev, PCI_COMMAND, &cmd); + cmd &= ~PCI_COMMAND_INTX_DISABLE; + pci_write_config_word(pdev, PCI_COMMAND, cmd); + + pci_unblock_user_cfg_access(pdev); + spin_unlock_irq(&vdev->irqlock); + return 0; +} + /* * MSI and MSI-X Interrupt handler. * Just signal an event diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index f671795..72db79c 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -464,6 +464,10 @@ static long vfio_unl_ioctl(struct file *filep, ret = vfio_domain_unset(vdev); break; + case VFIO_IRQ_EOI: + ret = vfio_irq_eoi(vdev); + break; + default: return -EINVAL; } diff --git a/include/linux/vfio.h b/include/linux/vfio.h index c491180..73d7e84 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -155,6 +155,7 @@ void vfio_error_resume(struct pci_dev *); #define VFIO_SUSPEND_REPLY_TIMEOUT (5*HZ) irqreturn_t vfio_interrupt(int, void *); +int vfio_irq_eoi(struct vfio_dev *); #endif /* __KERNEL__ */ @@ -198,6 +199,8 @@ struct vfio_dma_map { /* Unset the IOMMU domain */ #define VFIO_DOMAIN_UNSET _IO(';', 108) +/* Re-enable INTx */ +#define VFIO_IRQ_EOI _IO(';', 109) /* * Reads, writes, and mmaps determine which PCI BAR (or config space) * from the high level bits of the file offset