Skip to content

Commit 12c3f1f

Browse files
chleroympe
authored andcommitted
powerpc/32s: get rid of CPU_FTR_601 feature
Now that 601 is exclusive from other 6xx, CPU_FTR_601 and associated fixups are useless. Drop this feature and use #ifdefs instead. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/ecdb7194a17dbfa01865df6a82979533adc2c70b.1566834712.git.christophe.leroy@c-s.fr
1 parent f7a0bf7 commit 12c3f1f

File tree

10 files changed

+52
-79
lines changed

10 files changed

+52
-79
lines changed

arch/powerpc/configs/pmac32_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ CONFIG_CPU_FREQ=y
2020
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
2121
CONFIG_CPU_FREQ_GOV_USERSPACE=y
2222
CONFIG_CPU_FREQ_PMAC=y
23-
CONFIG_PPC601_SYNC_FIX=y
2423
CONFIG_GEN_RTC=y
2524
CONFIG_HIGHMEM=y
2625
CONFIG_BINFMT_MISC=m

arch/powerpc/include/asm/cputable.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ static inline void cpu_feature_keys_init(void) { }
145145

146146
/* Definitions for features that only exist on 32-bit chips */
147147
#ifdef CONFIG_PPC32
148-
#define CPU_FTR_601 ASM_CONST(0x00001000)
149148
#define CPU_FTR_L2CR ASM_CONST(0x00002000)
150149
#define CPU_FTR_SPEC7450 ASM_CONST(0x00004000)
151150
#define CPU_FTR_TAU ASM_CONST(0x00008000)
@@ -167,7 +166,6 @@ static inline void cpu_feature_keys_init(void) { }
167166

168167
#else /* CONFIG_PPC32 */
169168
/* Define these to 0 for the sake of tests in common code */
170-
#define CPU_FTR_601 (0)
171169
#define CPU_FTR_PPC_LE (0)
172170
#endif
173171

@@ -294,7 +292,7 @@ static inline void cpu_feature_keys_init(void) { }
294292
#define CPU_FTR_MAYBE_CAN_NAP 0
295293
#endif
296294

297-
#define CPU_FTRS_PPC601 (CPU_FTR_COMMON | CPU_FTR_601 | \
295+
#define CPU_FTRS_PPC601 (CPU_FTR_COMMON | \
298296
CPU_FTR_COHERENT_ICACHE | CPU_FTR_UNIFIED_ID_CACHE | CPU_FTR_USE_RTC)
299297
#define CPU_FTRS_603 (CPU_FTR_COMMON | CPU_FTR_MAYBE_CAN_DOZE | \
300298
CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_PPC_LE | CPU_FTR_NOEXECUTE)
@@ -498,7 +496,9 @@ static inline void cpu_feature_keys_init(void) { }
498496
#else
499497
enum {
500498
CPU_FTRS_POSSIBLE =
501-
#ifdef CONFIG_PPC_BOOK3S_32
499+
#ifdef CONFIG_PPC_BOOK3S_601
500+
CPU_FTRS_PPC601 |
501+
#elif defined(CONFIG_PPC_BOOK3S_32)
502502
CPU_FTRS_PPC601 | CPU_FTRS_603 | CPU_FTRS_604 | CPU_FTRS_740_NOTAU |
503503
CPU_FTRS_740 | CPU_FTRS_750 | CPU_FTRS_750FX1 |
504504
CPU_FTRS_750FX2 | CPU_FTRS_750FX | CPU_FTRS_750GX |
@@ -574,8 +574,10 @@ enum {
574574
#else
575575
enum {
576576
CPU_FTRS_ALWAYS =
577-
#ifdef CONFIG_PPC_BOOK3S_32
578-
CPU_FTRS_PPC601 & CPU_FTRS_603 & CPU_FTRS_604 & CPU_FTRS_740_NOTAU &
577+
#ifdef CONFIG_PPC_BOOK3S_601
578+
CPU_FTRS_PPC601 &
579+
#elif defined(CONFIG_PPC_BOOK3S_32)
580+
CPU_FTRS_603 & CPU_FTRS_604 & CPU_FTRS_740_NOTAU &
579581
CPU_FTRS_740 & CPU_FTRS_750 & CPU_FTRS_750FX1 &
580582
CPU_FTRS_750FX2 & CPU_FTRS_750FX & CPU_FTRS_750GX &
581583
CPU_FTRS_7400_NOTAU & CPU_FTRS_7400 & CPU_FTRS_7450_20 &

arch/powerpc/include/asm/ppc_asm.h

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -383,19 +383,9 @@ GLUE(.,name):
383383

384384
/* various errata or part fixups */
385385
#ifdef CONFIG_PPC601_SYNC_FIX
386-
#define SYNC \
387-
BEGIN_FTR_SECTION \
388-
sync; \
389-
isync; \
390-
END_FTR_SECTION_IFSET(CPU_FTR_601)
391-
#define SYNC_601 \
392-
BEGIN_FTR_SECTION \
393-
sync; \
394-
END_FTR_SECTION_IFSET(CPU_FTR_601)
395-
#define ISYNC_601 \
396-
BEGIN_FTR_SECTION \
397-
isync; \
398-
END_FTR_SECTION_IFSET(CPU_FTR_601)
386+
#define SYNC sync; isync
387+
#define SYNC_601 sync
388+
#define ISYNC_601 isync
399389
#else
400390
#define SYNC
401391
#define SYNC_601
@@ -421,15 +411,11 @@ END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96)
421411
#define MFTBU(dest) mfspr dest, SPRN_TBRU
422412
#endif
423413

424-
#ifndef CONFIG_SMP
425-
#define TLBSYNC
426-
#else /* CONFIG_SMP */
427414
/* tlbsync is not implemented on 601 */
428-
#define TLBSYNC \
429-
BEGIN_FTR_SECTION \
430-
tlbsync; \
431-
sync; \
432-
END_FTR_SECTION_IFCLR(CPU_FTR_601)
415+
#if !defined(CONFIG_SMP) || defined(CONFIG_PPC_BOOK3S_601)
416+
#define TLBSYNC
417+
#else
418+
#define TLBSYNC tlbsync; sync
433419
#endif
434420

435421
#ifdef CONFIG_PPC64

arch/powerpc/include/asm/ptrace.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ do { \
203203
#endif /* __powerpc64__ */
204204

205205
#define arch_has_single_step() (1)
206-
#define arch_has_block_step() (!cpu_has_feature(CPU_FTR_601))
206+
#ifndef CONFIG_BOOK3S_601
207+
#define arch_has_block_step() (true)
208+
#else
209+
#define arch_has_block_step() (false)
210+
#endif
207211
#define ARCH_HAS_USER_SINGLE_STEP_REPORT
208212

209213
/*

arch/powerpc/include/asm/timex.h

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,10 @@ typedef unsigned long cycles_t;
1717

1818
static inline cycles_t get_cycles(void)
1919
{
20-
#ifdef __powerpc64__
20+
if (IS_ENABLED(CONFIG_BOOK3S_601))
21+
return 0;
22+
2123
return mftb();
22-
#else
23-
cycles_t ret;
24-
25-
/*
26-
* For the "cycle" counter we use the timebase lower half.
27-
* Currently only used on SMP.
28-
*/
29-
30-
ret = 0;
31-
32-
__asm__ __volatile__(
33-
#ifdef CONFIG_PPC_8xx
34-
"97: mftb %0\n"
35-
#else
36-
"97: mfspr %0, %2\n"
37-
#endif
38-
"99:\n"
39-
".section __ftr_fixup,\"a\"\n"
40-
".align 2\n"
41-
"98:\n"
42-
" .long %1\n"
43-
" .long 0\n"
44-
" .long 97b-98b\n"
45-
" .long 99b-98b\n"
46-
" .long 0\n"
47-
" .long 0\n"
48-
".previous"
49-
: "=r" (ret) : "i" (CPU_FTR_601), "i" (SPRN_TBRL));
50-
return ret;
51-
#endif
5224
}
5325

5426
#endif /* __KERNEL__ */

arch/powerpc/kernel/cputable.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
569569
#endif /* CONFIG_PPC_BOOK3S_64 */
570570

571571
#ifdef CONFIG_PPC32
572-
#ifdef CONFIG_PPC_BOOK3S_32
572+
#ifdef CONFIG_PPC_BOOK3S_601
573573
{ /* 601 */
574574
.pvr_mask = 0xffff0000,
575575
.pvr_value = 0x00010000,
@@ -583,6 +583,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
583583
.machine_check = machine_check_generic,
584584
.platform = "ppc601",
585585
},
586+
#endif /* CONFIG_PPC_BOOK3S_601 */
587+
#ifdef CONFIG_PPC_BOOK3S_6xx
586588
{ /* 603 */
587589
.pvr_mask = 0xffff0000,
588590
.pvr_value = 0x00030000,
@@ -1212,7 +1214,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
12121214
.machine_check = machine_check_generic,
12131215
.platform = "ppc603",
12141216
},
1215-
#endif /* CONFIG_PPC_BOOK3S_32 */
1217+
#endif /* CONFIG_PPC_BOOK3S_6xx */
12161218
#ifdef CONFIG_PPC_8xx
12171219
{ /* 8xx */
12181220
.pvr_mask = 0xffff0000,

arch/powerpc/kernel/entry_32.S

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,19 @@ fast_exception_return:
777777
1: lis r3,exc_exit_restart_end@ha
778778
addi r3,r3,exc_exit_restart_end@l
779779
cmplw r12,r3
780+
#if CONFIG_PPC_BOOK3S_601
781+
bge 2b
782+
#else
780783
bge 3f
784+
#endif
781785
lis r4,exc_exit_restart@ha
782786
addi r4,r4,exc_exit_restart@l
783787
cmplw r12,r4
788+
#if CONFIG_PPC_BOOK3S_601
789+
blt 2b
790+
#else
784791
blt 3f
792+
#endif
785793
lis r3,fee_restarts@ha
786794
tophys(r3,r3)
787795
lwz r5,fee_restarts@l(r3)
@@ -800,9 +808,6 @@ fee_restarts:
800808
/* aargh, we don't know which trap this is */
801809
/* but the 601 doesn't implement the RI bit, so assume it's OK */
802810
3:
803-
BEGIN_FTR_SECTION
804-
b 2b
805-
END_FTR_SECTION_IFSET(CPU_FTR_601)
806811
li r10,-1
807812
stw r10,_TRAP(r11)
808813
addi r3,r1,STACK_FRAME_OVERHEAD
@@ -1270,11 +1275,19 @@ nonrecoverable:
12701275
lis r10,exc_exit_restart_end@ha
12711276
addi r10,r10,exc_exit_restart_end@l
12721277
cmplw r12,r10
1278+
#ifdef CONFIG_PPC_BOOK3S_601
1279+
bgelr
1280+
#else
12731281
bge 3f
1282+
#endif
12741283
lis r11,exc_exit_restart@ha
12751284
addi r11,r11,exc_exit_restart@l
12761285
cmplw r12,r11
1286+
#ifdef CONFIG_PPC_BOOK3S_601
1287+
bltlr
1288+
#else
12771289
blt 3f
1290+
#endif
12781291
lis r10,ee_restarts@ha
12791292
lwz r12,ee_restarts@l(r10)
12801293
addi r12,r12,1
@@ -1283,9 +1296,6 @@ nonrecoverable:
12831296
blr
12841297
3: /* OK, we can't recover, kill this process */
12851298
/* but the 601 doesn't implement the RI bit, so assume it's OK */
1286-
BEGIN_FTR_SECTION
1287-
blr
1288-
END_FTR_SECTION_IFSET(CPU_FTR_601)
12891299
lwz r3,_TRAP(r1)
12901300
andi. r0,r3,1
12911301
beq 5f

arch/powerpc/mm/book3s32/mmu.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int find_free_bat(void)
7474
{
7575
int b;
7676

77-
if (cpu_has_feature(CPU_FTR_601)) {
77+
if (IS_ENABLED(CONFIG_PPC_BOOK3S_601)) {
7878
for (b = 0; b < 4; b++) {
7979
struct ppc_bat *bat = BATS[b];
8080

@@ -106,7 +106,7 @@ static int find_free_bat(void)
106106
*/
107107
static unsigned int block_size(unsigned long base, unsigned long top)
108108
{
109-
unsigned int max_size = (cpu_has_feature(CPU_FTR_601) ? 8 : 256) << 20;
109+
unsigned int max_size = IS_ENABLED(CONFIG_PPC_BOOK3S_601) ? SZ_8M : SZ_256M;
110110
unsigned int base_shift = (ffs(base) - 1) & 31;
111111
unsigned int block_shift = (fls(top - base) - 1) & 31;
112112

@@ -189,7 +189,7 @@ void mmu_mark_initmem_nx(void)
189189
unsigned long top = (unsigned long)_etext - PAGE_OFFSET;
190190
unsigned long size;
191191

192-
if (cpu_has_feature(CPU_FTR_601))
192+
if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
193193
return;
194194

195195
for (i = 0; i < nb - 1 && base < top && top - base > (128 << 10);) {
@@ -227,7 +227,7 @@ void mmu_mark_rodata_ro(void)
227227
int nb = mmu_has_feature(MMU_FTR_USE_HIGH_BATS) ? 8 : 4;
228228
int i;
229229

230-
if (cpu_has_feature(CPU_FTR_601))
230+
if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
231231
return;
232232

233233
for (i = 0; i < nb; i++) {
@@ -259,7 +259,7 @@ void __init setbat(int index, unsigned long virt, phys_addr_t phys,
259259
flags &= ~_PAGE_COHERENT;
260260

261261
bl = (size >> 17) - 1;
262-
if (PVR_VER(mfspr(SPRN_PVR)) != 1) {
262+
if (!IS_ENABLED(CONFIG_PPC_BOOK3S_601)) {
263263
/* 603, 604, etc. */
264264
/* Do DBAT first */
265265
wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
@@ -441,7 +441,7 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,
441441
BUG_ON(first_memblock_base != 0);
442442

443443
/* 601 can only access 16MB at the moment */
444-
if (PVR_VER(mfspr(SPRN_PVR)) == 1)
444+
if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
445445
memblock_set_current_limit(min_t(u64, first_memblock_size, 0x01000000));
446446
else /* Anything else has 256M mapped */
447447
memblock_set_current_limit(min_t(u64, first_memblock_size, 0x10000000));
@@ -459,9 +459,6 @@ void __init setup_kuep(bool disabled)
459459
{
460460
pr_info("Activating Kernel Userspace Execution Prevention\n");
461461

462-
if (cpu_has_feature(CPU_FTR_601))
463-
pr_warn("KUEP is not working on powerpc 601 (No NX bit in Seg Regs)\n");
464-
465462
if (disabled)
466463
pr_warn("KUEP cannot be disabled yet on 6xx when compiled in\n");
467464
}

arch/powerpc/mm/ptdump/bats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int bats_show_603(struct seq_file *m, void *v)
149149

150150
static int bats_open(struct inode *inode, struct file *file)
151151
{
152-
if (cpu_has_feature(CPU_FTR_601))
152+
if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
153153
return single_open(file, bats_show_601, NULL);
154154

155155
return single_open(file, bats_show_603, NULL);

arch/powerpc/platforms/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ endmenu
197197

198198
config PPC601_SYNC_FIX
199199
bool "Workarounds for PPC601 bugs"
200-
depends on PPC_BOOK3S_32 && PPC_PMAC
200+
depends on PPC_BOOK3S_601 && PPC_PMAC
201+
default y
201202
help
202203
Some versions of the PPC601 (the first PowerPC chip) have bugs which
203204
mean that extra synchronization instructions are required near

0 commit comments

Comments
 (0)