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.
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/blk.h>
16 #include <linux/ide.h>
17 #include <linux/rtc.h>
18 #include <linux/time.h>
20 #include <asm/iSeries/HvTypes.h>
21 #include <asm/iSeries/HvLpEvent.h>
22 #include <asm/iSeries/HvCallPci.h>
23 #include <asm/iSeries/XmPciLpEvent.h>
24 #include <asm/ppcdebug.h>
26 #include <asm/flight_recorder.h>
28 extern struct flightRecorder* PciFr;
31 long Pci_Interrupt_Count = 0;
32 long Pci_Event_Count = 0;
34 enum XmPciLpEvent_Subtype {
35 XmPciLpEvent_BusCreated = 0, // PHB has been created
36 XmPciLpEvent_BusError = 1, // PHB has failed
37 XmPciLpEvent_BusFailed = 2, // Msg to Secondary, Primary failed bus
38 XmPciLpEvent_NodeFailed = 4, // Multi-adapter bridge has failed
39 XmPciLpEvent_NodeRecovered = 5, // Multi-adapter bridge has recovered
40 XmPciLpEvent_BusRecovered = 12, // PHB has been recovered
41 XmPciLpEvent_UnQuiesceBus = 18, // Secondary bus unqiescing
42 XmPciLpEvent_BridgeError = 21, // Bridge Error
43 XmPciLpEvent_SlotInterrupt = 22 // Slot interrupt
46 struct XmPciLpEvent_BusInterrupt {
47 HvBusNumber busNumber;
48 HvSubBusNumber subBusNumber;
51 struct XmPciLpEvent_NodeInterrupt {
52 HvBusNumber busNumber;
53 HvSubBusNumber subBusNumber;
58 struct HvLpEvent hvLpEvent;
61 u64 alignData; // Align on an 8-byte boundary
65 HvBusNumber busNumber;
66 HvSubBusNumber subBusNumber;
70 struct XmPciLpEvent_BusInterrupt busFailed;
71 struct XmPciLpEvent_BusInterrupt busRecovered;
72 struct XmPciLpEvent_BusInterrupt busCreated;
74 struct XmPciLpEvent_NodeInterrupt nodeFailed;
75 struct XmPciLpEvent_NodeInterrupt nodeRecovered;
81 static void intReceived(struct XmPciLpEvent* eventParm, struct pt_regs* regsParm);
82 static void logXmEvent( char* ErrorText, int busNumber);
84 static void XmPciLpEvent_handler( struct HvLpEvent* eventParm, struct pt_regs* regsParm)
86 //PPCDBG(PPCDBG_BUSWALK,"XmPciLpEvent_handler, type 0x%x\n",eventParm->xType );
89 if (eventParm && eventParm->xType == HvLpEvent_Type_PciIo) {
90 switch( eventParm->xFlags.xFunction ) {
91 case HvLpEvent_Function_Int:
92 intReceived( (struct XmPciLpEvent*)eventParm, regsParm );
94 case HvLpEvent_Function_Ack:
95 printk(KERN_ERR "XmPciLpEvent.c: Unexpected ack received\n");
98 printk(KERN_ERR "XmPciLpEvent.c: Unexpected event function %d\n",(int)eventParm->xFlags.xFunction);
102 else if (eventParm) {
103 printk(KERN_ERR "XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",(int)eventParm->xType);
106 printk(KERN_ERR "XmPciLpEvent.c: NULL event received\n");
110 static void intReceived(struct XmPciLpEvent* eventParm, struct pt_regs* regsParm)
114 ++Pci_Interrupt_Count;
115 //PPCDBG(PPCDBG_BUSWALK,"PCI: XmPciLpEvent.c: intReceived\n");
117 switch (eventParm->hvLpEvent.xSubtype) {
118 case XmPciLpEvent_SlotInterrupt:
119 irq = eventParm->hvLpEvent.xCorrelationToken;
120 /* Dispatch the interrupt handlers for this irq */
121 ppc_irq_dispatch_handler(regsParm, irq);
122 HvCallPci_eoi(eventParm->eventData.slotInterrupt.busNumber,
123 eventParm->eventData.slotInterrupt.subBusNumber,
124 eventParm->eventData.slotInterrupt.deviceId);
126 /* Ignore error recovery events for now */
127 case XmPciLpEvent_BusCreated:
128 logXmEvent("System bus created.",eventParm->eventData.busCreated.busNumber);
130 case XmPciLpEvent_BusError:
131 case XmPciLpEvent_BusFailed:
132 logXmEvent("System bus failed.", eventParm->eventData.busFailed.busNumber);
134 case XmPciLpEvent_BusRecovered:
135 case XmPciLpEvent_UnQuiesceBus:
136 logXmEvent("System bus recovered.",eventParm->eventData.busRecovered.busNumber);
138 case XmPciLpEvent_NodeFailed:
139 case XmPciLpEvent_BridgeError:
140 logXmEvent("Multi-adapter bridge failed.",eventParm->eventData.nodeFailed.busNumber);
142 case XmPciLpEvent_NodeRecovered:
143 logXmEvent("Multi-adapter bridge recovered",eventParm->eventData.nodeRecovered.busNumber);
146 logXmEvent("Unrecognized event subtype.",eventParm->hvLpEvent.xSubtype);
152 /* This should be called sometime prior to buswalk (init_IRQ would be good) */
153 int XmPciLpEvent_init()
156 PPCDBG(PPCDBG_BUSWALK,"XmPciLpEvent_init, Register Event type 0x%04X\n",HvLpEvent_Type_PciIo);
158 xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo, &XmPciLpEvent_handler);
160 xRc = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
162 printk(KERN_ERR "XmPciLpEvent.c: open event path failed with rc 0x%x\n", xRc);
166 printk(KERN_ERR "XmPciLpEvent.c: register handler failed with rc 0x%x\n", xRc);
170 /***********************************************************************/
172 /* XmPciLpEvent: System bus failed, bus 0x4A. Time:128-16.10.44 */
174 /* 0045. XmPciLpEvent: System bus failed, bus 0x4A. Time:128-16.10.44 */
175 /***********************************************************************/
176 static void logXmEvent( char* ErrorText, int busNumber) {
177 struct timeval TimeClock;
178 struct rtc_time CurTime;
180 do_gettimeofday(&TimeClock);
181 to_tm(TimeClock.tv_sec, &CurTime);
184 sprintf(EventLog,"XmPciLpEvent: %s, Bus:0x%03X. Time:%02d.%02d.%02d",
186 CurTime.tm_hour,CurTime.tm_min,CurTime.tm_sec);
188 fr_Log_Entry(PciFr,EventLog);
189 printk(KERN_INFO "%s\n",EventLog);