[PATCH] ppc64: cleanup iseries runlight support

The iseries has a bar graph on the front panel that shows how busy it is.
The operating system sets and clears a bit in the CTRL register to control
it.

Instead of going to the complexity of using a thread info bit, just set and
clear it in the idle loop.

Also create two helper functions, ppc64_runlatch_on and ppc64_runlatch_off.

Finally don't use the short form of the SPR defines.

Signed-off-by: Anton Blanchard <anton@samba.org>
Acked-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Anton Blanchard and committed by
Linus Torvalds
6dc2f0c7 79f12489

+33 -36
-9
arch/ppc64/kernel/entry.S
··· 436 436 REST_8GPRS(14, r1) 437 437 REST_10GPRS(22, r1) 438 438 439 - #ifdef CONFIG_PPC_ISERIES 440 - clrrdi r7,r1,THREAD_SHIFT /* get current_thread_info() */ 441 - ld r7,TI_FLAGS(r7) /* Get run light flag */ 442 - mfspr r9,CTRLF 443 - srdi r7,r7,TIF_RUN_LIGHT 444 - insrdi r9,r7,1,63 /* Insert run light into CTRL */ 445 - mtspr CTRLT,r9 446 - #endif 447 - 448 439 /* convert old thread to its task_struct for return value */ 449 440 addi r3,r3,-THREAD 450 441 ld r7,_NIP(r1) /* Return to _switch caller in new task */
+5 -5
arch/ppc64/kernel/head.S
··· 626 626 lhz r24,PACAPACAINDEX(r13) /* Get processor # */ 627 627 cmpwi 0,r24,0 /* Are we processor 0? */ 628 628 beq .__start_initialization_iSeries /* Start up the first processor */ 629 - mfspr r4,CTRLF 630 - li r5,RUNLATCH /* Turn off the run light */ 629 + mfspr r4,SPRN_CTRLF 630 + li r5,CTRL_RUNLATCH /* Turn off the run light */ 631 631 andc r4,r4,r5 632 - mtspr CTRLT,r4 632 + mtspr SPRN_CTRLT,r4 633 633 634 634 1: 635 635 HMT_LOW ··· 2082 2082 mfspr r4, HID0 2083 2083 ori r4, r4, 0x1 2084 2084 mtspr HID0, r4 2085 - mfspr r4, CTRLF 2085 + mfspr r4, SPRN_CTRLF 2086 2086 oris r4, r4, 0x40 2087 - mtspr CTRLT, r4 2087 + mtspr SPRN_CTRLT, r4 2088 2088 blr 2089 2089 #endif 2090 2090
+3 -5
arch/ppc64/kernel/idle.c
··· 75 75 { 76 76 struct paca_struct *lpaca; 77 77 long oldval; 78 - unsigned long CTRL; 79 78 80 79 /* ensure iSeries run light will be out when idle */ 81 - clear_thread_flag(TIF_RUN_LIGHT); 82 - CTRL = mfspr(CTRLF); 83 - CTRL &= ~RUNLATCH; 84 - mtspr(CTRLT, CTRL); 80 + ppc64_runlatch_off(); 85 81 86 82 lpaca = get_paca(); 87 83 ··· 107 111 } 108 112 } 109 113 114 + ppc64_runlatch_on(); 110 115 schedule(); 116 + ppc64_runlatch_off(); 111 117 } 112 118 113 119 return 0;
-3
arch/ppc64/kernel/process.c
··· 378 378 childregs->gpr[1] = sp + sizeof(struct pt_regs); 379 379 p->thread.regs = NULL; /* no user register state */ 380 380 clear_ti_thread_flag(p->thread_info, TIF_32BIT); 381 - #ifdef CONFIG_PPC_ISERIES 382 - set_ti_thread_flag(p->thread_info, TIF_RUN_LIGHT); 383 - #endif 384 381 } else { 385 382 childregs->gpr[1] = usp; 386 383 p->thread.regs = childregs;
+2 -6
arch/ppc64/kernel/sysfs.c
··· 113 113 #ifdef CONFIG_PPC_PSERIES 114 114 unsigned long set, reset; 115 115 int ret; 116 - unsigned int ctrl; 117 116 #endif /* CONFIG_PPC_PSERIES */ 118 117 119 118 /* Only need to enable them once */ ··· 166 167 * On SMT machines we have to set the run latch in the ctrl register 167 168 * in order to make PMC6 spin. 168 169 */ 169 - if (cpu_has_feature(CPU_FTR_SMT)) { 170 - ctrl = mfspr(CTRLF); 171 - ctrl |= RUNLATCH; 172 - mtspr(CTRLT, ctrl); 173 - } 170 + if (cpu_has_feature(CPU_FTR_SMT)) 171 + ppc64_runlatch_on(); 174 172 #endif /* CONFIG_PPC_PSERIES */ 175 173 } 176 174
+21 -6
include/asm-ppc64/processor.h
··· 164 164 #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ 165 165 #define SPRN_XER 0x001 /* Fixed Point Exception Register */ 166 166 #define SPRN_VRSAVE 0x100 /* Vector save */ 167 + #define SPRN_CTRLF 0x088 168 + #define SPRN_CTRLT 0x098 169 + #define CTRL_RUNLATCH 0x1 167 170 168 171 /* Performance monitor SPRs */ 169 172 #define SPRN_SIAR 780 ··· 281 278 282 279 #define XGLUE(a,b) a##b 283 280 #define GLUE(a,b) XGLUE(a,b) 284 - 285 - /* iSeries CTRL register (for runlatch) */ 286 - 287 - #define CTRLT 0x098 288 - #define CTRLF 0x088 289 - #define RUNLATCH 0x0001 290 281 291 282 #ifdef __ASSEMBLY__ 292 283 ··· 495 498 #define spin_lock_prefetch(x) prefetchw(x) 496 499 497 500 #define HAVE_ARCH_PICK_MMAP_LAYOUT 501 + 502 + static inline void ppc64_runlatch_on(void) 503 + { 504 + unsigned long ctrl; 505 + 506 + ctrl = mfspr(SPRN_CTRLF); 507 + ctrl |= CTRL_RUNLATCH; 508 + mtspr(SPRN_CTRLT, ctrl); 509 + } 510 + 511 + static inline void ppc64_runlatch_off(void) 512 + { 513 + unsigned long ctrl; 514 + 515 + ctrl = mfspr(SPRN_CTRLF); 516 + ctrl &= ~CTRL_RUNLATCH; 517 + mtspr(SPRN_CTRLT, ctrl); 518 + } 498 519 499 520 #endif /* __KERNEL__ */ 500 521
+2 -2
include/asm-ppc64/thread_info.h
··· 96 96 #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling 97 97 TIF_NEED_RESCHED */ 98 98 #define TIF_32BIT 5 /* 32 bit binary */ 99 - #define TIF_RUN_LIGHT 6 /* iSeries run light */ 99 + /* #define SPARE 6 */ 100 100 #define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */ 101 101 #define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */ 102 102 #define TIF_SINGLESTEP 9 /* singlestepping active */ ··· 110 110 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 111 111 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 112 112 #define _TIF_32BIT (1<<TIF_32BIT) 113 - #define _TIF_RUN_LIGHT (1<<TIF_RUN_LIGHT) 113 + /* #define _SPARE (1<<SPARE) */ 114 114 #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 115 115 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 116 116 #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)