Skip to content

Commit 5fcafb7

Browse files
daniel-hellstromdavem330
authored andcommitted
sparc32: always define boot_cpu_id
Define boot_cpu_id in single-processor kernels as well. This is to support architectures which can boot on other than CPU0. Sam Ravnborg has written the cleanup parts by extracting boot_cpu_id from smp_32.c into setup_32.c and cleaned up sun4d_irq.c. boot_cpu_id was initialized before BSS was cleared in sun4c_continue_boot, instead boot_cpu_id is set to 0xff to avoid BSS. If boot_cpu_id is untouched (0xff) by bootup code it will be overwritten to 0. boot_cpu_id4 is automatically calculated in common code. Signed-off-by: Daniel Hellstrom <daniel@gaisler.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1827237 commit 5fcafb7

5 files changed

Lines changed: 35 additions & 14 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@
1111
# define COMMAND_LINE_SIZE 256
1212
#endif
1313

14+
#ifdef __KERNEL__
15+
16+
#ifdef CONFIG_SPARC32
17+
/* The CPU that was used for booting
18+
* Only sun4d + leon may have boot_cpu_id != 0
19+
*/
20+
extern unsigned char boot_cpu_id;
21+
extern unsigned char boot_cpu_id4;
22+
#endif
23+
24+
#endif /* __KERNEL__ */
25+
1426
#endif /* _SPARC_SETUP_H */

‎arch/sparc/kernel/head_32.S‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,7 @@ got_prop:
816816

817817
.global leon_smp_init
818818
leon_smp_init:
819-
sethi %hi(boot_cpu_id), %g1 ! master always 0
820-
stb %g0, [%g1 + %lo(boot_cpu_id)]
821-
sethi %hi(boot_cpu_id4), %g1 ! master always 0
822-
stb %g0, [%g1 + %lo(boot_cpu_id4)]
819+
/* let boot_cpu_id default to 0 (master always 0) */
823820

824821
rd %asr17,%g1
825822
srl %g1,28,%g1
@@ -893,9 +890,6 @@ sun4d_init:
893890
sta %g4, [%g0] ASI_M_VIKING_TMP1
894891
sethi %hi(boot_cpu_id), %g5
895892
stb %g4, [%g5 + %lo(boot_cpu_id)]
896-
sll %g4, 2, %g4
897-
sethi %hi(boot_cpu_id4), %g5
898-
stb %g4, [%g5 + %lo(boot_cpu_id4)]
899893
#endif
900894

901895
/* Fall through to sun4m_init */
@@ -1024,14 +1018,28 @@ sun4c_continue_boot:
10241018
bl 1b
10251019
add %o0, 0x1, %o0
10261020

1021+
/* If boot_cpu_id has not been setup by machine specific
1022+
* init-code above we default it to zero.
1023+
*/
1024+
sethi %hi(boot_cpu_id), %g2
1025+
ldub [%g2 + %lo(boot_cpu_id)], %g3
1026+
cmp %g3, 0xff
1027+
bne 1f
1028+
nop
1029+
mov %g0, %g3
1030+
stub %g3, [%g2 + %lo(boot_cpu_id)]
1031+
1032+
1: /* boot_cpu_id set. calculate boot_cpu_id4 = boot_cpu_id*4 */
1033+
sll %g3, 2, %g3
1034+
sethi %hi(boot_cpu_id4), %g2
1035+
stub %g3, [%g2 + %lo(boot_cpu_id4)]
1036+
10271037
/* Initialize the uwinmask value for init task just in case.
10281038
* But first make current_set[boot_cpu_id] point to something useful.
10291039
*/
10301040
set init_thread_union, %g6
10311041
set current_set, %g2
10321042
#ifdef CONFIG_SMP
1033-
sethi %hi(boot_cpu_id4), %g3
1034-
ldub [%g3 + %lo(boot_cpu_id4)], %g3
10351043
st %g6, [%g2]
10361044
add %g2, %g3, %g2
10371045
#endif

‎arch/sparc/kernel/setup_32.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ static unsigned int boot_flags __initdata = 0;
103103
/* Exported for mm/init.c:paging_init. */
104104
unsigned long cmdline_memory_size __initdata = 0;
105105

106+
/* which CPU booted us (0xff = not set) */
107+
unsigned char boot_cpu_id = 0xff; /* 0xff will make it into DATA section... */
108+
unsigned char boot_cpu_id4; /* boot_cpu_id << 2 */
109+
106110
static void
107111
prom_console_write(struct console *con, const char *s, unsigned n)
108112
{

‎arch/sparc/kernel/smp_32.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "irq.h"
3838

3939
volatile unsigned long cpu_callin_map[NR_CPUS] __cpuinitdata = {0,};
40-
unsigned char boot_cpu_id = 0;
41-
unsigned char boot_cpu_id4 = 0; /* boot_cpu_id << 2 */
4240

4341
cpumask_t smp_commenced_mask = CPU_MASK_NONE;
4442

‎arch/sparc/kernel/sun4d_irq.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/io.h>
1515
#include <asm/sbi.h>
1616
#include <asm/cacheflush.h>
17+
#include <asm/setup.h>
1718

1819
#include "kernel.h"
1920
#include "irq.h"
@@ -438,11 +439,9 @@ static void __init sun4d_init_timers(irq_handler_t counter_fn)
438439
void __init sun4d_init_sbi_irq(void)
439440
{
440441
struct device_node *dp;
441-
int target_cpu = 0;
442+
int target_cpu;
442443

443-
#ifdef CONFIG_SMP
444444
target_cpu = boot_cpu_id;
445-
#endif
446445
for_each_node_by_name(dp, "sbi") {
447446
int devid = of_getintprop_default(dp, "device-id", 0);
448447
int board = of_getintprop_default(dp, "board#", 0);

0 commit comments

Comments
 (0)