Re: [Patch v4 21/23] x86/PCI: Refine the way to release PCI IRQ resources

Alex Williamson
2015-03-04T23:49:10Z

On Wed, 2015-03-04 at 09:06 -0700, Alex Williamson wrote:
> Hi,
>
> I'm getting a regression from this patch when using VFIO for device
> assignment to a QEMU VM. I have a device initially bound to the nouveau
> driver, which is unbound from that driver and bound to vfio-pci for use
> by userspace. vfio-pci calls pci_enable_device, but when userspace
> attempts to setup the legacy INTx interrupt, pci_dev->irq is zero and
> vfio-pci errors with -ENODEV.
>
> Where is pci_dev->irq supposed to be getting re-initialized in this
> case? Am I missing an important initialization step in vfio-pci? I
> certainly don't think I should be calling request_irq(pci_dev->irq, ...
> when pci_dev->irq is zero. Thanks,

It looks like the imbalance is in pci_dev->enable_cnt. Any call to
pci_disable_device() will clear pci_dev->irq, but pci_enable_device()
does effectively nothing unless it's called with enable_cnt == zero. So
I'm at the mercy of the previous driver behaving relatively sanely in
order to re-enable legacy interrupts for a device :-\ Maybe the unbound
notifier needs to do some sanitizing of the device? Thanks,

Alex