Skip to content

Commit 1851617

Browse files
mstsirkinbjorn-helgaas
authored andcommitted
PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI
If we enable MSI, then kexec a new kernel, the new kernel may receive MSIs it is not prepared for. Commit d5dea7d ("PCI: msi: Disable msi interrupts when we initialize a pci device") prevents this, but only if the new kernel is built with CONFIG_PCI_MSI=y. Move the "disable MSI" functionality from drivers/pci/msi.c to a new pci_msi_setup_pci_dev() in drivers/pci/probe.c so we can disable MSIs when we enumerate devices even if the kernel doesn't include full MSI support. [bhelgaas: changelog, disable MSIs in pci_setup_device(), put pci_msi_setup_pci_dev() at its final destination] Signed-off-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 6a25f5e commit 1851617

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

drivers/pci/msi.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,18 +1041,6 @@ EXPORT_SYMBOL(pci_msi_enabled);
10411041
void pci_msi_init_pci_dev(struct pci_dev *dev)
10421042
{
10431043
INIT_LIST_HEAD(&dev->msi_list);
1044-
1045-
/* Disable the msi hardware to avoid screaming interrupts
1046-
* during boot. This is the power on reset default so
1047-
* usually this should be a noop.
1048-
*/
1049-
dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI);
1050-
if (dev->msi_cap)
1051-
pci_msi_set_enable(dev, 0);
1052-
1053-
dev->msix_cap = pci_find_capability(dev, PCI_CAP_ID_MSIX);
1054-
if (dev->msix_cap)
1055-
pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
10561044
}
10571045

10581046
/**

drivers/pci/probe.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,22 @@ int pci_cfg_space_size(struct pci_dev *dev)
10851085

10861086
#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED)
10871087

1088+
static void pci_msi_setup_pci_dev(struct pci_dev *dev)
1089+
{
1090+
/*
1091+
* Disable the MSI hardware to avoid screaming interrupts
1092+
* during boot. This is the power on reset default so
1093+
* usually this should be a noop.
1094+
*/
1095+
dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI);
1096+
if (dev->msi_cap)
1097+
pci_msi_set_enable(dev, 0);
1098+
1099+
dev->msix_cap = pci_find_capability(dev, PCI_CAP_ID_MSIX);
1100+
if (dev->msix_cap)
1101+
pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0);
1102+
}
1103+
10881104
/**
10891105
* pci_setup_device - fill in class and map information of a device
10901106
* @dev: the device structure to fill
@@ -1140,6 +1156,8 @@ int pci_setup_device(struct pci_dev *dev)
11401156
/* "Unknown power state" */
11411157
dev->current_state = PCI_UNKNOWN;
11421158

1159+
pci_msi_setup_pci_dev(dev);
1160+
11431161
/* Early fixups, before probing the BARs */
11441162
pci_fixup_device(pci_fixup_early, dev);
11451163
/* device class may be changed after fixup */

0 commit comments

Comments
 (0)