Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / pci / msi / pcidev_msi.c
blob5520aff53b5670e70311c63f0f358228bf03c309
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * MSI[X} related functions which are available unconditionally.
4 */
5 #include "../pci.h"
7 /*
8 * Disable the MSI[X] hardware to avoid screaming interrupts during boot.
9 * This is the power on reset default so usually this should be a noop.
12 void pci_msi_init(struct pci_dev *dev)
14 u16 ctrl;
16 dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI);
17 if (!dev->msi_cap)
18 return;
20 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &ctrl);
21 if (ctrl & PCI_MSI_FLAGS_ENABLE) {
22 pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS,
23 ctrl & ~PCI_MSI_FLAGS_ENABLE);
26 if (!(ctrl & PCI_MSI_FLAGS_64BIT))
27 dev->no_64bit_msi = 1;
30 void pci_msix_init(struct pci_dev *dev)
32 u16 ctrl;
34 dev->msix_cap = pci_find_capability(dev, PCI_CAP_ID_MSIX);
35 if (!dev->msix_cap)
36 return;
38 pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl);
39 if (ctrl & PCI_MSIX_FLAGS_ENABLE) {
40 pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS,
41 ctrl & ~PCI_MSIX_FLAGS_ENABLE);