Skip to content

Commit

Permalink
virtio_pci: use irq to detect interrupt support
Browse files Browse the repository at this point in the history
commit 71491c5 ("virtio_pci: don't try to use intxif pin is zero")
breaks virtio_pci on powerpc, when running as a qemu guest.

vp_find_vqs() bails out because pci_dev->pin == 0.

But pci_dev->irq is populated correctly, so vp_find_vqs_intx() would
succeed if we called it - which is what the code used to do.

This seems to happen because pci_dev->pin is not populated in
pci_assign_irq(). A PCI core bug? Maybe.

However Linus said:
	I really think that that is basically the only time you should use
	that 'pci_dev->pin' thing: it basically exists not for "does this
	device have an IRQ", but for "what is the routing of this irq on this
	device".

and
	The correct way to check for "no irq" doesn't use NO_IRQ at all, it just does
		if (dev->irq) ...

so let's just check irq and be done with it.

Suggested-by: Linus Torvalds <[email protected]>
Reported-by: Michael Ellerman <[email protected]>
Fixes: 71491c5 ("virtio_pci: don't try to use intxif pin is zero")
Cc: "Angus Chen" <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Tested-by: Michael Ellerman <[email protected]>
Acked-by: Jason Wang <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
mstsirkin committed Oct 13, 2022
1 parent 041bc24 commit 2145ab5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/virtio/virtio_pci_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ int vp_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, false, ctx, desc);
if (!err)
return 0;
/* Is there an interrupt pin? If not give up. */
if (!(to_vp_device(vdev)->pci_dev->pin))
/* Is there an interrupt? If not give up. */
if (!(to_vp_device(vdev)->pci_dev->irq))
return err;
/* Finally fall back to regular interrupts. */
return vp_find_vqs_intx(vdev, nvqs, vqs, callbacks, names, ctx);
Expand Down

0 comments on commit 2145ab5

Please sign in to comment.