Skip to content

Commit 01dae0f

Browse files
daniel-hellstromdavem330
authored andcommitted
sparc32,leon: operate on boot-cpu IRQ controller registers
* proper initialization of boot_cpu_id (no hardcoding to 0) * use boot_cpu_id index to address into the IRQ controller where appropriate Each CPU has a separate set of IRQ controller registers, this patch makes sure that the boot-cpu registers are used instead of CPU0's. Signed-off-by: Daniel Hellstrom <daniel@gaisler.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5fcafb7 commit 01dae0f

3 files changed

Lines changed: 21 additions & 25 deletions

File tree

‎arch/sparc/kernel/head_32.S‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -810,27 +810,24 @@ found_version:
810810
got_prop:
811811
#ifdef CONFIG_SPARC_LEON
812812
/* no cpu-type check is needed, it is a SPARC-LEON */
813-
#ifdef CONFIG_SMP
814-
ba leon_smp_init
815-
nop
816813

817-
.global leon_smp_init
818-
leon_smp_init:
819-
/* let boot_cpu_id default to 0 (master always 0) */
814+
sethi %hi(boot_cpu_id), %g2 ! boot-cpu index
820815

821-
rd %asr17,%g1
822-
srl %g1,28,%g1
816+
#ifdef CONFIG_SMP
817+
ldub [%g2 + %lo(boot_cpu_id)], %g1
818+
cmp %g1, 0xff ! unset means first CPU
819+
bne leon_smp_cpu_startup ! continue only with master
820+
nop
821+
#endif
822+
/* Get CPU-ID from most significant 4-bit of ASR17 */
823+
rd %asr17, %g1
824+
srl %g1, 28, %g1
823825

824-
cmp %g0,%g1
825-
beq sun4c_continue_boot !continue with master
826-
nop
826+
/* Update boot_cpu_id only on boot cpu */
827+
stub %g1, [%g2 + %lo(boot_cpu_id)]
827828

828-
ba leon_smp_cpu_startup
829-
nop
830-
#else
831829
ba sun4c_continue_boot
832830
nop
833-
#endif
834831
#endif
835832
set cputypval, %o2
836833
ldub [%o2 + 0x4], %l1

‎arch/sparc/kernel/leon_kernel.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <asm/traps.h>
2121
#include <asm/cacheflush.h>
2222
#include <asm/smp.h>
23+
#include <asm/setup.h>
2324

2425
#include "prom.h"
2526
#include "irq.h"
@@ -53,7 +54,7 @@ static inline unsigned int leon_eirq_get(int cpu)
5354
static void leon_handle_ext_irq(unsigned int irq, struct irq_desc *desc)
5455
{
5556
unsigned int eirq;
56-
int cpu = hard_smp_processor_id();
57+
int cpu = sparc_leon3_cpuid();
5758

5859
eirq = leon_eirq_get(cpu);
5960
if ((eirq & 0x10) && irq_map[eirq]->irq) /* bit4 tells if IRQ happened */
@@ -79,8 +80,8 @@ void leon_eirq_setup(unsigned int eirq)
7980
*/
8081
irq_link(veirq);
8182
mask = 1 << eirq;
82-
oldmask = LEON3_BYPASS_LOAD_PA(LEON_IMASK(0));
83-
LEON3_BYPASS_STORE_PA(LEON_IMASK(0), (oldmask | mask));
83+
oldmask = LEON3_BYPASS_LOAD_PA(LEON_IMASK(boot_cpu_id));
84+
LEON3_BYPASS_STORE_PA(LEON_IMASK(boot_cpu_id), (oldmask | mask));
8485
sparc_leon_eirq = eirq;
8586
}
8687

@@ -106,12 +107,12 @@ static int irq_choose_cpu(const struct cpumask *affinity)
106107

107108
cpus_and(mask, cpu_online_map, *affinity);
108109
if (cpus_equal(mask, cpu_online_map) || cpus_empty(mask))
109-
return 0;
110+
return boot_cpu_id;
110111
else
111112
return first_cpu(mask);
112113
}
113114
#else
114-
#define irq_choose_cpu(affinity) 0
115+
#define irq_choose_cpu(affinity) boot_cpu_id
115116
#endif
116117

117118
static int leon_set_affinity(struct irq_data *data, const struct cpumask *dest,
@@ -241,7 +242,7 @@ void __init leon_init_timers(irq_handler_t counter_fn)
241242
struct device_node *rootnp, *np, *nnp;
242243
struct property *pp;
243244
int len;
244-
int cpu, icsel;
245+
int icsel;
245246
int ampopts;
246247
int err;
247248

@@ -340,9 +341,8 @@ void __init leon_init_timers(irq_handler_t counter_fn)
340341
* accessed anyway.
341342
* In AMP systems, Linux must run on CPU0 for the time being.
342343
*/
343-
cpu = sparc_leon3_cpuid();
344-
icsel = LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->icsel[cpu/8]);
345-
icsel = (icsel >> ((7 - (cpu&0x7)) * 4)) & 0xf;
344+
icsel = LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->icsel[boot_cpu_id/8]);
345+
icsel = (icsel >> ((7 - (boot_cpu_id&0x7)) * 4)) & 0xf;
346346
leon3_irqctrl_regs += icsel;
347347

348348
/* Probe extended IRQ controller */

‎arch/sparc/kernel/leon_smp.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
extern ctxd_t *srmmu_ctx_table_phys;
5151
static int smp_processors_ready;
5252
extern volatile unsigned long cpu_callin_map[NR_CPUS];
53-
extern unsigned char boot_cpu_id;
5453
extern cpumask_t smp_commenced_mask;
5554
void __init leon_configure_cache_smp(void);
5655

0 commit comments

Comments
 (0)