aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/pci/pci_event.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/pci/pci_event.c')
-rw-r--r--arch/s390/pci/pci_event.c79
1 files changed, 54 insertions, 25 deletions
diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
index 278e671ec9ac..800f064b0da7 100644
--- a/arch/s390/pci/pci_event.c
+++ b/arch/s390/pci/pci_event.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <asm/pci_debug.h> 13#include <asm/pci_debug.h>
14#include <asm/sclp.h>
14 15
15/* Content Code Description for PCI Function Error */ 16/* Content Code Description for PCI Function Error */
16struct zpci_ccdf_err { 17struct zpci_ccdf_err {
@@ -42,10 +43,27 @@ struct zpci_ccdf_avail {
42 u16 pec; /* PCI event code */ 43 u16 pec; /* PCI event code */
43} __packed; 44} __packed;
44 45
45static void zpci_event_log_avail(struct zpci_ccdf_avail *ccdf) 46void zpci_event_error(void *data)
46{ 47{
48 struct zpci_ccdf_err *ccdf = data;
49 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
50
51 zpci_err("error CCDF:\n");
52 zpci_err_hex(ccdf, sizeof(*ccdf));
53
54 if (!zdev)
55 return;
56
57 pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
58 pci_name(zdev->pdev), ccdf->pec, ccdf->fid);
59}
60
61void zpci_event_availability(void *data)
62{
63 struct zpci_ccdf_avail *ccdf = data;
47 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); 64 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
48 struct pci_dev *pdev = zdev ? zdev->pdev : NULL; 65 struct pci_dev *pdev = zdev ? zdev->pdev : NULL;
66 int ret;
49 67
50 pr_info("%s: Event 0x%x reconfigured PCI function 0x%x\n", 68 pr_info("%s: Event 0x%x reconfigured PCI function 0x%x\n",
51 pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); 69 pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid);
@@ -53,36 +71,47 @@ static void zpci_event_log_avail(struct zpci_ccdf_avail *ccdf)
53 zpci_err_hex(ccdf, sizeof(*ccdf)); 71 zpci_err_hex(ccdf, sizeof(*ccdf));
54 72
55 switch (ccdf->pec) { 73 switch (ccdf->pec) {
56 case 0x0301: 74 case 0x0301: /* Standby -> Configured */
57 zpci_enable_device(zdev); 75 if (!zdev || zdev->state == ZPCI_FN_STATE_CONFIGURED)
76 break;
77 zdev->state = ZPCI_FN_STATE_CONFIGURED;
78 ret = zpci_enable_device(zdev);
79 if (ret)
80 break;
81 pci_rescan_bus(zdev->bus);
58 break; 82 break;
59 case 0x0302: 83 case 0x0302: /* Reserved -> Standby */
60 clp_add_pci_device(ccdf->fid, ccdf->fh, 0); 84 clp_add_pci_device(ccdf->fid, ccdf->fh, 0);
61 break; 85 break;
62 case 0x0306: 86 case 0x0303: /* Deconfiguration requested */
87 if (pdev)
88 pci_stop_and_remove_bus_device(pdev);
89
90 ret = zpci_disable_device(zdev);
91 if (ret)
92 break;
93
94 ret = sclp_pci_deconfigure(zdev->fid);
95 zpci_dbg(3, "deconf fid:%x, rc:%d\n", zdev->fid, ret);
96 if (!ret)
97 zdev->state = ZPCI_FN_STATE_STANDBY;
98
99 break;
100 case 0x0304: /* Configured -> Standby */
101 if (pdev)
102 pci_stop_and_remove_bus_device(pdev);
103
104 zpci_disable_device(zdev);
105 zdev->state = ZPCI_FN_STATE_STANDBY;
106 break;
107 case 0x0306: /* 0x308 or 0x302 for multiple devices */
63 clp_rescan_pci_devices(); 108 clp_rescan_pci_devices();
64 break; 109 break;
110 case 0x0308: /* Standby -> Reserved */
111 pci_stop_root_bus(zdev->bus);
112 pci_remove_root_bus(zdev->bus);
113 break;
65 default: 114 default:
66 break; 115 break;
67 } 116 }
68} 117}
69
70void zpci_event_error(void *data)
71{
72 struct zpci_ccdf_err *ccdf = data;
73 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
74
75 zpci_err("error CCDF:\n");
76 zpci_err_hex(ccdf, sizeof(*ccdf));
77
78 if (!zdev)
79 return;
80
81 pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
82 pci_name(zdev->pdev), ccdf->pec, ccdf->fid);
83}
84
85void zpci_event_availability(void *data)
86{
87 zpci_event_log_avail(data);
88}