public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] uio/uio_pci_generic: don't fail probe if pdev->irq == NULL
@ 2017-05-02 14:20 Jim Harris
  2017-05-09 12:02 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Harris @ 2017-05-02 14:20 UTC (permalink / raw)
  To: mst, kvm; +Cc: gregkh, keith.busch, jonathan.derrick, Jim Harris

Some userspace drivers and frameworks only poll and do not
require interrupts to be available and enabled on the
PCI device.  So remove the requirement that an IRQ is
assigned.  If an IRQ is not assigned and a userspace
driver tries to read()/write(), the generic uio
framework will just return -EIO.

This allows binding uio_pci_generic to devices which
cannot get an IRQ assigned, such as an NVMe controller
behind Intel Volume Management Device (VMD), since VMD
does not support INTx interrupts.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
---
 drivers/uio/uio_pci_generic.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
index d0b508b68f3c..a56fdf972dbe 100644
--- a/drivers/uio/uio_pci_generic.c
+++ b/drivers/uio/uio_pci_generic.c
@@ -66,14 +66,7 @@ static int probe(struct pci_dev *pdev,
 		return err;
 	}
 
-	if (!pdev->irq) {
-		dev_warn(&pdev->dev, "No IRQ assigned to device: "
-			 "no support for interrupts?\n");
-		pci_disable_device(pdev);
-		return -ENODEV;
-	}
-
-	if (!pci_intx_mask_supported(pdev)) {
+	if (pdev->irq && !pci_intx_mask_supported(pdev)) {
 		err = -ENODEV;
 		goto err_verify;
 	}
@@ -86,10 +79,15 @@ static int probe(struct pci_dev *pdev,
 
 	gdev->info.name = "uio_pci_generic";
 	gdev->info.version = DRIVER_VERSION;
-	gdev->info.irq = pdev->irq;
-	gdev->info.irq_flags = IRQF_SHARED;
-	gdev->info.handler = irqhandler;
 	gdev->pdev = pdev;
+	if (pdev->irq) {
+		gdev->info.irq = pdev->irq;
+		gdev->info.irq_flags = IRQF_SHARED;
+		gdev->info.handler = irqhandler;
+	} else {
+		dev_warn(&pdev->dev, "No IRQ assigned to device: "
+			 "no support for interrupts?\n");
+	}
 
 	err = uio_register_device(&pdev->dev, &gdev->info);
 	if (err)
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] uio/uio_pci_generic: don't fail probe if pdev->irq == NULL
  2017-05-02 14:20 [PATCH v2] uio/uio_pci_generic: don't fail probe if pdev->irq == NULL Jim Harris
@ 2017-05-09 12:02 ` Michael S. Tsirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2017-05-09 12:02 UTC (permalink / raw)
  To: Jim Harris; +Cc: kvm, gregkh, keith.busch, jonathan.derrick

On Tue, May 02, 2017 at 07:20:59AM -0700, Jim Harris wrote:
> Some userspace drivers and frameworks only poll and do not
> require interrupts to be available and enabled on the
> PCI device.  So remove the requirement that an IRQ is
> assigned.  If an IRQ is not assigned and a userspace
> driver tries to read()/write(), the generic uio
> framework will just return -EIO.
> 
> This allows binding uio_pci_generic to devices which
> cannot get an IRQ assigned, such as an NVMe controller
> behind Intel Volume Management Device (VMD), since VMD
> does not support INTx interrupts.
> 
> Signed-off-by: Jim Harris <james.r.harris@intel.com>


I'm still not sure why such a stub is useful, but it seems
harmless.

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  drivers/uio/uio_pci_generic.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
> index d0b508b68f3c..a56fdf972dbe 100644
> --- a/drivers/uio/uio_pci_generic.c
> +++ b/drivers/uio/uio_pci_generic.c
> @@ -66,14 +66,7 @@ static int probe(struct pci_dev *pdev,
>  		return err;
>  	}
>  
> -	if (!pdev->irq) {
> -		dev_warn(&pdev->dev, "No IRQ assigned to device: "
> -			 "no support for interrupts?\n");
> -		pci_disable_device(pdev);
> -		return -ENODEV;
> -	}
> -
> -	if (!pci_intx_mask_supported(pdev)) {
> +	if (pdev->irq && !pci_intx_mask_supported(pdev)) {
>  		err = -ENODEV;
>  		goto err_verify;
>  	}
> @@ -86,10 +79,15 @@ static int probe(struct pci_dev *pdev,
>  
>  	gdev->info.name = "uio_pci_generic";
>  	gdev->info.version = DRIVER_VERSION;
> -	gdev->info.irq = pdev->irq;
> -	gdev->info.irq_flags = IRQF_SHARED;
> -	gdev->info.handler = irqhandler;
>  	gdev->pdev = pdev;
> +	if (pdev->irq) {
> +		gdev->info.irq = pdev->irq;
> +		gdev->info.irq_flags = IRQF_SHARED;
> +		gdev->info.handler = irqhandler;
> +	} else {
> +		dev_warn(&pdev->dev, "No IRQ assigned to device: "
> +			 "no support for interrupts?\n");
> +	}
>  
>  	err = uio_register_device(&pdev->dev, &gdev->info);
>  	if (err)
> -- 
> 2.12.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-09 12:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-02 14:20 [PATCH v2] uio/uio_pci_generic: don't fail probe if pdev->irq == NULL Jim Harris
2017-05-09 12:02 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox