diff mbox

[v2] uio/uio_pci_generic: don't fail probe if pdev->irq == NULL

Message ID 20170502142059.34452-1-james.r.harris@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Harris, James R May 2, 2017, 2:20 p.m. UTC
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(-)

Comments

Michael S. Tsirkin May 9, 2017, 12:02 p.m. UTC | #1
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
diff mbox

Patch

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)