[IA64] Fix CONFIG_PRINTK_TIME

There were two problems with enabling the PRINTK_TIME config
option:
1) The first calls to printk() occur before per-cpu data virtual
address is pinned into the TLB, so sched_clock() can fault.
2) sched_clock() is based on ar.itc, which may not be synchronized
across cpus.

Ken Chen started this patch, Tony Luck tinkered with it, and Jes
Sorensen perfected it.

Signed-off-by: Tony Luck <tony.luck@intel.com>

Tony Luck d6e56a2a 9d78f43d

+59 -13
+1
arch/ia64/kernel/head.S
··· 352 352 mov ar.rsc=0 // place RSE in enforced lazy mode 353 353 ;; 354 354 loadrs // clear the dirty partition 355 + mov IA64_KR(PER_CPU_DATA)=r0 // clear physical per-CPU base 355 356 ;; 356 357 mov ar.bspstore=r2 // establish the new RSE stack 357 358 ;;
+4
arch/ia64/kernel/setup.c
··· 71 71 EXPORT_SYMBOL(__per_cpu_offset); 72 72 #endif 73 73 74 + extern void ia64_setup_printk_clock(void); 75 + 74 76 DEFINE_PER_CPU(struct cpuinfo_ia64, cpu_info); 75 77 DEFINE_PER_CPU(unsigned long, local_per_cpu_offset); 76 78 DEFINE_PER_CPU(unsigned long, ia64_phys_stacked_size_p8); ··· 446 444 447 445 /* process SAL system table: */ 448 446 ia64_sal_init(efi.sal_systab); 447 + 448 + ia64_setup_printk_clock(); 449 449 450 450 #ifdef CONFIG_SMP 451 451 cpu_physical_id(0) = hard_smp_processor_id();
+27
arch/ia64/kernel/time.c
··· 278 278 } 279 279 } 280 280 EXPORT_SYMBOL(udelay); 281 + 282 + static unsigned long long ia64_itc_printk_clock(void) 283 + { 284 + if (ia64_get_kr(IA64_KR_PER_CPU_DATA)) 285 + return sched_clock(); 286 + return 0; 287 + } 288 + 289 + static unsigned long long ia64_default_printk_clock(void) 290 + { 291 + return (unsigned long long)(jiffies_64 - INITIAL_JIFFIES) * 292 + (1000000000/HZ); 293 + } 294 + 295 + unsigned long long (*ia64_printk_clock)(void) = &ia64_default_printk_clock; 296 + 297 + unsigned long long printk_clock(void) 298 + { 299 + return ia64_printk_clock(); 300 + } 301 + 302 + void __init 303 + ia64_setup_printk_clock(void) 304 + { 305 + if (!(sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)) 306 + ia64_printk_clock = ia64_itc_printk_clock; 307 + }
+27 -13
arch/ia64/sn/kernel/setup.c
··· 67 67 extern void (*ia64_mark_idle) (int); 68 68 extern void snidle(int); 69 69 extern unsigned char acpi_kbd_controller_present; 70 + extern unsigned long long (*ia64_printk_clock)(void); 70 71 71 72 unsigned long sn_rtc_cycles_per_second; 72 73 EXPORT_SYMBOL(sn_rtc_cycles_per_second); ··· 373 372 } 374 373 } 375 374 375 + static unsigned long sn2_rtc_initial; 376 + 377 + static unsigned long long ia64_sn2_printk_clock(void) 378 + { 379 + unsigned long rtc_now = rtc_time(); 380 + 381 + return (rtc_now - sn2_rtc_initial) * 382 + (1000000000 / sn_rtc_cycles_per_second); 383 + } 384 + 376 385 /** 377 386 * sn_setup - SN platform setup routine 378 387 * @cmdline_p: kernel command line ··· 397 386 u32 version = sn_sal_rev(); 398 387 extern void sn_cpu_init(void); 399 388 389 + sn2_rtc_initial = rtc_time(); 400 390 ia64_sn_plat_set_error_handling_features(); // obsolete 401 391 ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV); 402 392 ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES); ··· 449 437 */ 450 438 build_cnode_tables(); 451 439 452 - /* 453 - * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard 454 - * support here so we don't have to listen to failed keyboard probe 455 - * messages. 456 - */ 457 - if (version <= 0x0209 && acpi_kbd_controller_present) { 458 - printk(KERN_INFO "Disabling legacy keyboard support as prom " 459 - "is too old and doesn't provide FADT\n"); 460 - acpi_kbd_controller_present = 0; 461 - } 462 - 463 - printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF); 464 - 465 440 status = 466 441 ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec, 467 442 &drift); ··· 461 462 sn_rtc_cycles_per_second = ticks_per_sec; 462 463 463 464 platform_intr_list[ACPI_INTERRUPT_CPEI] = IA64_CPE_VECTOR; 465 + 466 + ia64_printk_clock = ia64_sn2_printk_clock; 467 + 468 + /* 469 + * Old PROMs do not provide an ACPI FADT. Disable legacy keyboard 470 + * support here so we don't have to listen to failed keyboard probe 471 + * messages. 472 + */ 473 + if (version <= 0x0209 && acpi_kbd_controller_present) { 474 + printk(KERN_INFO "Disabling legacy keyboard support as prom " 475 + "is too old and doesn't provide FADT\n"); 476 + acpi_kbd_controller_present = 0; 477 + } 478 + 479 + printk("SGI SAL version %x.%02x\n", version >> 8, version & 0x00FF); 464 480 465 481 /* 466 482 * we set the default root device to /dev/hda