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

ARC: Code cosmetics (Nothing semantical)

* reduce editor lines taken by pt_regs
* ARCompact ISA specific part of TLB Miss handlers clubbed together
* cleanup some comments

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

+77 -104
+7 -29
arch/arc/include/asm/ptrace.h
··· 20 20 21 21 /* Real registers */ 22 22 long bta; /* bta_l1, bta_l2, erbta */ 23 - long lp_start; 24 - long lp_end; 25 - long lp_count; 23 + 24 + long lp_start, lp_end, lp_count; 25 + 26 26 long status32; /* status32_l1, status32_l2, erstatus */ 27 27 long ret; /* ilink1, ilink2 or eret */ 28 28 long blink; 29 29 long fp; 30 30 long r26; /* gp */ 31 - long r12; 32 - long r11; 33 - long r10; 34 - long r9; 35 - long r8; 36 - long r7; 37 - long r6; 38 - long r5; 39 - long r4; 40 - long r3; 41 - long r2; 42 - long r1; 43 - long r0; 31 + 32 + long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0; 33 + 44 34 long sp; /* user/kernel sp depending on where we came from */ 45 35 long orig_r0; 46 36 ··· 60 70 /* Callee saved registers - need to be saved only when you are scheduled out */ 61 71 62 72 struct callee_regs { 63 - long r25; 64 - long r24; 65 - long r23; 66 - long r22; 67 - long r21; 68 - long r20; 69 - long r19; 70 - long r18; 71 - long r17; 72 - long r16; 73 - long r15; 74 - long r14; 75 - long r13; 73 + long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13; 76 74 }; 77 75 78 76 #define instruction_pointer(regs) ((regs)->ret)
+3 -3
arch/arc/include/asm/spinlock_types.h
··· 20 20 #define __ARCH_SPIN_LOCK_LOCKED { __ARCH_SPIN_LOCK_LOCKED__ } 21 21 22 22 /* 23 - * Unlocked: 0x01_00_00_00 24 - * Read lock(s): 0x00_FF_00_00 to say 0x01 25 - * Write lock: 0x0, but only possible if prior value "unlocked" 0x0100_0000 23 + * Unlocked : 0x0100_0000 24 + * Read lock(s) : 0x00FF_FFFF to 0x01 (Multiple Readers decrement it) 25 + * Write lock : 0x0, but only if prior value is "unlocked" 0x0100_0000 26 26 */ 27 27 typedef struct { 28 28 volatile unsigned int counter;
+4 -4
arch/arc/mm/cache_arc700.c
··· 622 622 /* 623 623 * General purpose helper to make I and D cache lines consistent. 624 624 * @paddr is phy addr of region 625 - * @vaddr is typically user or kernel vaddr (vmalloc) 626 - * Howver in one instance, flush_icache_range() by kprobe (for a breakpt in 625 + * @vaddr is typically user vaddr (breakpoint) or kernel vaddr (vmalloc) 626 + * However in one instance, when called by kprobe (for a breakpt in 627 627 * builtin kernel code) @vaddr will be paddr only, meaning CDU operation will 628 628 * use a paddr to index the cache (despite VIPT). This is fine since since a 629 - * built-in kernel page will not have any virtual mappings (not even kernel) 630 - * kprobe on loadable module is different as it will have kvaddr. 629 + * builtin kernel page will not have any virtual mappings. 630 + * kprobe on loadable module will be kernel vaddr. 631 631 */ 632 632 void __sync_icache_dcache(unsigned long paddr, unsigned long vaddr, int len) 633 633 {
+63 -68
arch/arc/mm/tlbex.S
··· 44 44 #include <asm/arcregs.h> 45 45 #include <asm/cache.h> 46 46 #include <asm/processor.h> 47 - #if (CONFIG_ARC_MMU_VER == 1) 48 47 #include <asm/tlb-mmu1.h> 49 - #endif 50 48 51 - ;-------------------------------------------------------------------------- 52 - ; scratch memory to save the registers (r0-r3) used to code TLB refill Handler 53 - ; For details refer to comments before TLBMISS_FREEUP_REGS below 49 + ;----------------------------------------------------------------- 50 + ; ARC700 Exception Handling doesn't auto-switch stack and it only provides 51 + ; ONE scratch AUX reg "ARC_REG_SCRATCH_DATA0" 52 + ; 53 + ; For Non-SMP, the scratch AUX reg is repurposed to cache task PGD, so a 54 + ; "global" is used to free-up FIRST core reg to be able to code the rest of 55 + ; exception prologue (IRQ auto-disabled on Exceptions, so it's IRQ-safe). 56 + ; Since the Fast Path TLB Miss handler is coded with 4 regs, the remaining 3 57 + ; need to be saved as well by extending the "global" to be 4 words. Hence 58 + ; ".size ex_saved_reg1, 16" 59 + ; [All of this dance is to avoid stack switching for each TLB Miss, since we 60 + ; only need to save only a handful of regs, as opposed to complete reg file] 61 + ; 62 + ; For ARC700 SMP, the "global" obviously can't be used for free up the FIRST 63 + ; core reg as it will not be SMP safe. 64 + ; Thus scratch AUX reg is used (and no longer used to cache task PGD). 65 + ; To save the rest of 3 regs - per cpu, the global is made "per-cpu". 66 + ; Epilogue thus has to locate the "per-cpu" storage for regs. 67 + ; To avoid cache line bouncing the per-cpu global is aligned/sized per 68 + ; L1_CACHE_SHIFT, despite fundamentally needing to be 12 bytes only. Hence 69 + ; ".size ex_saved_reg1, (CONFIG_NR_CPUS << L1_CACHE_SHIFT)" 70 + 71 + ; As simple as that.... 54 72 ;-------------------------------------------------------------------------- 55 73 74 + ; scratch memory to save [r0-r3] used to code TLB refill Handler 56 75 ARCFP_DATA ex_saved_reg1 57 - .align 1 << L1_CACHE_SHIFT ; IMP: Must be Cache Line aligned 76 + .align 1 << L1_CACHE_SHIFT 58 77 .type ex_saved_reg1, @object 59 78 #ifdef CONFIG_SMP 60 79 .size ex_saved_reg1, (CONFIG_NR_CPUS << L1_CACHE_SHIFT) ··· 84 65 ex_saved_reg1: 85 66 .zero 16 86 67 #endif 68 + 69 + .macro TLBMISS_FREEUP_REGS 70 + #ifdef CONFIG_SMP 71 + sr r0, [ARC_REG_SCRATCH_DATA0] ; freeup r0 to code with 72 + GET_CPU_ID r0 ; get to per cpu scratch mem, 73 + lsl r0, r0, L1_CACHE_SHIFT ; cache line wide per cpu 74 + add r0, @ex_saved_reg1, r0 75 + #else 76 + st r0, [@ex_saved_reg1] 77 + mov_s r0, @ex_saved_reg1 78 + #endif 79 + st_s r1, [r0, 4] 80 + st_s r2, [r0, 8] 81 + st_s r3, [r0, 12] 82 + 83 + ; VERIFY if the ASID in MMU-PID Reg is same as 84 + ; one in Linux data structures 85 + 86 + DBG_ASID_MISMATCH 87 + .endm 88 + 89 + .macro TLBMISS_RESTORE_REGS 90 + #ifdef CONFIG_SMP 91 + GET_CPU_ID r0 ; get to per cpu scratch mem 92 + lsl r0, r0, L1_CACHE_SHIFT ; each is cache line wide 93 + add r0, @ex_saved_reg1, r0 94 + ld_s r3, [r0,12] 95 + ld_s r2, [r0, 8] 96 + ld_s r1, [r0, 4] 97 + lr r0, [ARC_REG_SCRATCH_DATA0] 98 + #else 99 + mov_s r0, @ex_saved_reg1 100 + ld_s r3, [r0,12] 101 + ld_s r2, [r0, 8] 102 + ld_s r1, [r0, 4] 103 + ld_s r0, [r0] 104 + #endif 105 + .endm 87 106 88 107 ;============================================================================ 89 108 ; Troubleshooting Stuff ··· 248 191 #endif 249 192 .endm 250 193 251 - ;----------------------------------------------------------------- 252 - ; ARC700 Exception Handling doesn't auto-switch stack and it only provides 253 - ; ONE scratch AUX reg "ARC_REG_SCRATCH_DATA0" 254 - ; 255 - ; For Non-SMP, the scratch AUX reg is repurposed to cache task PGD, so a 256 - ; "global" is used to free-up FIRST core reg to be able to code the rest of 257 - ; exception prologue (IRQ auto-disabled on Exceptions, so it's IRQ-safe). 258 - ; Since the Fast Path TLB Miss handler is coded with 4 regs, the remaining 3 259 - ; need to be saved as well by extending the "global" to be 4 words. Hence 260 - ; ".size ex_saved_reg1, 16" 261 - ; [All of this dance is to avoid stack switching for each TLB Miss, since we 262 - ; only need to save only a handful of regs, as opposed to complete reg file] 263 - ; 264 - ; For ARC700 SMP, the "global" obviously can't be used for free up the FIRST 265 - ; core reg as it will not be SMP safe. 266 - ; Thus scratch AUX reg is used (and no longer used to cache task PGD). 267 - ; To save the rest of 3 regs - per cpu, the global is made "per-cpu". 268 - ; Epilogue thus has to locate the "per-cpu" storage for regs. 269 - ; To avoid cache line bouncing the per-cpu global is aligned/sized per 270 - ; L1_CACHE_SHIFT, despite fundamentally needing to be 12 bytes only. Hence 271 - ; ".size ex_saved_reg1, (CONFIG_NR_CPUS << L1_CACHE_SHIFT)" 272 - 273 - ; As simple as that.... 274 - 275 - .macro TLBMISS_FREEUP_REGS 276 - #ifdef CONFIG_SMP 277 - sr r0, [ARC_REG_SCRATCH_DATA0] ; freeup r0 to code with 278 - GET_CPU_ID r0 ; get to per cpu scratch mem, 279 - lsl r0, r0, L1_CACHE_SHIFT ; cache line wide per cpu 280 - add r0, @ex_saved_reg1, r0 281 - #else 282 - st r0, [@ex_saved_reg1] 283 - mov_s r0, @ex_saved_reg1 284 - #endif 285 - st_s r1, [r0, 4] 286 - st_s r2, [r0, 8] 287 - st_s r3, [r0, 12] 288 - 289 - ; VERIFY if the ASID in MMU-PID Reg is same as 290 - ; one in Linux data structures 291 - 292 - DBG_ASID_MISMATCH 293 - .endm 294 - 295 - ;----------------------------------------------------------------- 296 - .macro TLBMISS_RESTORE_REGS 297 - #ifdef CONFIG_SMP 298 - GET_CPU_ID r0 ; get to per cpu scratch mem 299 - lsl r0, r0, L1_CACHE_SHIFT ; each is cache line wide 300 - add r0, @ex_saved_reg1, r0 301 - ld_s r3, [r0,12] 302 - ld_s r2, [r0, 8] 303 - ld_s r1, [r0, 4] 304 - lr r0, [ARC_REG_SCRATCH_DATA0] 305 - #else 306 - mov_s r0, @ex_saved_reg1 307 - ld_s r3, [r0,12] 308 - ld_s r2, [r0, 8] 309 - ld_s r1, [r0, 4] 310 - ld_s r0, [r0] 311 - #endif 312 - .endm 313 194 314 195 ARCFP_CODE ;Fast Path Code, candidate for ICCM 315 196