33 #include <linux/errno.h>
34 #include <linux/pci.h>
36 #include <linux/slab.h>
48 int bridge_pcix_cap = 0;
55 #define MTHCA_RESET_OFFSET 0xf0010
56 #define MTHCA_RESET_VALUE swab32(1)
73 mdev->
pdev->device + 2,
90 pci_name(mdev->
pdev));
99 mthca_err(mdev,
"Couldn't allocate memory to save HCA "
100 "PCI header, aborting.\n");
104 for (i = 0; i < 64; ++
i) {
105 if (i == 22 || i == 23)
107 if (pci_read_config_dword(mdev->
pdev, i * 4, hca_header + i)) {
110 "PCI header, aborting.\n");
116 hca_pcie_cap = pci_pcie_cap(mdev->
pdev);
120 if (!bridge_header) {
122 mthca_err(mdev,
"Couldn't allocate memory to save HCA "
123 "bridge PCI header, aborting.\n");
127 for (i = 0; i < 64; ++
i) {
128 if (i == 22 || i == 23)
130 if (pci_read_config_dword(bridge, i * 4, bridge_header + i)) {
132 mthca_err(mdev,
"Couldn't save HCA bridge "
133 "PCI header, aborting.\n");
138 if (!bridge_pcix_cap) {
140 mthca_err(mdev,
"Couldn't locate HCA bridge "
141 "PCI-X capability, aborting.\n");
153 mthca_err(mdev,
"Couldn't map HCA reset register, "
170 for (c = 0; c < 100; ++
c) {
171 if (pci_read_config_dword(bridge ? bridge : mdev->
pdev, 0, &v)) {
173 mthca_err(mdev,
"Couldn't access HCA after reset, "
185 mthca_err(mdev,
"PCI device did not come back after reset, "
193 if (pci_write_config_dword(bridge, bridge_pcix_cap + 0x8,
194 bridge_header[(bridge_pcix_cap + 0x8) / 4])) {
196 mthca_err(mdev,
"Couldn't restore HCA bridge Upstream "
197 "split transaction control, aborting.\n");
200 if (pci_write_config_dword(bridge, bridge_pcix_cap + 0
xc,
201 bridge_header[(bridge_pcix_cap + 0
xc) / 4])) {
203 mthca_err(mdev,
"Couldn't restore HCA bridge Downstream "
204 "split transaction control, aborting.\n");
211 for (i = 0; i < 16; ++
i) {
215 if (pci_write_config_dword(bridge, i * 4, bridge_header[i])) {
217 mthca_err(mdev,
"Couldn't restore HCA bridge reg %x, "
226 mthca_err(mdev,
"Couldn't restore HCA bridge COMMAND, "
233 if (pci_write_config_dword(mdev->
pdev, hca_pcix_cap,
234 hca_header[hca_pcix_cap / 4])) {
236 mthca_err(mdev,
"Couldn't restore HCA PCI-X "
237 "command register, aborting.\n");
247 mthca_err(mdev,
"Couldn't restore HCA PCI Express "
248 "Device Control register, aborting.\n");
255 mthca_err(mdev,
"Couldn't restore HCA PCI Express "
256 "Link control register, aborting.\n");
261 for (i = 0; i < 16; ++
i) {
265 if (pci_write_config_dword(mdev->
pdev, i * 4, hca_header[i])) {
267 mthca_err(mdev,
"Couldn't restore HCA reg %x, "
276 mthca_err(mdev,
"Couldn't restore HCA COMMAND, "
284 kfree(bridge_header);