qib_pcie.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /*
  2. * Copyright (c) 2010 - 2017 Intel Corporation. All rights reserved.
  3. * Copyright (c) 2008, 2009 QLogic Corporation. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #include <linux/pci.h>
  34. #include <linux/io.h>
  35. #include <linux/delay.h>
  36. #include <linux/vmalloc.h>
  37. #include <linux/aer.h>
  38. #include <linux/module.h>
  39. #include "qib.h"
  40. /*
  41. * This file contains PCIe utility routines that are common to the
  42. * various QLogic InfiniPath adapters
  43. */
  44. /*
  45. * Code to adjust PCIe capabilities.
  46. * To minimize the change footprint, we call it
  47. * from qib_pcie_params, which every chip-specific
  48. * file calls, even though this violates some
  49. * expectations of harmlessness.
  50. */
  51. static void qib_tune_pcie_caps(struct qib_devdata *);
  52. static void qib_tune_pcie_coalesce(struct qib_devdata *);
  53. /*
  54. * Do all the common PCIe setup and initialization.
  55. * devdata is not yet allocated, and is not allocated until after this
  56. * routine returns success. Therefore qib_dev_err() can't be used for error
  57. * printing.
  58. */
  59. int qib_pcie_init(struct pci_dev *pdev, const struct pci_device_id *ent)
  60. {
  61. int ret;
  62. ret = pci_enable_device(pdev);
  63. if (ret) {
  64. /*
  65. * This can happen (in theory) iff:
  66. * We did a chip reset, and then failed to reprogram the
  67. * BAR, or the chip reset due to an internal error. We then
  68. * unloaded the driver and reloaded it.
  69. *
  70. * Both reset cases set the BAR back to initial state. For
  71. * the latter case, the AER sticky error bit at offset 0x718
  72. * should be set, but the Linux kernel doesn't yet know
  73. * about that, it appears. If the original BAR was retained
  74. * in the kernel data structures, this may be OK.
  75. */
  76. qib_early_err(&pdev->dev, "pci enable failed: error %d\n",
  77. -ret);
  78. goto done;
  79. }
  80. ret = pci_request_regions(pdev, QIB_DRV_NAME);
  81. if (ret) {
  82. qib_devinfo(pdev, "pci_request_regions fails: err %d\n", -ret);
  83. goto bail;
  84. }
  85. ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
  86. if (ret) {
  87. /*
  88. * If the 64 bit setup fails, try 32 bit. Some systems
  89. * do not setup 64 bit maps on systems with 2GB or less
  90. * memory installed.
  91. */
  92. ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
  93. if (ret) {
  94. qib_devinfo(pdev, "Unable to set DMA mask: %d\n", ret);
  95. goto bail;
  96. }
  97. ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
  98. } else
  99. ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
  100. if (ret) {
  101. qib_early_err(&pdev->dev,
  102. "Unable to set DMA consistent mask: %d\n", ret);
  103. goto bail;
  104. }
  105. pci_set_master(pdev);
  106. ret = pci_enable_pcie_error_reporting(pdev);
  107. if (ret) {
  108. qib_early_err(&pdev->dev,
  109. "Unable to enable pcie error reporting: %d\n",
  110. ret);
  111. ret = 0;
  112. }
  113. goto done;
  114. bail:
  115. pci_disable_device(pdev);
  116. pci_release_regions(pdev);
  117. done:
  118. return ret;
  119. }
  120. /*
  121. * Do remaining PCIe setup, once dd is allocated, and save away
  122. * fields required to re-initialize after a chip reset, or for
  123. * various other purposes
  124. */
  125. int qib_pcie_ddinit(struct qib_devdata *dd, struct pci_dev *pdev,
  126. const struct pci_device_id *ent)
  127. {
  128. unsigned long len;
  129. resource_size_t addr;
  130. dd->pcidev = pdev;
  131. pci_set_drvdata(pdev, dd);
  132. addr = pci_resource_start(pdev, 0);
  133. len = pci_resource_len(pdev, 0);
  134. dd->kregbase = ioremap_nocache(addr, len);
  135. if (!dd->kregbase)
  136. return -ENOMEM;
  137. dd->kregend = (u64 __iomem *)((void __iomem *) dd->kregbase + len);
  138. dd->physaddr = addr; /* used for io_remap, etc. */
  139. /*
  140. * Save BARs to rewrite after device reset. Save all 64 bits of
  141. * BAR, just in case.
  142. */
  143. dd->pcibar0 = addr;
  144. dd->pcibar1 = addr >> 32;
  145. dd->deviceid = ent->device; /* save for later use */
  146. dd->vendorid = ent->vendor;
  147. return 0;
  148. }
  149. /*
  150. * Do PCIe cleanup, after chip-specific cleanup, etc. Just prior
  151. * to releasing the dd memory.
  152. * void because none of the core pcie cleanup returns are void
  153. */
  154. void qib_pcie_ddcleanup(struct qib_devdata *dd)
  155. {
  156. u64 __iomem *base = (void __iomem *) dd->kregbase;
  157. dd->kregbase = NULL;
  158. iounmap(base);
  159. if (dd->piobase)
  160. iounmap(dd->piobase);
  161. if (dd->userbase)
  162. iounmap(dd->userbase);
  163. if (dd->piovl15base)
  164. iounmap(dd->piovl15base);
  165. pci_disable_device(dd->pcidev);
  166. pci_release_regions(dd->pcidev);
  167. pci_set_drvdata(dd->pcidev, NULL);
  168. }
  169. /**
  170. * We save the msi lo and hi values, so we can restore them after
  171. * chip reset (the kernel PCI infrastructure doesn't yet handle that
  172. * correctly.
  173. */
  174. static void qib_cache_msi_info(struct qib_devdata *dd, int pos)
  175. {
  176. struct pci_dev *pdev = dd->pcidev;
  177. u16 control;
  178. pci_read_config_dword(pdev, pos + PCI_MSI_ADDRESS_LO, &dd->msi_lo);
  179. pci_read_config_dword(pdev, pos + PCI_MSI_ADDRESS_HI, &dd->msi_hi);
  180. pci_read_config_word(pdev, pos + PCI_MSI_FLAGS, &control);
  181. /* now save the data (vector) info */
  182. pci_read_config_word(pdev,
  183. pos + ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8),
  184. &dd->msi_data);
  185. }
  186. int qib_pcie_params(struct qib_devdata *dd, u32 minw, u32 *nent)
  187. {
  188. u16 linkstat, speed;
  189. int nvec;
  190. int maxvec;
  191. unsigned int flags = PCI_IRQ_MSIX | PCI_IRQ_MSI;
  192. if (!pci_is_pcie(dd->pcidev)) {
  193. qib_dev_err(dd, "Can't find PCI Express capability!\n");
  194. /* set up something... */
  195. dd->lbus_width = 1;
  196. dd->lbus_speed = 2500; /* Gen1, 2.5GHz */
  197. nvec = -1;
  198. goto bail;
  199. }
  200. if (dd->flags & QIB_HAS_INTX)
  201. flags |= PCI_IRQ_LEGACY;
  202. maxvec = (nent && *nent) ? *nent : 1;
  203. nvec = pci_alloc_irq_vectors(dd->pcidev, 1, maxvec, flags);
  204. if (nvec < 0)
  205. goto bail;
  206. /*
  207. * If nent exists, make sure to record how many vectors were allocated.
  208. * If msix_enabled is false, return 0 so the fallback code works
  209. * correctly.
  210. */
  211. if (nent)
  212. *nent = !dd->pcidev->msix_enabled ? 0 : nvec;
  213. if (dd->pcidev->msi_enabled)
  214. qib_cache_msi_info(dd, dd->pcidev->msi_cap);
  215. pcie_capability_read_word(dd->pcidev, PCI_EXP_LNKSTA, &linkstat);
  216. /*
  217. * speed is bits 0-3, linkwidth is bits 4-8
  218. * no defines for them in headers
  219. */
  220. speed = linkstat & 0xf;
  221. linkstat >>= 4;
  222. linkstat &= 0x1f;
  223. dd->lbus_width = linkstat;
  224. switch (speed) {
  225. case 1:
  226. dd->lbus_speed = 2500; /* Gen1, 2.5GHz */
  227. break;
  228. case 2:
  229. dd->lbus_speed = 5000; /* Gen1, 5GHz */
  230. break;
  231. default: /* not defined, assume gen1 */
  232. dd->lbus_speed = 2500;
  233. break;
  234. }
  235. /*
  236. * Check against expected pcie width and complain if "wrong"
  237. * on first initialization, not afterwards (i.e., reset).
  238. */
  239. if (minw && linkstat < minw)
  240. qib_dev_err(dd,
  241. "PCIe width %u (x%u HCA), performance reduced\n",
  242. linkstat, minw);
  243. qib_tune_pcie_caps(dd);
  244. qib_tune_pcie_coalesce(dd);
  245. bail:
  246. /* fill in string, even on errors */
  247. snprintf(dd->lbus_info, sizeof(dd->lbus_info),
  248. "PCIe,%uMHz,x%u\n", dd->lbus_speed, dd->lbus_width);
  249. return nvec < 0 ? nvec : 0;
  250. }
  251. /**
  252. * qib_free_irq - Cleanup INTx and MSI interrupts
  253. * @dd: valid pointer to qib dev data
  254. *
  255. * Since cleanup for INTx and MSI interrupts is trivial, have a common
  256. * routine.
  257. *
  258. */
  259. void qib_free_irq(struct qib_devdata *dd)
  260. {
  261. pci_free_irq(dd->pcidev, 0, dd);
  262. pci_free_irq_vectors(dd->pcidev);
  263. }
  264. /*
  265. * Setup pcie interrupt stuff again after a reset. I'd like to just call
  266. * pci_enable_msi() again for msi, but when I do that,
  267. * the MSI enable bit doesn't get set in the command word, and
  268. * we switch to to a different interrupt vector, which is confusing,
  269. * so I instead just do it all inline. Perhaps somehow can tie this
  270. * into the PCIe hotplug support at some point
  271. */
  272. int qib_reinit_intr(struct qib_devdata *dd)
  273. {
  274. int pos;
  275. u16 control;
  276. int ret = 0;
  277. /* If we aren't using MSI, don't restore it */
  278. if (!dd->msi_lo)
  279. goto bail;
  280. pos = dd->pcidev->msi_cap;
  281. if (!pos) {
  282. qib_dev_err(dd,
  283. "Can't find MSI capability, can't restore MSI settings\n");
  284. ret = 0;
  285. /* nothing special for MSIx, just MSI */
  286. goto bail;
  287. }
  288. pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_LO,
  289. dd->msi_lo);
  290. pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_HI,
  291. dd->msi_hi);
  292. pci_read_config_word(dd->pcidev, pos + PCI_MSI_FLAGS, &control);
  293. if (!(control & PCI_MSI_FLAGS_ENABLE)) {
  294. control |= PCI_MSI_FLAGS_ENABLE;
  295. pci_write_config_word(dd->pcidev, pos + PCI_MSI_FLAGS,
  296. control);
  297. }
  298. /* now rewrite the data (vector) info */
  299. pci_write_config_word(dd->pcidev, pos +
  300. ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8),
  301. dd->msi_data);
  302. ret = 1;
  303. bail:
  304. qib_free_irq(dd);
  305. if (!ret && (dd->flags & QIB_HAS_INTX))
  306. ret = 1;
  307. /* and now set the pci master bit again */
  308. pci_set_master(dd->pcidev);
  309. return ret;
  310. }
  311. /*
  312. * These two routines are helper routines for the device reset code
  313. * to move all the pcie code out of the chip-specific driver code.
  314. */
  315. void qib_pcie_getcmd(struct qib_devdata *dd, u16 *cmd, u8 *iline, u8 *cline)
  316. {
  317. pci_read_config_word(dd->pcidev, PCI_COMMAND, cmd);
  318. pci_read_config_byte(dd->pcidev, PCI_INTERRUPT_LINE, iline);
  319. pci_read_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE, cline);
  320. }
  321. void qib_pcie_reenable(struct qib_devdata *dd, u16 cmd, u8 iline, u8 cline)
  322. {
  323. int r;
  324. r = pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_0,
  325. dd->pcibar0);
  326. if (r)
  327. qib_dev_err(dd, "rewrite of BAR0 failed: %d\n", r);
  328. r = pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_1,
  329. dd->pcibar1);
  330. if (r)
  331. qib_dev_err(dd, "rewrite of BAR1 failed: %d\n", r);
  332. /* now re-enable memory access, and restore cosmetic settings */
  333. pci_write_config_word(dd->pcidev, PCI_COMMAND, cmd);
  334. pci_write_config_byte(dd->pcidev, PCI_INTERRUPT_LINE, iline);
  335. pci_write_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE, cline);
  336. r = pci_enable_device(dd->pcidev);
  337. if (r)
  338. qib_dev_err(dd,
  339. "pci_enable_device failed after reset: %d\n", r);
  340. }
  341. static int qib_pcie_coalesce;
  342. module_param_named(pcie_coalesce, qib_pcie_coalesce, int, S_IRUGO);
  343. MODULE_PARM_DESC(pcie_coalesce, "tune PCIe colescing on some Intel chipsets");
  344. /*
  345. * Enable PCIe completion and data coalescing, on Intel 5x00 and 7300
  346. * chipsets. This is known to be unsafe for some revisions of some
  347. * of these chipsets, with some BIOS settings, and enabling it on those
  348. * systems may result in the system crashing, and/or data corruption.
  349. */
  350. static void qib_tune_pcie_coalesce(struct qib_devdata *dd)
  351. {
  352. struct pci_dev *parent;
  353. u16 devid;
  354. u32 mask, bits, val;
  355. if (!qib_pcie_coalesce)
  356. return;
  357. /* Find out supported and configured values for parent (root) */
  358. parent = dd->pcidev->bus->self;
  359. if (parent->bus->parent) {
  360. qib_devinfo(dd->pcidev, "Parent not root\n");
  361. return;
  362. }
  363. if (!pci_is_pcie(parent))
  364. return;
  365. if (parent->vendor != 0x8086)
  366. return;
  367. /*
  368. * - bit 12: Max_rdcmp_Imt_EN: need to set to 1
  369. * - bit 11: COALESCE_FORCE: need to set to 0
  370. * - bit 10: COALESCE_EN: need to set to 1
  371. * (but limitations on some on some chipsets)
  372. *
  373. * On the Intel 5000, 5100, and 7300 chipsets, there is
  374. * also: - bit 25:24: COALESCE_MODE, need to set to 0
  375. */
  376. devid = parent->device;
  377. if (devid >= 0x25e2 && devid <= 0x25fa) {
  378. /* 5000 P/V/X/Z */
  379. if (parent->revision <= 0xb2)
  380. bits = 1U << 10;
  381. else
  382. bits = 7U << 10;
  383. mask = (3U << 24) | (7U << 10);
  384. } else if (devid >= 0x65e2 && devid <= 0x65fa) {
  385. /* 5100 */
  386. bits = 1U << 10;
  387. mask = (3U << 24) | (7U << 10);
  388. } else if (devid >= 0x4021 && devid <= 0x402e) {
  389. /* 5400 */
  390. bits = 7U << 10;
  391. mask = 7U << 10;
  392. } else if (devid >= 0x3604 && devid <= 0x360a) {
  393. /* 7300 */
  394. bits = 7U << 10;
  395. mask = (3U << 24) | (7U << 10);
  396. } else {
  397. /* not one of the chipsets that we know about */
  398. return;
  399. }
  400. pci_read_config_dword(parent, 0x48, &val);
  401. val &= ~mask;
  402. val |= bits;
  403. pci_write_config_dword(parent, 0x48, val);
  404. }
  405. /*
  406. * BIOS may not set PCIe bus-utilization parameters for best performance.
  407. * Check and optionally adjust them to maximize our throughput.
  408. */
  409. static int qib_pcie_caps;
  410. module_param_named(pcie_caps, qib_pcie_caps, int, S_IRUGO);
  411. MODULE_PARM_DESC(pcie_caps, "Max PCIe tuning: Payload (0..3), ReadReq (4..7)");
  412. static void qib_tune_pcie_caps(struct qib_devdata *dd)
  413. {
  414. struct pci_dev *parent;
  415. u16 rc_mpss, rc_mps, ep_mpss, ep_mps;
  416. u16 rc_mrrs, ep_mrrs, max_mrrs;
  417. /* Find out supported and configured values for parent (root) */
  418. parent = dd->pcidev->bus->self;
  419. if (!pci_is_root_bus(parent->bus)) {
  420. qib_devinfo(dd->pcidev, "Parent not root\n");
  421. return;
  422. }
  423. if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev))
  424. return;
  425. rc_mpss = parent->pcie_mpss;
  426. rc_mps = ffs(pcie_get_mps(parent)) - 8;
  427. /* Find out supported and configured values for endpoint (us) */
  428. ep_mpss = dd->pcidev->pcie_mpss;
  429. ep_mps = ffs(pcie_get_mps(dd->pcidev)) - 8;
  430. /* Find max payload supported by root, endpoint */
  431. if (rc_mpss > ep_mpss)
  432. rc_mpss = ep_mpss;
  433. /* If Supported greater than limit in module param, limit it */
  434. if (rc_mpss > (qib_pcie_caps & 7))
  435. rc_mpss = qib_pcie_caps & 7;
  436. /* If less than (allowed, supported), bump root payload */
  437. if (rc_mpss > rc_mps) {
  438. rc_mps = rc_mpss;
  439. pcie_set_mps(parent, 128 << rc_mps);
  440. }
  441. /* If less than (allowed, supported), bump endpoint payload */
  442. if (rc_mpss > ep_mps) {
  443. ep_mps = rc_mpss;
  444. pcie_set_mps(dd->pcidev, 128 << ep_mps);
  445. }
  446. /*
  447. * Now the Read Request size.
  448. * No field for max supported, but PCIe spec limits it to 4096,
  449. * which is code '5' (log2(4096) - 7)
  450. */
  451. max_mrrs = 5;
  452. if (max_mrrs > ((qib_pcie_caps >> 4) & 7))
  453. max_mrrs = (qib_pcie_caps >> 4) & 7;
  454. max_mrrs = 128 << max_mrrs;
  455. rc_mrrs = pcie_get_readrq(parent);
  456. ep_mrrs = pcie_get_readrq(dd->pcidev);
  457. if (max_mrrs > rc_mrrs) {
  458. rc_mrrs = max_mrrs;
  459. pcie_set_readrq(parent, rc_mrrs);
  460. }
  461. if (max_mrrs > ep_mrrs) {
  462. ep_mrrs = max_mrrs;
  463. pcie_set_readrq(dd->pcidev, ep_mrrs);
  464. }
  465. }
  466. /* End of PCIe capability tuning */
  467. /*
  468. * From here through qib_pci_err_handler definition is invoked via
  469. * PCI error infrastructure, registered via pci
  470. */
  471. static pci_ers_result_t
  472. qib_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
  473. {
  474. struct qib_devdata *dd = pci_get_drvdata(pdev);
  475. pci_ers_result_t ret = PCI_ERS_RESULT_RECOVERED;
  476. switch (state) {
  477. case pci_channel_io_normal:
  478. qib_devinfo(pdev, "State Normal, ignoring\n");
  479. break;
  480. case pci_channel_io_frozen:
  481. qib_devinfo(pdev, "State Frozen, requesting reset\n");
  482. pci_disable_device(pdev);
  483. ret = PCI_ERS_RESULT_NEED_RESET;
  484. break;
  485. case pci_channel_io_perm_failure:
  486. qib_devinfo(pdev, "State Permanent Failure, disabling\n");
  487. if (dd) {
  488. /* no more register accesses! */
  489. dd->flags &= ~QIB_PRESENT;
  490. qib_disable_after_error(dd);
  491. }
  492. /* else early, or other problem */
  493. ret = PCI_ERS_RESULT_DISCONNECT;
  494. break;
  495. default: /* shouldn't happen */
  496. qib_devinfo(pdev, "QIB PCI errors detected (state %d)\n",
  497. state);
  498. break;
  499. }
  500. return ret;
  501. }
  502. static pci_ers_result_t
  503. qib_pci_mmio_enabled(struct pci_dev *pdev)
  504. {
  505. u64 words = 0U;
  506. struct qib_devdata *dd = pci_get_drvdata(pdev);
  507. pci_ers_result_t ret = PCI_ERS_RESULT_RECOVERED;
  508. if (dd && dd->pport) {
  509. words = dd->f_portcntr(dd->pport, QIBPORTCNTR_WORDRCV);
  510. if (words == ~0ULL)
  511. ret = PCI_ERS_RESULT_NEED_RESET;
  512. }
  513. qib_devinfo(pdev,
  514. "QIB mmio_enabled function called, read wordscntr %Lx, returning %d\n",
  515. words, ret);
  516. return ret;
  517. }
  518. static pci_ers_result_t
  519. qib_pci_slot_reset(struct pci_dev *pdev)
  520. {
  521. qib_devinfo(pdev, "QIB slot_reset function called, ignored\n");
  522. return PCI_ERS_RESULT_CAN_RECOVER;
  523. }
  524. static void
  525. qib_pci_resume(struct pci_dev *pdev)
  526. {
  527. struct qib_devdata *dd = pci_get_drvdata(pdev);
  528. qib_devinfo(pdev, "QIB resume function called\n");
  529. pci_cleanup_aer_uncorrect_error_status(pdev);
  530. /*
  531. * Running jobs will fail, since it's asynchronous
  532. * unlike sysfs-requested reset. Better than
  533. * doing nothing.
  534. */
  535. qib_init(dd, 1); /* same as re-init after reset */
  536. }
  537. const struct pci_error_handlers qib_pci_err_handler = {
  538. .error_detected = qib_pci_error_detected,
  539. .mmio_enabled = qib_pci_mmio_enabled,
  540. .slot_reset = qib_pci_slot_reset,
  541. .resume = qib_pci_resume,
  542. };