From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH corrected RFC] uio: add generic driver for PCI 2.3 devices Date: Thu, 09 Jul 2009 09:54:43 -0500 Message-ID: <4A5604B3.2090508@codemonkey.ws> References: <20090709114834.GB26479@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, avi@redhat.com To: "Michael S. Tsirkin" Return-path: Received: from rv-out-0506.google.com ([209.85.198.228]:63288 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759180AbZGIPCB (ORCPT ); Thu, 9 Jul 2009 11:02:01 -0400 Received: by rv-out-0506.google.com with SMTP id f6so52504rvb.1 for ; Thu, 09 Jul 2009 08:02:00 -0700 (PDT) In-Reply-To: <20090709114834.GB26479@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Michael S. Tsirkin wrote: > Resending with corrected addresses. Sorry about the churn. > > ----------- > > I got annoyed by the fact that we don't support shared interrupts > with PCI in assigned devides, so here's a draft patch to add that > support in kernel through uio. > > I intend to send this to lkml, but meanwhile I'd appreciate some early > feedback/flames from people on the list. > > Thanks! > > > -----------> > > This adds a generic uio driver that can bind to any PCI device. First > user will be virtualization where a qemu userspace process needs to give > guest OS access to the device. > > Interrupts are handled using the Interrupt Disable bit in the PCI command > register and Interrupt Status bit in the PCI status register. All devices > compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should > support these bits. Driver detects this support, and won't bind to devices > which do not support the Interrupt Disable Bit in the command register. > > It's expected that MSI/MSI-X support will be added to this driver in the > future, to interface with virtualization irqfd/eventfd infrastructure. > Another area to examine, and of interest to virtualization, is iommu. > > Signed-off-by: Michael S. Tsirkin > I didn't know this was possible... so we could also use this driver for vm-channel. > + > + err = pci_request_regions(pdev, "uio_pci_generic"); > + if (err) { > + dev_err(&pdev->dev, "%s: pci_request_regions failed: %d\n", > + __func__, err); > + goto err_verify; > + } > + > + dev = kzalloc(sizeof(struct generic_dev), GFP_KERNEL); > + if (!dev) { > + err = -ENOMEM; > + goto err_alloc; > + } > + > + dev->info.name = "uio_pci_generic"; > + dev->info.version = "0.01"; > + dev->info.irq = pdev->irq; > + dev->info.irq_flags = IRQF_SHARED; > + dev->info.handler = irqhandler; > + dev->info.irqcontrol = irqcontrol; > + dev->pdev = pdev; > + spin_lock_init(&dev->lock) > I know it's not strictly needed for PCI pass through, but it would be useful to register the IO regions via UIO. The userspace implementation would then use UIO strictly instead of poking the sysfs pci info directly. I think that ends up being cleaner. Regards, ANthony Liguori