PCI: Test INTx masking during enumeration, not at run-time
The test for INTx masking via PCI_COMMAND_INTX_DISABLE performed in pci_intx_mask_supported() should be done before the device can be used. This is to avoid writing PCI_COMMAND while the driver owns the device, in case that has any effect on MSI/MSI-X interrupts. Move the content of pci_intx_mask_supported() to pci_intx_mask_broken() and call it from pci_setup_device(). The test result can be queried at any time later using the same pci_intx_mask_supported() interface as before (though with changed implementation), so callers (uio, vfio) should be unaffected. Signed-off-by: Piotr Gregor <piotrgregor@rsyncme.org> [bhelgaas: changelog, remove quirk check, remove locking, move dev->broken_intx_masking assignment to caller] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Alex Williamson <alex.williamson@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:

committed by
Bjorn Helgaas

parent
2ea659a9ef
commit
99b3c58f7b
@@ -1329,6 +1329,34 @@ static void pci_msi_setup_pci_dev(struct pci_dev *dev)
|
||||
pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* pci_intx_mask_broken - test PCI_COMMAND_INTX_DISABLE writability
|
||||
* @dev: PCI device
|
||||
*
|
||||
* Test whether PCI_COMMAND_INTX_DISABLE is writable for @dev. Check this
|
||||
* at enumeration-time to avoid modifying PCI_COMMAND at run-time.
|
||||
*/
|
||||
static int pci_intx_mask_broken(struct pci_dev *dev)
|
||||
{
|
||||
u16 orig, toggle, new;
|
||||
|
||||
pci_read_config_word(dev, PCI_COMMAND, &orig);
|
||||
toggle = orig ^ PCI_COMMAND_INTX_DISABLE;
|
||||
pci_write_config_word(dev, PCI_COMMAND, toggle);
|
||||
pci_read_config_word(dev, PCI_COMMAND, &new);
|
||||
|
||||
pci_write_config_word(dev, PCI_COMMAND, orig);
|
||||
|
||||
/*
|
||||
* PCI_COMMAND_INTX_DISABLE was reserved and read-only prior to PCI
|
||||
* r2.3, so strictly speaking, a device is not *broken* if it's not
|
||||
* writable. But we'll live with the misnomer for now.
|
||||
*/
|
||||
if (new != toggle)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* pci_setup_device - fill in class and map information of a device
|
||||
* @dev: the device structure to fill
|
||||
@@ -1399,6 +1427,8 @@ int pci_setup_device(struct pci_dev *dev)
|
||||
}
|
||||
}
|
||||
|
||||
dev->broken_intx_masking = pci_intx_mask_broken(dev);
|
||||
|
||||
switch (dev->hdr_type) { /* header type */
|
||||
case PCI_HEADER_TYPE_NORMAL: /* standard header */
|
||||
if (class == PCI_CLASS_BRIDGE_PCI)
|
||||
|
Reference in New Issue
Block a user