diff options
author | Alexander Gordeev <agordeev@redhat.com> | 2014-04-14 09:28:35 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-04-30 18:56:47 -0400 |
commit | 034cd97ebda4062eb4402a6cf963ccd262caa86a (patch) | |
tree | f9d9d74d58c21b68bd875d192d18d915196531d0 | |
parent | a30d0108b09ae46d24594a2e699c4dad21bb4af4 (diff) |
PCI/MSI: Remove pci_enable_msi_block()
There are no users of pci_enable_msi_block() function left. Obsolete it in
favor of pci_enable_msi_range() and pci_enable_msi_exact() functions.
Previously, we called arch_setup_msi_irqs() once, requesting the same
vector count we passed to arch_msi_check_device(). Now we may call it
several times: if it returns failure, we may retry and request fewer
vectors.
We don't keep track of the vector count we initially passed to
arch_msi_check_device(). We only keep track of the number of vectors
successfully set up by arch_setup_msi_irqs(), and this is what we use to
clean things up when disabling MSI. Therefore, we assume that
arch_msi_check_device() does nothing that will have to be cleaned up later.
[bhelgaas: changelog]
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | drivers/pci/msi.c | 79 | ||||
-rw-r--r-- | include/linux/pci.h | 5 |
2 files changed, 34 insertions, 50 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 04130c3f9cf6..36dd0caa1759 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -879,50 +879,6 @@ int pci_msi_vec_count(struct pci_dev *dev) | |||
879 | } | 879 | } |
880 | EXPORT_SYMBOL(pci_msi_vec_count); | 880 | EXPORT_SYMBOL(pci_msi_vec_count); |
881 | 881 | ||
882 | /** | ||
883 | * pci_enable_msi_block - configure device's MSI capability structure | ||
884 | * @dev: device to configure | ||
885 | * @nvec: number of interrupts to configure | ||
886 | * | ||
887 | * Allocate IRQs for a device with the MSI capability. | ||
888 | * This function returns a negative errno if an error occurs. If it | ||
889 | * is unable to allocate the number of interrupts requested, it returns | ||
890 | * the number of interrupts it might be able to allocate. If it successfully | ||
891 | * allocates at least the number of interrupts requested, it returns 0 and | ||
892 | * updates the @dev's irq member to the lowest new interrupt number; the | ||
893 | * other interrupt numbers allocated to this device are consecutive. | ||
894 | */ | ||
895 | int pci_enable_msi_block(struct pci_dev *dev, int nvec) | ||
896 | { | ||
897 | int status, maxvec; | ||
898 | |||
899 | if (dev->current_state != PCI_D0) | ||
900 | return -EINVAL; | ||
901 | |||
902 | maxvec = pci_msi_vec_count(dev); | ||
903 | if (maxvec < 0) | ||
904 | return maxvec; | ||
905 | if (nvec > maxvec) | ||
906 | return maxvec; | ||
907 | |||
908 | status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI); | ||
909 | if (status) | ||
910 | return status; | ||
911 | |||
912 | WARN_ON(!!dev->msi_enabled); | ||
913 | |||
914 | /* Check whether driver already requested MSI-X irqs */ | ||
915 | if (dev->msix_enabled) { | ||
916 | dev_info(&dev->dev, "can't enable MSI " | ||
917 | "(MSI-X already enabled)\n"); | ||
918 | return -EINVAL; | ||
919 | } | ||
920 | |||
921 | status = msi_capability_init(dev, nvec); | ||
922 | return status; | ||
923 | } | ||
924 | EXPORT_SYMBOL(pci_enable_msi_block); | ||
925 | |||
926 | void pci_msi_shutdown(struct pci_dev *dev) | 882 | void pci_msi_shutdown(struct pci_dev *dev) |
927 | { | 883 | { |
928 | struct msi_desc *desc; | 884 | struct msi_desc *desc; |
@@ -1128,14 +1084,45 @@ void pci_msi_init_pci_dev(struct pci_dev *dev) | |||
1128 | **/ | 1084 | **/ |
1129 | int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) | 1085 | int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) |
1130 | { | 1086 | { |
1131 | int nvec = maxvec; | 1087 | int nvec; |
1132 | int rc; | 1088 | int rc; |
1133 | 1089 | ||
1090 | if (dev->current_state != PCI_D0) | ||
1091 | return -EINVAL; | ||
1092 | |||
1093 | WARN_ON(!!dev->msi_enabled); | ||
1094 | |||
1095 | /* Check whether driver already requested MSI-X irqs */ | ||
1096 | if (dev->msix_enabled) { | ||
1097 | dev_info(&dev->dev, | ||
1098 | "can't enable MSI (MSI-X already enabled)\n"); | ||
1099 | return -EINVAL; | ||
1100 | } | ||
1101 | |||
1134 | if (maxvec < minvec) | 1102 | if (maxvec < minvec) |
1135 | return -ERANGE; | 1103 | return -ERANGE; |
1136 | 1104 | ||
1105 | nvec = pci_msi_vec_count(dev); | ||
1106 | if (nvec < 0) | ||
1107 | return nvec; | ||
1108 | else if (nvec < minvec) | ||
1109 | return -EINVAL; | ||
1110 | else if (nvec > maxvec) | ||
1111 | nvec = maxvec; | ||
1112 | |||
1113 | do { | ||
1114 | rc = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI); | ||
1115 | if (rc < 0) { | ||
1116 | return rc; | ||
1117 | } else if (rc > 0) { | ||
1118 | if (rc < minvec) | ||
1119 | return -ENOSPC; | ||
1120 | nvec = rc; | ||
1121 | } | ||
1122 | } while (rc); | ||
1123 | |||
1137 | do { | 1124 | do { |
1138 | rc = pci_enable_msi_block(dev, nvec); | 1125 | rc = msi_capability_init(dev, nvec); |
1139 | if (rc < 0) { | 1126 | if (rc < 0) { |
1140 | return rc; | 1127 | return rc; |
1141 | } else if (rc > 0) { | 1128 | } else if (rc > 0) { |
diff --git a/include/linux/pci.h b/include/linux/pci.h index aab57b4abe7f..499755e6dab5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -1158,7 +1158,6 @@ struct msix_entry { | |||
1158 | 1158 | ||
1159 | #ifdef CONFIG_PCI_MSI | 1159 | #ifdef CONFIG_PCI_MSI |
1160 | int pci_msi_vec_count(struct pci_dev *dev); | 1160 | int pci_msi_vec_count(struct pci_dev *dev); |
1161 | int pci_enable_msi_block(struct pci_dev *dev, int nvec); | ||
1162 | void pci_msi_shutdown(struct pci_dev *dev); | 1161 | void pci_msi_shutdown(struct pci_dev *dev); |
1163 | void pci_disable_msi(struct pci_dev *dev); | 1162 | void pci_disable_msi(struct pci_dev *dev); |
1164 | int pci_msix_vec_count(struct pci_dev *dev); | 1163 | int pci_msix_vec_count(struct pci_dev *dev); |
@@ -1188,8 +1187,6 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev, | |||
1188 | } | 1187 | } |
1189 | #else | 1188 | #else |
1190 | static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; } | 1189 | static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; } |
1191 | static inline int pci_enable_msi_block(struct pci_dev *dev, int nvec) | ||
1192 | { return -ENOSYS; } | ||
1193 | static inline void pci_msi_shutdown(struct pci_dev *dev) { } | 1190 | static inline void pci_msi_shutdown(struct pci_dev *dev) { } |
1194 | static inline void pci_disable_msi(struct pci_dev *dev) { } | 1191 | static inline void pci_disable_msi(struct pci_dev *dev) { } |
1195 | static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; } | 1192 | static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; } |
@@ -1244,7 +1241,7 @@ static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { } | |||
1244 | static inline void pcie_ecrc_get_policy(char *str) { } | 1241 | static inline void pcie_ecrc_get_policy(char *str) { } |
1245 | #endif | 1242 | #endif |
1246 | 1243 | ||
1247 | #define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1) | 1244 | #define pci_enable_msi(pdev) pci_enable_msi_exact(pdev, 1) |
1248 | 1245 | ||
1249 | #ifdef CONFIG_HT_IRQ | 1246 | #ifdef CONFIG_HT_IRQ |
1250 | /* The functions a driver should call */ | 1247 | /* The functions a driver should call */ |