pcidev_msi.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * MSI[X} related functions which are available unconditionally.
  4. */
  5. #include "../pci.h"
  6. /*
  7. * Disable the MSI[X] hardware to avoid screaming interrupts during boot.
  8. * This is the power on reset default so usually this should be a noop.
  9. */
  10. void pci_msi_init(struct pci_dev *dev)
  11. {
  12. u16 ctrl;
  13. dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI);
  14. if (!dev->msi_cap)
  15. return;
  16. pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &ctrl);
  17. if (ctrl & PCI_MSI_FLAGS_ENABLE) {
  18. pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS,
  19. ctrl & ~PCI_MSI_FLAGS_ENABLE);
  20. }
  21. if (!(ctrl & PCI_MSI_FLAGS_64BIT))
  22. dev->no_64bit_msi = 1;
  23. }
  24. void pci_msix_init(struct pci_dev *dev)
  25. {
  26. u16 ctrl;
  27. dev->msix_cap = pci_find_capability(dev, PCI_CAP_ID_MSIX);
  28. if (!dev->msix_cap)
  29. return;
  30. pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl);
  31. if (ctrl & PCI_MSIX_FLAGS_ENABLE) {
  32. pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS,
  33. ctrl & ~PCI_MSIX_FLAGS_ENABLE);
  34. }
  35. }