1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Alpha specific irq code. 4 */ 5 6 #include <linux/init.h> 7 #include <linux/sched.h> 8 #include <linux/irq.h> 9 #include <linux/kernel_stat.h> 10 #include <linux/module.h> 11 12 #include <asm/machvec.h> 13 #include <asm/dma.h> 14 #include <asm/perf_event.h> 15 #include <asm/mce.h> 16 17 #include "proto.h" 18 #include "irq_impl.h" 19 20 /* Hack minimum IPL during interrupt processing for broken hardware. */ 21 #ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK 22 int __min_ipl; 23 EXPORT_SYMBOL(__min_ipl); 24 #endif 25 26 /* 27 * Performance counter hook. A module can override this to 28 * do something useful. 29 */ 30 static void 31 dummy_perf(unsigned long vector, struct pt_regs *regs) 32 { 33 irq_err_count++; 34 printk(KERN_CRIT "Performance counter interrupt!\n"); 35 } 36 37 void (*perf_irq)(unsigned long, struct pt_regs *) = dummy_perf; 38 EXPORT_SYMBOL(perf_irq); 39 40 /* 41 * The main interrupt entry point. 42 */ 43 44 asmlinkage void 45 do_entInt(unsigned long type, unsigned long vector, 46 unsigned long la_ptr, struct pt_regs *regs) 47 { 48 struct pt_regs *old_regs; 49 50 /* 51 * Disable interrupts during IRQ handling. 52 * Note that there is no matching local_irq_enable() due to 53 * severe problems with RTI at IPL0 and some MILO PALcode 54 * (namely LX164). 55 * 56 * PALcode has already raised PS.IPL to the level of the interrupt 57 * being delivered. For an IPL 7 entry - a machine check or a system 58 * event - that is IPL_MAX, which is what arch_irqs_disabled() tests 59 * for, so local_irq_disable() would decide interrupts were already 60 * off and skip trace_hardirqs_off(). lockdep would then spend the 61 * whole handler believing interrupts are enabled. Drive the 62 * annotation from lockdep's own state rather than the hardware IPL. 63 */ 64 raw_local_irq_disable(); 65 if (lockdep_hardirqs_enabled()) 66 trace_hardirqs_off(); 67 68 old_regs = set_irq_regs(regs); 69 70 switch (type) { 71 case 0: 72 #ifdef CONFIG_SMP 73 irq_enter(); 74 handle_ipi(regs); 75 irq_exit(); 76 break; 77 #else 78 irq_err_count++; 79 pr_crit("Interprocessor interrupt? You must be kidding!\n"); 80 break; 81 #endif 82 case 1: 83 /* handle_irq() already does irq_enter()/irq_exit() */ 84 handle_irq(RTC_IRQ); 85 break; 86 case 2: 87 irq_enter(); 88 alpha_mv.machine_check(vector, la_ptr); 89 irq_exit(); 90 break; 91 case 3: 92 irq_enter(); 93 alpha_mv.device_interrupt(vector); 94 irq_exit(); 95 break; 96 case 4: 97 irq_enter(); 98 perf_irq(la_ptr, regs); 99 irq_exit(); 100 break; 101 default: 102 pr_crit("Hardware intr %lu %lx? Huh?\n", type, vector); 103 pr_crit("PC = %016lx PS=%04lx\n", regs->pc, regs->ps); 104 break; 105 } 106 107 set_irq_regs(old_regs); 108 109 /* 110 * Intentionally no local_irq_enable(): Alpha historically avoids 111 * enabling at IPL0 here due to PAL/RTI issues (LX164/MILO note). 112 */ 113 } 114 115 void notrace lockdep_on_restore(unsigned long ps, 116 unsigned long ip) 117 { 118 #ifdef CONFIG_PROVE_LOCKING 119 /* Restoring IPL==7 means interrupts remain disabled. */ 120 if ((ps & 7) == 7) 121 return; 122 123 /* 124 * If hardware IRQs are already enabled here, then emitting a 125 * hardirqs-on transition is redundant. 126 */ 127 if (!irqs_disabled()) 128 return; 129 130 /* 131 * Only emit the transition if lockdep currently believes 132 * hardirqs are off. 133 */ 134 if (lockdep_hardirqs_enabled()) 135 return; 136 137 lockdep_hardirqs_on_prepare(); 138 lockdep_hardirqs_on(ip); 139 #endif 140 } 141 142 void __init 143 common_init_isa_dma(void) 144 { 145 outb(0, DMA1_RESET_REG); 146 outb(0, DMA2_RESET_REG); 147 outb(0, DMA1_CLR_MASK_REG); 148 outb(0, DMA2_CLR_MASK_REG); 149 } 150 151 void __init 152 init_IRQ(void) 153 { 154 /* Just in case the platform init_irq() causes interrupts/mchecks 155 (as is the case with RAWHIDE, at least). */ 156 wrent(entInt, 0); 157 158 alpha_mv.init_irq(); 159 } 160 161 /* 162 * machine error checks 163 */ 164 #define MCHK_K_TPERR 0x0080 165 #define MCHK_K_TCPERR 0x0082 166 #define MCHK_K_HERR 0x0084 167 #define MCHK_K_ECC_C 0x0086 168 #define MCHK_K_ECC_NC 0x0088 169 #define MCHK_K_OS_BUGCHECK 0x008A 170 #define MCHK_K_PAL_BUGCHECK 0x0090 171 172 #ifndef CONFIG_SMP 173 struct mcheck_info __mcheck_info; 174 #endif 175 176 void 177 process_mcheck_info(unsigned long vector, unsigned long la_ptr, 178 const char *machine, int expected) 179 { 180 struct el_common *mchk_header; 181 const char *reason; 182 183 /* 184 * See if the machine check is due to a badaddr() and if so, 185 * ignore it. 186 */ 187 188 #ifdef CONFIG_VERBOSE_MCHECK 189 if (alpha_verbose_mcheck > 1) { 190 printk(KERN_CRIT "%s machine check %s\n", machine, 191 expected ? "expected." : "NOT expected!!!"); 192 } 193 #endif 194 195 if (expected) { 196 int cpu = smp_processor_id(); 197 mcheck_expected(cpu) = 0; 198 mcheck_taken(cpu) = 1; 199 return; 200 } 201 202 mchk_header = (struct el_common *)la_ptr; 203 204 printk(KERN_CRIT "%s machine check: vector=0x%lx pc=0x%lx code=0x%x\n", 205 machine, vector, get_irq_regs()->pc, mchk_header->code); 206 207 switch (mchk_header->code) { 208 /* Machine check reasons. Defined according to PALcode sources. */ 209 case 0x80: reason = "tag parity error"; break; 210 case 0x82: reason = "tag control parity error"; break; 211 case 0x84: reason = "generic hard error"; break; 212 case 0x86: reason = "correctable ECC error"; break; 213 case 0x88: reason = "uncorrectable ECC error"; break; 214 case 0x8A: reason = "OS-specific PAL bugcheck"; break; 215 case 0x90: reason = "callsys in kernel mode"; break; 216 case 0x96: reason = "i-cache read retryable error"; break; 217 case 0x98: reason = "processor detected hard error"; break; 218 219 /* System specific (these are for Alcor, at least): */ 220 case 0x202: reason = "system detected hard error"; break; 221 case 0x203: reason = "system detected uncorrectable ECC error"; break; 222 case 0x204: reason = "SIO SERR occurred on PCI bus"; break; 223 case 0x205: reason = "parity error detected by core logic"; break; 224 case 0x206: reason = "SIO IOCHK occurred on ISA bus"; break; 225 case 0x207: reason = "non-existent memory error"; break; 226 case 0x208: reason = "MCHK_K_DCSR"; break; 227 case 0x209: reason = "PCI SERR detected"; break; 228 case 0x20b: reason = "PCI data parity error detected"; break; 229 case 0x20d: reason = "PCI address parity error detected"; break; 230 case 0x20f: reason = "PCI master abort error"; break; 231 case 0x211: reason = "PCI target abort error"; break; 232 case 0x213: reason = "scatter/gather PTE invalid error"; break; 233 case 0x215: reason = "flash ROM write error"; break; 234 case 0x217: reason = "IOA timeout detected"; break; 235 case 0x219: reason = "IOCHK#, EISA add-in board parity or other catastrophic error"; break; 236 case 0x21b: reason = "EISA fail-safe timer timeout"; break; 237 case 0x21d: reason = "EISA bus time-out"; break; 238 case 0x21f: reason = "EISA software generated NMI"; break; 239 case 0x221: reason = "unexpected ev5 IRQ[3] interrupt"; break; 240 default: reason = "unknown"; break; 241 } 242 243 printk(KERN_CRIT "machine check type: %s%s\n", 244 reason, mchk_header->retry ? " (retryable)" : ""); 245 246 dik_show_regs(get_irq_regs(), NULL); 247 248 #ifdef CONFIG_VERBOSE_MCHECK 249 if (alpha_verbose_mcheck > 1) { 250 /* Dump the logout area to give all info. */ 251 unsigned long *ptr = (unsigned long *)la_ptr; 252 long i; 253 for (i = 0; i < mchk_header->size / sizeof(long); i += 2) { 254 printk(KERN_CRIT " +%8lx %016lx %016lx\n", 255 i*sizeof(long), ptr[i], ptr[i+1]); 256 } 257 } 258 #endif /* CONFIG_VERBOSE_MCHECK */ 259 } 260 261 /* 262 * The special RTC interrupt type. The interrupt itself was 263 * processed by PALcode, and comes in via entInt vector 1. 264 */ 265 void __init 266 init_rtc_irq(irq_handler_t handler) 267 { 268 irq_set_chip_and_handler_name(RTC_IRQ, &dummy_irq_chip, 269 handle_percpu_irq, "RTC"); 270 if (!handler) 271 handler = rtc_timer_interrupt; 272 if (request_irq(RTC_IRQ, handler, 0, "timer", NULL)) 273 pr_err("Failed to register timer interrupt\n"); 274 } 275