pci_event.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright IBM Corp. 2012
  3. *
  4. * Author(s):
  5. * Jan Glauber <jang@linux.vnet.ibm.com>
  6. */
  7. #define COMPONENT "zPCI"
  8. #define pr_fmt(fmt) COMPONENT ": " fmt
  9. #include <linux/kernel.h>
  10. #include <linux/pci.h>
  11. #include <asm/pci_debug.h>
  12. /* Content Code Description for PCI Function Error */
  13. struct zpci_ccdf_err {
  14. u32 reserved1;
  15. u32 fh; /* function handle */
  16. u32 fid; /* function id */
  17. u32 ett : 4; /* expected table type */
  18. u32 mvn : 12; /* MSI vector number */
  19. u32 dmaas : 8; /* DMA address space */
  20. u32 : 6;
  21. u32 q : 1; /* event qualifier */
  22. u32 rw : 1; /* read/write */
  23. u64 faddr; /* failing address */
  24. u32 reserved3;
  25. u16 reserved4;
  26. u16 pec; /* PCI event code */
  27. } __packed;
  28. /* Content Code Description for PCI Function Availability */
  29. struct zpci_ccdf_avail {
  30. u32 reserved1;
  31. u32 fh; /* function handle */
  32. u32 fid; /* function id */
  33. u32 reserved2;
  34. u32 reserved3;
  35. u32 reserved4;
  36. u32 reserved5;
  37. u16 reserved6;
  38. u16 pec; /* PCI event code */
  39. } __packed;
  40. static void zpci_event_log_avail(struct zpci_ccdf_avail *ccdf)
  41. {
  42. struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
  43. struct pci_dev *pdev = zdev ? zdev->pdev : NULL;
  44. pr_info("%s: Event 0x%x reconfigured PCI function 0x%x\n",
  45. pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid);
  46. zpci_err("avail CCDF:\n");
  47. zpci_err_hex(ccdf, sizeof(*ccdf));
  48. switch (ccdf->pec) {
  49. case 0x0301:
  50. zpci_enable_device(zdev);
  51. break;
  52. case 0x0302:
  53. clp_add_pci_device(ccdf->fid, ccdf->fh, 0);
  54. break;
  55. case 0x0306:
  56. clp_rescan_pci_devices();
  57. break;
  58. default:
  59. break;
  60. }
  61. }
  62. void zpci_event_error(void *data)
  63. {
  64. struct zpci_ccdf_err *ccdf = data;
  65. struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
  66. zpci_err("error CCDF:\n");
  67. zpci_err_hex(ccdf, sizeof(*ccdf));
  68. if (!zdev)
  69. return;
  70. pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
  71. pci_name(zdev->pdev), ccdf->pec, ccdf->fid);
  72. }
  73. void zpci_event_availability(void *data)
  74. {
  75. zpci_event_log_avail(data);
  76. }