Skip to content

Commit 1edc178

Browse files
sravnborgdavem330
authored andcommitted
sparc32: use flushi when run-time patching in per_cpu_patch
Davis S. Miller wrote: " The way we do that now is overkill. We only needed to use the MMU cache ops when we had sun4c around because sun4c lacked support for the "flush" instruction. But all sun4m and later chips have it so we can use it unconditionally. So in the per_cpu_patch() code, get rid of the cache ops invocation, and instead execute a "flush %reg" after each of the instruction patch assignments, where %reg is set to the address of the instruction that was stored into. Perhaps take the flushi() definition from asm/cacheflush_64.h and place it into asm/cacheflush.h, then you can simply use that. " Implemented as per suggestion. Moved run-time patching before we call paging_init(), so helper methods in paging_init() may utilise run-time patching too. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9cd5f82 commit 1edc178

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎arch/sparc/include/asm/cacheflush.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#ifndef ___ASM_SPARC_CACHEFLUSH_H
22
#define ___ASM_SPARC_CACHEFLUSH_H
3+
4+
/* flush addr - to allow use of self-modifying code */
5+
#define flushi(addr) __asm__ __volatile__ ("flush %0" : : "r" (addr) : "memory")
6+
37
#if defined(__sparc__) && defined(__arch64__)
48
#include <asm/cacheflush_64.h>
59
#else

‎arch/sparc/include/asm/cacheflush_64.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#include <linux/mm.h>
99

1010
/* Cache flush operations. */
11-
12-
13-
#define flushi(addr) __asm__ __volatile__ ("flush %0" : : "r" (addr) : "memory")
1411
#define flushw_all() __asm__ __volatile__("flushw")
1512

1613
extern void __flushw_user(void);

‎arch/sparc/kernel/setup_32.c‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,14 @@ static void __init per_cpu_patch(void)
227227
prom_halt();
228228
}
229229
*(unsigned int *) (addr + 0) = insns[0];
230+
flushi(addr + 0);
230231
*(unsigned int *) (addr + 4) = insns[1];
232+
flushi(addr + 4);
231233
*(unsigned int *) (addr + 8) = insns[2];
234+
flushi(addr + 8);
232235

233236
p++;
234237
}
235-
#ifdef CONFIG_SMP
236-
local_ops->cache_all();
237-
#else
238-
sparc32_cachetlb_ops->cache_all();
239-
#endif
240238
}
241239

242240
enum sparc_cpu sparc_cpu_model;
@@ -340,13 +338,11 @@ void __init setup_arch(char **cmdline_p)
340338
init_mm.context = (unsigned long) NO_CONTEXT;
341339
init_task.thread.kregs = &fake_swapper_regs;
342340

343-
paging_init();
344-
345-
/* Now that we have the cache ops hooked up, we can patch
346-
* instructions.
347-
*/
341+
/* Run-time patch instructions to match the cpu model */
348342
per_cpu_patch();
349343

344+
paging_init();
345+
350346
smp_setup_cpu_possible_map();
351347
}
352348

0 commit comments

Comments
 (0)