Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * MSI[X} related functions which are available unconditionally.
0004  */
0005 #include "../pci.h"
0006 
0007 /*
0008  * Disable the MSI[X] hardware to avoid screaming interrupts during boot.
0009  * This is the power on reset default so usually this should be a noop.
0010  */
0011 
0012 void pci_msi_init(struct pci_dev *dev)
0013 {
0014     u16 ctrl;
0015 
0016     dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI);
0017     if (!dev->msi_cap)
0018         return;
0019 
0020     pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &ctrl);
0021     if (ctrl & PCI_MSI_FLAGS_ENABLE) {
0022         pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS,
0023                       ctrl & ~PCI_MSI_FLAGS_ENABLE);
0024     }
0025 
0026     if (!(ctrl & PCI_MSI_FLAGS_64BIT))
0027         dev->no_64bit_msi = 1;
0028 }
0029 
0030 void pci_msix_init(struct pci_dev *dev)
0031 {
0032     u16 ctrl;
0033 
0034     dev->msix_cap = pci_find_capability(dev, PCI_CAP_ID_MSIX);
0035     if (!dev->msix_cap)
0036         return;
0037 
0038     pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl);
0039     if (ctrl & PCI_MSIX_FLAGS_ENABLE) {
0040         pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS,
0041                       ctrl & ~PCI_MSIX_FLAGS_ENABLE);
0042     }
0043 }