[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / ppc64 / kernel / XmPciLpEvent.c
blob809c9bc6678ba55de89df310b55c33feaab4bca7
1 /*
2 * File XmPciLpEvent.h created by Wayne Holm on Mon Jan 15 2001.
4 * This module handles PCI interrupt events sent by the iSeries Hypervisor.
5 */
7 #include <linux/config.h>
8 #include <linux/pci.h>
9 #include <linux/init.h>
10 #include <linux/threads.h>
11 #include <linux/smp.h>
12 #include <linux/param.h>
13 #include <linux/string.h>
14 #include <linux/bootmem.h>
15 #include <linux/ide.h>
17 #include <asm/iSeries/HvTypes.h>
18 #include <asm/iSeries/HvLpEvent.h>
19 #include <asm/iSeries/HvCallPci.h>
20 #include <asm/iSeries/XmPciLpEvent.h>
21 #include <asm/ppcdebug.h>
23 static long Pci_Interrupt_Count;
24 static long Pci_Event_Count;
26 enum XmPciLpEvent_Subtype {
27 XmPciLpEvent_BusCreated = 0, // PHB has been created
28 XmPciLpEvent_BusError = 1, // PHB has failed
29 XmPciLpEvent_BusFailed = 2, // Msg to Secondary, Primary failed bus
30 XmPciLpEvent_NodeFailed = 4, // Multi-adapter bridge has failed
31 XmPciLpEvent_NodeRecovered = 5, // Multi-adapter bridge has recovered
32 XmPciLpEvent_BusRecovered = 12, // PHB has been recovered
33 XmPciLpEvent_UnQuiesceBus = 18, // Secondary bus unqiescing
34 XmPciLpEvent_BridgeError = 21, // Bridge Error
35 XmPciLpEvent_SlotInterrupt = 22 // Slot interrupt
38 struct XmPciLpEvent_BusInterrupt {
39 HvBusNumber busNumber;
40 HvSubBusNumber subBusNumber;
43 struct XmPciLpEvent_NodeInterrupt {
44 HvBusNumber busNumber;
45 HvSubBusNumber subBusNumber;
46 HvAgentId deviceId;
49 struct XmPciLpEvent {
50 struct HvLpEvent hvLpEvent;
52 union {
53 u64 alignData; // Align on an 8-byte boundary
55 struct {
56 u32 fisr;
57 HvBusNumber busNumber;
58 HvSubBusNumber subBusNumber;
59 HvAgentId deviceId;
60 } slotInterrupt;
62 struct XmPciLpEvent_BusInterrupt busFailed;
63 struct XmPciLpEvent_BusInterrupt busRecovered;
64 struct XmPciLpEvent_BusInterrupt busCreated;
66 struct XmPciLpEvent_NodeInterrupt nodeFailed;
67 struct XmPciLpEvent_NodeInterrupt nodeRecovered;
69 } eventData;
73 static void intReceived(struct XmPciLpEvent *eventParm,
74 struct pt_regs *regsParm);
76 static void XmPciLpEvent_handler(struct HvLpEvent *eventParm,
77 struct pt_regs *regsParm)
79 #ifdef CONFIG_PCI
80 #if 0
81 PPCDBG(PPCDBG_BUSWALK, "XmPciLpEvent_handler, type 0x%x\n",
82 eventParm->xType);
83 #endif
84 ++Pci_Event_Count;
86 if (eventParm && (eventParm->xType == HvLpEvent_Type_PciIo)) {
87 switch (eventParm->xFlags.xFunction) {
88 case HvLpEvent_Function_Int:
89 intReceived((struct XmPciLpEvent *)eventParm, regsParm);
90 break;
91 case HvLpEvent_Function_Ack:
92 printk(KERN_ERR
93 "XmPciLpEvent.c: unexpected ack received\n");
94 break;
95 default:
96 printk(KERN_ERR
97 "XmPciLpEvent.c: unexpected event function %d\n",
98 (int)eventParm->xFlags.xFunction);
99 break;
101 } else if (eventParm)
102 printk(KERN_ERR
103 "XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",
104 (int)eventParm->xType);
105 else
106 printk(KERN_ERR "XmPciLpEvent.c: NULL event received\n");
107 #endif
110 static void intReceived(struct XmPciLpEvent *eventParm,
111 struct pt_regs *regsParm)
113 int irq;
115 ++Pci_Interrupt_Count;
116 #if 0
117 PPCDBG(PPCDBG_BUSWALK, "PCI: XmPciLpEvent.c: intReceived\n");
118 #endif
120 switch (eventParm->hvLpEvent.xSubtype) {
121 case XmPciLpEvent_SlotInterrupt:
122 irq = eventParm->hvLpEvent.xCorrelationToken;
123 /* Dispatch the interrupt handlers for this irq */
124 ppc_irq_dispatch_handler(regsParm, irq);
125 HvCallPci_eoi(eventParm->eventData.slotInterrupt.busNumber,
126 eventParm->eventData.slotInterrupt.subBusNumber,
127 eventParm->eventData.slotInterrupt.deviceId);
128 break;
129 /* Ignore error recovery events for now */
130 case XmPciLpEvent_BusCreated:
131 printk(KERN_INFO "XmPciLpEvent.c: system bus %d created\n",
132 eventParm->eventData.busCreated.busNumber);
133 break;
134 case XmPciLpEvent_BusError:
135 case XmPciLpEvent_BusFailed:
136 printk(KERN_INFO "XmPciLpEvent.c: system bus %d failed\n",
137 eventParm->eventData.busFailed.busNumber);
138 break;
139 case XmPciLpEvent_BusRecovered:
140 case XmPciLpEvent_UnQuiesceBus:
141 printk(KERN_INFO "XmPciLpEvent.c: system bus %d recovered\n",
142 eventParm->eventData.busRecovered.busNumber);
143 break;
144 case XmPciLpEvent_NodeFailed:
145 case XmPciLpEvent_BridgeError:
146 printk(KERN_INFO
147 "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d failed\n",
148 eventParm->eventData.nodeFailed.busNumber,
149 eventParm->eventData.nodeFailed.subBusNumber,
150 eventParm->eventData.nodeFailed.deviceId);
151 break;
152 case XmPciLpEvent_NodeRecovered:
153 printk(KERN_INFO
154 "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d recovered\n",
155 eventParm->eventData.nodeRecovered.busNumber,
156 eventParm->eventData.nodeRecovered.subBusNumber,
157 eventParm->eventData.nodeRecovered.deviceId);
158 break;
159 default:
160 printk(KERN_ERR
161 "XmPciLpEvent.c: unrecognized event subtype 0x%x\n",
162 eventParm->hvLpEvent.xSubtype);
163 break;
168 /* This should be called sometime prior to buswalk (init_IRQ would be good) */
169 int XmPciLpEvent_init()
171 int xRc;
173 PPCDBG(PPCDBG_BUSWALK,
174 "XmPciLpEvent_init, Register Event type 0x%04X\n",
175 HvLpEvent_Type_PciIo);
177 xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
178 &XmPciLpEvent_handler);
179 if (xRc == 0) {
180 xRc = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
181 if (xRc != 0)
182 printk(KERN_ERR
183 "XmPciLpEvent.c: open event path failed with rc 0x%x\n",
184 xRc);
185 } else
186 printk(KERN_ERR
187 "XmPciLpEvent.c: register handler failed with rc 0x%x\n",
188 xRc);
189 return xRc;