pci_event.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /* Content Code Description for PCI Function Error */
  12. struct zpci_ccdf_err {
  13. u32 reserved1;
  14. u32 fh; /* function handle */
  15. u32 fid; /* function id */
  16. u32 ett : 4; /* expected table type */
  17. u32 mvn : 12; /* MSI vector number */
  18. u32 dmaas : 8; /* DMA address space */
  19. u32 : 6;
  20. u32 q : 1; /* event qualifier */
  21. u32 rw : 1; /* read/write */
  22. u64 faddr; /* failing address */
  23. u32 reserved3;
  24. u16 reserved4;
  25. u16 pec; /* PCI event code */
  26. } __packed;
  27. /* Content Code Description for PCI Function Availability */
  28. struct zpci_ccdf_avail {
  29. u32 reserved1;
  30. u32 fh; /* function handle */
  31. u32 fid; /* function id */
  32. u32 reserved2;
  33. u32 reserved3;
  34. u32 reserved4;
  35. u32 reserved5;
  36. u16 reserved6;
  37. u16 pec; /* PCI event code */
  38. } __packed;
  39. static void zpci_event_log_err(struct zpci_ccdf_err *ccdf)
  40. {
  41. struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
  42. zpci_err("SEI error CCD:\n");
  43. zpci_err_hex(ccdf, sizeof(*ccdf));
  44. dev_err(&zdev->pdev->dev, "event code: 0x%x\n", ccdf->pec);
  45. }
  46. static void zpci_event_log_avail(struct zpci_ccdf_avail *ccdf)
  47. {
  48. struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
  49. pr_err("%s%s: availability event: fh: 0x%x fid: 0x%x event code: 0x%x reason:",
  50. (zdev) ? dev_driver_string(&zdev->pdev->dev) : "?",
  51. (zdev) ? dev_name(&zdev->pdev->dev) : "?",
  52. ccdf->fh, ccdf->fid, ccdf->pec);
  53. print_hex_dump(KERN_CONT, "ccdf", DUMP_PREFIX_OFFSET,
  54. 16, 1, ccdf, sizeof(*ccdf), false);
  55. switch (ccdf->pec) {
  56. case 0x0301:
  57. zpci_enable_device(zdev);
  58. break;
  59. case 0x0302:
  60. clp_add_pci_device(ccdf->fid, ccdf->fh, 0);
  61. break;
  62. case 0x0306:
  63. clp_find_pci_devices();
  64. break;
  65. default:
  66. break;
  67. }
  68. }
  69. void zpci_event_error(void *data)
  70. {
  71. struct zpci_ccdf_err *ccdf = data;
  72. struct zpci_dev *zdev;
  73. zpci_event_log_err(ccdf);
  74. zdev = get_zdev_by_fid(ccdf->fid);
  75. if (!zdev) {
  76. pr_err("Error event for unknown fid: %x", ccdf->fid);
  77. return;
  78. }
  79. }
  80. void zpci_event_availability(void *data)
  81. {
  82. zpci_event_log_avail(data);
  83. }