aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_main.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c110
1 files changed, 54 insertions, 56 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 76fed7545c5..60de6f93869 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -61,7 +61,7 @@ MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
61 61
62#ifdef CONFIG_PCI_MSI 62#ifdef CONFIG_PCI_MSI
63 63
64static int msi_x = 0; 64static int msi_x = 1;
65module_param(msi_x, int, 0444); 65module_param(msi_x, int, 0444);
66MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero"); 66MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
67 67
@@ -137,40 +137,23 @@ static const char mthca_version[] __devinitdata =
137 137
138static int mthca_tune_pci(struct mthca_dev *mdev) 138static int mthca_tune_pci(struct mthca_dev *mdev)
139{ 139{
140 int cap;
141 u16 val;
142
143 if (!tune_pci) 140 if (!tune_pci)
144 return 0; 141 return 0;
145 142
146 /* First try to max out Read Byte Count */ 143 /* First try to max out Read Byte Count */
147 cap = pci_find_capability(mdev->pdev, PCI_CAP_ID_PCIX); 144 if (pci_find_capability(mdev->pdev, PCI_CAP_ID_PCIX)) {
148 if (cap) { 145 if (pcix_set_mmrbc(mdev->pdev, pcix_get_max_mmrbc(mdev->pdev))) {
149 if (pci_read_config_word(mdev->pdev, cap + PCI_X_CMD, &val)) { 146 mthca_err(mdev, "Couldn't set PCI-X max read count, "
150 mthca_err(mdev, "Couldn't read PCI-X command register, " 147 "aborting.\n");
151 "aborting.\n");
152 return -ENODEV;
153 }
154 val = (val & ~PCI_X_CMD_MAX_READ) | (3 << 2);
155 if (pci_write_config_word(mdev->pdev, cap + PCI_X_CMD, val)) {
156 mthca_err(mdev, "Couldn't write PCI-X command register, "
157 "aborting.\n");
158 return -ENODEV; 148 return -ENODEV;
159 } 149 }
160 } else if (!(mdev->mthca_flags & MTHCA_FLAG_PCIE)) 150 } else if (!(mdev->mthca_flags & MTHCA_FLAG_PCIE))
161 mthca_info(mdev, "No PCI-X capability, not setting RBC.\n"); 151 mthca_info(mdev, "No PCI-X capability, not setting RBC.\n");
162 152
163 cap = pci_find_capability(mdev->pdev, PCI_CAP_ID_EXP); 153 if (pci_find_capability(mdev->pdev, PCI_CAP_ID_EXP)) {
164 if (cap) { 154 if (pcie_set_readrq(mdev->pdev, 4096)) {
165 if (pci_read_config_word(mdev->pdev, cap + PCI_EXP_DEVCTL, &val)) { 155 mthca_err(mdev, "Couldn't write PCI Express read request, "
166 mthca_err(mdev, "Couldn't read PCI Express device control " 156 "aborting.\n");
167 "register, aborting.\n");
168 return -ENODEV;
169 }
170 val = (val & ~PCI_EXP_DEVCTL_READRQ) | (5 << 12);
171 if (pci_write_config_word(mdev->pdev, cap + PCI_EXP_DEVCTL, val)) {
172 mthca_err(mdev, "Couldn't write PCI Express device control "
173 "register, aborting.\n");
174 return -ENODEV; 157 return -ENODEV;
175 } 158 }
176 } else if (mdev->mthca_flags & MTHCA_FLAG_PCIE) 159 } else if (mdev->mthca_flags & MTHCA_FLAG_PCIE)
@@ -833,14 +816,19 @@ static int mthca_setup_hca(struct mthca_dev *dev)
833 816
834 err = mthca_NOP(dev, &status); 817 err = mthca_NOP(dev, &status);
835 if (err || status) { 818 if (err || status) {
836 mthca_err(dev, "NOP command failed to generate interrupt (IRQ %d), aborting.\n", 819 if (dev->mthca_flags & (MTHCA_FLAG_MSI | MTHCA_FLAG_MSI_X)) {
837 dev->mthca_flags & MTHCA_FLAG_MSI_X ? 820 mthca_warn(dev, "NOP command failed to generate interrupt "
838 dev->eq_table.eq[MTHCA_EQ_CMD].msi_x_vector : 821 "(IRQ %d).\n",
839 dev->pdev->irq); 822 dev->mthca_flags & MTHCA_FLAG_MSI_X ?
840 if (dev->mthca_flags & (MTHCA_FLAG_MSI | MTHCA_FLAG_MSI_X)) 823 dev->eq_table.eq[MTHCA_EQ_CMD].msi_x_vector :
841 mthca_err(dev, "Try again with MSI/MSI-X disabled.\n"); 824 dev->pdev->irq);
842 else 825 mthca_warn(dev, "Trying again with MSI/MSI-X disabled.\n");
826 } else {
827 mthca_err(dev, "NOP command failed to generate interrupt "
828 "(IRQ %d), aborting.\n",
829 dev->pdev->irq);
843 mthca_err(dev, "BIOS or ACPI interrupt routing problem?\n"); 830 mthca_err(dev, "BIOS or ACPI interrupt routing problem?\n");
831 }
844 832
845 goto err_cmd_poll; 833 goto err_cmd_poll;
846 } 834 }
@@ -1115,24 +1103,6 @@ static int __mthca_init_one(struct pci_dev *pdev, int hca_type)
1115 goto err_free_dev; 1103 goto err_free_dev;
1116 } 1104 }
1117 1105
1118 if (msi_x && !mthca_enable_msi_x(mdev))
1119 mdev->mthca_flags |= MTHCA_FLAG_MSI_X;
1120 else if (msi) {
1121 static int warned;
1122
1123 if (!warned) {
1124 printk(KERN_WARNING PFX "WARNING: MSI support will be "
1125 "removed from the ib_mthca driver in January 2008.\n");
1126 printk(KERN_WARNING " If you are using MSI and cannot "
1127 "switch to MSI-X, please tell "
1128 "<general@lists.openfabrics.org>.\n");
1129 ++warned;
1130 }
1131
1132 if (!pci_enable_msi(pdev))
1133 mdev->mthca_flags |= MTHCA_FLAG_MSI;
1134 }
1135
1136 if (mthca_cmd_init(mdev)) { 1106 if (mthca_cmd_init(mdev)) {
1137 mthca_err(mdev, "Failed to init command interface, aborting.\n"); 1107 mthca_err(mdev, "Failed to init command interface, aborting.\n");
1138 goto err_free_dev; 1108 goto err_free_dev;
@@ -1156,7 +1126,35 @@ static int __mthca_init_one(struct pci_dev *pdev, int hca_type)
1156 mthca_warn(mdev, "If you have problems, try updating your HCA FW.\n"); 1126 mthca_warn(mdev, "If you have problems, try updating your HCA FW.\n");
1157 } 1127 }
1158 1128
1129 if (msi_x && !mthca_enable_msi_x(mdev))
1130 mdev->mthca_flags |= MTHCA_FLAG_MSI_X;
1131 else if (msi) {
1132 static int warned;
1133
1134 if (!warned) {
1135 printk(KERN_WARNING PFX "WARNING: MSI support will be "
1136 "removed from the ib_mthca driver in January 2008.\n");
1137 printk(KERN_WARNING " If you are using MSI and cannot "
1138 "switch to MSI-X, please tell "
1139 "<general@lists.openfabrics.org>.\n");
1140 ++warned;
1141 }
1142
1143 if (!pci_enable_msi(pdev))
1144 mdev->mthca_flags |= MTHCA_FLAG_MSI;
1145 }
1146
1159 err = mthca_setup_hca(mdev); 1147 err = mthca_setup_hca(mdev);
1148 if (err == -EBUSY && (mdev->mthca_flags & (MTHCA_FLAG_MSI | MTHCA_FLAG_MSI_X))) {
1149 if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
1150 pci_disable_msix(pdev);
1151 if (mdev->mthca_flags & MTHCA_FLAG_MSI)
1152 pci_disable_msi(pdev);
1153 mdev->mthca_flags &= ~(MTHCA_FLAG_MSI_X | MTHCA_FLAG_MSI);
1154
1155 err = mthca_setup_hca(mdev);
1156 }
1157
1160 if (err) 1158 if (err)
1161 goto err_close; 1159 goto err_close;
1162 1160
@@ -1192,17 +1190,17 @@ err_cleanup:
1192 mthca_cleanup_uar_table(mdev); 1190 mthca_cleanup_uar_table(mdev);
1193 1191
1194err_close: 1192err_close:
1193 if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
1194 pci_disable_msix(pdev);
1195 if (mdev->mthca_flags & MTHCA_FLAG_MSI)
1196 pci_disable_msi(pdev);
1197
1195 mthca_close_hca(mdev); 1198 mthca_close_hca(mdev);
1196 1199
1197err_cmd: 1200err_cmd:
1198 mthca_cmd_cleanup(mdev); 1201 mthca_cmd_cleanup(mdev);
1199 1202
1200err_free_dev: 1203err_free_dev:
1201 if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
1202 pci_disable_msix(pdev);
1203 if (mdev->mthca_flags & MTHCA_FLAG_MSI)
1204 pci_disable_msi(pdev);
1205
1206 ib_dealloc_device(&mdev->ib_dev); 1204 ib_dealloc_device(&mdev->ib_dev);
1207 1205
1208err_free_res: 1206err_free_res: