Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IA64] avoid broken SAL_CACHE_FLUSH implementations

If SAL_CACHE_FLUSH drops interrupts, complain about it and fall back to
using PAL_CACHE_FLUSH instead.

This is to work around a defect in HP rx5670 firmware: when an interrupt
occurs during SAL_CACHE_FLUSH, SAL drops the interrupt but leaves it marked
"in-service", which leaves the interrupt (and others of equal or lower
priority) masked.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by

Bjorn Helgaas and committed by
Tony Luck
a5878691 af14aca9

+93 -9
+75
arch/ia64/kernel/sal.c
··· 14 14 #include <linux/spinlock.h> 15 15 #include <linux/string.h> 16 16 17 + #include <asm/delay.h> 17 18 #include <asm/page.h> 18 19 #include <asm/sal.h> 19 20 #include <asm/pal.h> ··· 215 214 static void __init sal_desc_ap_wakeup(void *p) { } 216 215 #endif 217 216 217 + /* 218 + * HP rx5670 firmware polls for interrupts during SAL_CACHE_FLUSH by reading 219 + * cr.ivr, but it never writes cr.eoi. This leaves any interrupt marked as 220 + * "in-service" and masks other interrupts of equal or lower priority. 221 + * 222 + * HP internal defect reports: F1859, F2775, F3031. 223 + */ 224 + static int sal_cache_flush_drops_interrupts; 225 + 226 + static void __init 227 + check_sal_cache_flush (void) 228 + { 229 + unsigned long flags, itv; 230 + int cpu; 231 + u64 vector; 232 + 233 + cpu = get_cpu(); 234 + local_irq_save(flags); 235 + 236 + /* 237 + * Schedule a timer interrupt, wait until it's reported, and see if 238 + * SAL_CACHE_FLUSH drops it. 239 + */ 240 + itv = ia64_get_itv(); 241 + BUG_ON((itv & (1 << 16)) == 0); 242 + 243 + ia64_set_itv(IA64_TIMER_VECTOR); 244 + ia64_set_itm(ia64_get_itc() + 1000); 245 + 246 + while (!ia64_get_irr(IA64_TIMER_VECTOR)) 247 + cpu_relax(); 248 + 249 + ia64_sal_cache_flush(3); 250 + 251 + if (ia64_get_irr(IA64_TIMER_VECTOR)) { 252 + vector = ia64_get_ivr(); 253 + ia64_eoi(); 254 + WARN_ON(vector != IA64_TIMER_VECTOR); 255 + } else { 256 + sal_cache_flush_drops_interrupts = 1; 257 + printk(KERN_ERR "SAL: SAL_CACHE_FLUSH drops interrupts; " 258 + "PAL_CACHE_FLUSH will be used instead\n"); 259 + ia64_eoi(); 260 + } 261 + 262 + ia64_set_itv(itv); 263 + local_irq_restore(flags); 264 + put_cpu(); 265 + } 266 + 267 + s64 268 + ia64_sal_cache_flush (u64 cache_type) 269 + { 270 + struct ia64_sal_retval isrv; 271 + 272 + if (sal_cache_flush_drops_interrupts) { 273 + unsigned long flags; 274 + u64 progress; 275 + s64 rc; 276 + 277 + progress = 0; 278 + local_irq_save(flags); 279 + rc = ia64_pal_cache_flush(cache_type, 280 + PAL_CACHE_FLUSH_INVALIDATE, &progress, NULL); 281 + local_irq_restore(flags); 282 + return rc; 283 + } 284 + 285 + SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0); 286 + return isrv.status; 287 + } 288 + 218 289 void __init 219 290 ia64_sal_init (struct ia64_sal_systab *systab) 220 291 { ··· 335 262 } 336 263 p += SAL_DESC_SIZE(*p); 337 264 } 265 + 266 + check_sal_cache_flush(); 338 267 } 339 268 340 269 int
+17
include/asm-ia64/processor.h
··· 559 559 560 560 #define cpu_relax() ia64_hint(ia64_hint_pause) 561 561 562 + static inline int 563 + ia64_get_irr(unsigned int vector) 564 + { 565 + unsigned int reg = vector / 64; 566 + unsigned int bit = vector % 64; 567 + u64 irr; 568 + 569 + switch (reg) { 570 + case 0: irr = ia64_getreg(_IA64_REG_CR_IRR0); break; 571 + case 1: irr = ia64_getreg(_IA64_REG_CR_IRR1); break; 572 + case 2: irr = ia64_getreg(_IA64_REG_CR_IRR2); break; 573 + case 3: irr = ia64_getreg(_IA64_REG_CR_IRR3); break; 574 + } 575 + 576 + return test_bit(bit, &irr); 577 + } 578 + 562 579 static inline void 563 580 ia64_set_lrr0 (unsigned long val) 564 581 {
+1 -9
include/asm-ia64/sal.h
··· 658 658 return isrv.status; 659 659 } 660 660 661 - /* Flush all the processor and platform level instruction and/or data caches */ 662 - static inline s64 663 - ia64_sal_cache_flush (u64 cache_type) 664 - { 665 - struct ia64_sal_retval isrv; 666 - SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0); 667 - return isrv.status; 668 - } 669 - 661 + extern s64 ia64_sal_cache_flush (u64 cache_type); 670 662 671 663 /* Initialize all the processor and platform level instruction and data caches */ 672 664 static inline s64