From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH] uio: add irq control support to uio_pci_generic Date: Thu, 16 Apr 2015 09:43:24 +0200 Message-ID: <20150416094105-mutt-send-email-mst@redhat.com> References: <20150415095934.09966367@urahara> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Hans J. Koch" , Greg Kroah-Hartman , kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Stephen Hemminger Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52125 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbbDPHn2 (ORCPT ); Thu, 16 Apr 2015 03:43:28 -0400 Content-Disposition: inline In-Reply-To: <20150415095934.09966367@urahara> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Apr 15, 2015 at 09:59:34AM -0700, Stephen Hemminger wrote: > The driver already supported INTX interrupts but had no in kernel > function to enable and disable them. > > It is possible for userspace to do this by accessing PCI config > directly, but this racy How is it racy? We have userspace using this interface, if there's a race I want to fix it. > and better handled by same mechanism > that already exists in kernel. > > Signed-off-by: Stephen Hemminger > > > --- a/drivers/uio/uio_pci_generic.c 2015-04-15 08:50:15.543900681 -0700 > +++ b/drivers/uio/uio_pci_generic.c 2015-04-15 09:00:01.658609786 -0700 > @@ -53,6 +53,18 @@ static irqreturn_t irqhandler(int irq, s > return IRQ_HANDLED; > } > > +static int irqcontrol(struct uio_info *info, s32 irq_on) > +{ > + struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info); > + struct pci_dev *pdev = gdev->pdev; > + > + pci_cfg_access_lock(pdev); > + pci_intx(pdev, irq_on); > + pci_cfg_access_unlock(pdev); > + > + return 0; > +} > + > static int probe(struct pci_dev *pdev, > const struct pci_device_id *id) > { > @@ -89,6 +101,7 @@ static int probe(struct pci_dev *pdev, > gdev->info.irq = pdev->irq; > gdev->info.irq_flags = IRQF_SHARED; > gdev->info.handler = irqhandler; > + gdev->info.irqcontrol = irqcontrol; > gdev->pdev = pdev; > > err = uio_register_device(&pdev->dev, &gdev->info);